build: avoid compiling platformtest test list generator

This also fixes a deprecation warning.
This commit is contained in:
Christian Schwarz 2024-09-08 15:12:31 +00:00
parent 740ab4b1b2
commit 0ab92d4861
4 changed files with 5 additions and 13 deletions

View File

@ -202,12 +202,10 @@ jobs:
key: quickcheck-<<parameters.goversion>> key: quickcheck-<<parameters.goversion>>
- run: make formatcheck - run: make formatcheck
- run: make generate-platform-test-list
- run: make zrepl-bin test-platform-bin - run: make zrepl-bin test-platform-bin
- run: make vet - run: make vet
- run: make lint - run: make lint
- run: rm -f artifacts/generate-platform-test-list
- store_artifacts: - store_artifacts:
path: artifacts path: artifacts
- persist_to_workspace: - persist_to_workspace:

View File

@ -228,7 +228,7 @@ _run_make_foreach_target_tuple:
$(MAKE) $(RUN_MAKE_FOREACH_TARGET_TUPLE_ARG) GOOS=illumos GOARCH=amd64 $(MAKE) $(RUN_MAKE_FOREACH_TARGET_TUPLE_ARG) GOOS=illumos GOARCH=amd64
##################### REGULAR TARGETS ##################### ##################### 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: lint:
$(GO_ENV_VARS) $(GOLANGCI_LINT) run ./... $(GO_ENV_VARS) $(GOLANGCI_LINT) run ./...
@ -252,9 +252,6 @@ endif
zrepl-bin: zrepl-bin:
$(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl-$(ZREPL_TARGET_TUPLE)" $(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_PATH := $(ARTIFACTDIR)/platformtest-cover-$(ZREPL_TARGET_TUPLE)
cover-platform-bin: cover-platform-bin:
$(GO_ENV_VARS) $(GO) test $(GO_BUILDFLAGS) \ $(GO_ENV_VARS) $(GO) test $(GO_BUILDFLAGS) \
@ -312,7 +309,7 @@ cover-full:
# not part of the build, must do that manually # not part of the build, must do that manually
.PHONY: generate formatcheck format .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=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 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 ./... $(GO_ENV_VARS) $(GO) generate $(GO_BUILDFLAGS) -x ./...

View File

@ -21,7 +21,6 @@ func check(err error) {
} }
type platformtestFuncDeclFinder struct { type platformtestFuncDeclFinder struct {
pkg *packages.Package
testFuncs []*ast.FuncDecl testFuncs []*ast.FuncDecl
} }
@ -78,7 +77,7 @@ func main() {
pkgs, err := packages.Load( pkgs, err := packages.Load(
&packages.Config{ &packages.Config{
Mode: packages.LoadFiles, Mode: packages.NeedFiles,
Tests: false, Tests: false,
}, },
os.Args[1], os.Args[1],
@ -97,9 +96,7 @@ func main() {
s := token.NewFileSet() s := token.NewFileSet()
a, err := parser.ParseFile(s, f, nil, parser.AllErrors) a, err := parser.ParseFile(s, f, nil, parser.AllErrors)
check(err) check(err)
finder := &platformtestFuncDeclFinder{ finder := &platformtestFuncDeclFinder{}
pkg: p,
}
ast.Walk(finder, a) ast.Walk(finder, a)
tests = append(tests, finder.testFuncs...) tests = append(tests, finder.testFuncs...)
} }

View File

@ -13,4 +13,4 @@ func (c Case) String() string {
return runtime.FuncForPC(reflect.ValueOf(c).Pointer()).Name() 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