From 0ab92d48614eacdc237b2f3173fac0d66c66d418 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Sun, 8 Sep 2024 15:12:31 +0000 Subject: [PATCH] build: avoid compiling platformtest test list generator This also fixes a deprecation warning. --- .circleci/config.yml | 2 -- Makefile | 7 ++----- platformtest/tests/gen/gen.go | 7 ++----- platformtest/tests/tests.go | 2 +- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a9d1c20..490abfa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -202,12 +202,10 @@ jobs: key: quickcheck-<> - run: make formatcheck - - run: make generate-platform-test-list - run: make zrepl-bin test-platform-bin - run: make vet - run: make lint - - run: rm -f artifacts/generate-platform-test-list - store_artifacts: path: artifacts - persist_to_workspace: diff --git a/Makefile b/Makefile index fcc4b8a..08405be 100644 --- a/Makefile +++ b/Makefile @@ -228,7 +228,7 @@ _run_make_foreach_target_tuple: $(MAKE) $(RUN_MAKE_FOREACH_TARGET_TUPLE_ARG) GOOS=illumos GOARCH=amd64 ##################### REGULAR TARGETS ##################### -.PHONY: lint test-go test-platform cover-merge cover-html vet zrepl-bin test-platform-bin generate-platform-test-list +.PHONY: lint test-go test-platform cover-merge cover-html vet zrepl-bin test-platform-bin lint: $(GO_ENV_VARS) $(GOLANGCI_LINT) run ./... @@ -252,9 +252,6 @@ endif zrepl-bin: $(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl-$(ZREPL_TARGET_TUPLE)" -generate-platform-test-list: - $(GO_BUILD) -o $(ARTIFACTDIR)/generate-platform-test-list ./platformtest/tests/gen - COVER_PLATFORM_BIN_PATH := $(ARTIFACTDIR)/platformtest-cover-$(ZREPL_TARGET_TUPLE) cover-platform-bin: $(GO_ENV_VARS) $(GO) test $(GO_BUILDFLAGS) \ @@ -312,7 +309,7 @@ cover-full: # not part of the build, must do that manually .PHONY: generate formatcheck format -generate: generate-platform-test-list +generate: protoc -I=replication/logic/pdu --go_out=replication/logic/pdu --go-grpc_out=replication/logic/pdu replication/logic/pdu/pdu.proto protoc -I=rpc/grpcclientidentity/example --go_out=rpc/grpcclientidentity/example/pdu --go-grpc_out=rpc/grpcclientidentity/example/pdu rpc/grpcclientidentity/example/grpcauth.proto $(GO_ENV_VARS) $(GO) generate $(GO_BUILDFLAGS) -x ./... diff --git a/platformtest/tests/gen/gen.go b/platformtest/tests/gen/gen.go index 3147297..dd319f4 100644 --- a/platformtest/tests/gen/gen.go +++ b/platformtest/tests/gen/gen.go @@ -21,7 +21,6 @@ func check(err error) { } type platformtestFuncDeclFinder struct { - pkg *packages.Package testFuncs []*ast.FuncDecl } @@ -78,7 +77,7 @@ func main() { pkgs, err := packages.Load( &packages.Config{ - Mode: packages.LoadFiles, + Mode: packages.NeedFiles, Tests: false, }, os.Args[1], @@ -97,9 +96,7 @@ func main() { s := token.NewFileSet() a, err := parser.ParseFile(s, f, nil, parser.AllErrors) check(err) - finder := &platformtestFuncDeclFinder{ - pkg: p, - } + finder := &platformtestFuncDeclFinder{} ast.Walk(finder, a) tests = append(tests, finder.testFuncs...) } diff --git a/platformtest/tests/tests.go b/platformtest/tests/tests.go index 4b16441..9db0326 100644 --- a/platformtest/tests/tests.go +++ b/platformtest/tests/tests.go @@ -13,4 +13,4 @@ func (c Case) String() string { return runtime.FuncForPC(reflect.ValueOf(c).Pointer()).Name() } -//go:generate ../../artifacts/generate-platform-test-list github.com/zrepl/zrepl/platformtest/tests +//go:generate go run ./gen github.com/zrepl/zrepl/platformtest/tests