From 8829960b1a59a96e9e759053c70eca9a6368c966 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 3 Dec 2020 11:30:26 +0100 Subject: [PATCH] make+Travis: use EXEC_SUFFIX for Windows, remove explicit goal To remove the need to have an extra make goal for the Windows itests, we instead add the flag windows=1 that sets the make variable EXEC_SUFFIX to properly add the ".exe" suffix to all executable names. --- .travis.yml | 2 +- Makefile | 29 ++++++----------------------- make/testing_flags.mk | 7 +++++++ 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index 51cf9402..594d78fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -73,7 +73,7 @@ jobs: - name: Btcd Integration Windows script: - - make itest-parallel-windows + - make itest-parallel windows=1 os: windows before_install: - choco upgrade --no-progress -y make netcat curl findutils diff --git a/Makefile b/Makefile index 79d6abdc..b27a4dac 100644 --- a/Makefile +++ b/Makefile @@ -141,13 +141,8 @@ build: build-itest: @$(call print, "Building itest lnd and lncli.") - $(GOBUILD) -tags="$(ITEST_TAGS)" -o lnd-itest $(ITEST_LDFLAGS) $(PKG)/cmd/lnd - $(GOBUILD) -tags="$(ITEST_TAGS)" -o lncli-itest $(ITEST_LDFLAGS) $(PKG)/cmd/lncli - -build-itest-windows: - @$(call print, "Building itest lnd and lncli.") - $(GOBUILD) -tags="$(ITEST_TAGS)" -o lnd-itest.exe $(ITEST_LDFLAGS) $(PKG)/cmd/lnd - $(GOBUILD) -tags="$(ITEST_TAGS)" -o lncli-itest.exe $(ITEST_LDFLAGS) $(PKG)/cmd/lncli + $(GOBUILD) -tags="$(ITEST_TAGS)" -o lnd-itest$(EXEC_SUFFIX) $(ITEST_LDFLAGS) $(PKG)/cmd/lnd + $(GOBUILD) -tags="$(ITEST_TAGS)" -o lncli-itest$(EXEC_SUFFIX) $(ITEST_LDFLAGS) $(PKG)/cmd/lncli install: @$(call print, "Installing lnd and lncli.") @@ -171,33 +166,21 @@ check: unit itest itest-only: @$(call print, "Running integration tests with ${backend} backend.") rm -rf lntest/itest/*.log lntest/itest/.logs-*; date - scripts/itest_part.sh 0 1 $(TEST_FLAGS) $(ITEST_FLAGS) + EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_part.sh 0 1 $(TEST_FLAGS) $(ITEST_FLAGS) lntest/itest/log_check_errors.sh itest: btcd build-itest itest-only itest-parallel: btcd @$(call print, "Building lnd binary") - CGO_ENABLED=0 $(GOBUILD) -tags="$(ITEST_TAGS)" -o lntest/itest/lnd-itest $(ITEST_LDFLAGS) $(PKG)/cmd/lnd + CGO_ENABLED=0 $(GOBUILD) -tags="$(ITEST_TAGS)" -o lntest/itest/lnd-itest$(EXEC_SUFFIX) $(ITEST_LDFLAGS) $(PKG)/cmd/lnd @$(call print, "Building itest binary for $(backend) backend") - CGO_ENABLED=0 $(GOTEST) -v ./lntest/itest -tags="$(DEV_TAGS) $(RPC_TAGS) rpctest $(backend)" -logoutput -goroutinedump -c -o lntest/itest/itest.test + CGO_ENABLED=0 $(GOTEST) -v ./lntest/itest -tags="$(DEV_TAGS) $(RPC_TAGS) rpctest $(backend)" -logoutput -goroutinedump -c -o lntest/itest/itest.test$(EXEC_SUFFIX) @$(call print, "Running tests") rm -rf lntest/itest/*.log lntest/itest/.logs-* - echo "$$(seq 0 $$(expr $(ITEST_PARALLELISM) - 1))" | xargs -P $(ITEST_PARALLELISM) -n 1 -I {} scripts/itest_part.sh {} $(NUM_ITEST_TRANCHES) $(TEST_FLAGS) - -itest-parallel-windows: btcd - @$(call print, "Building lnd binary") - CGO_ENABLED=0 $(GOBUILD) -tags="$(ITEST_TAGS)" -o lntest/itest/lnd-itest.exe $(ITEST_LDFLAGS) $(PKG)/cmd/lnd - - @$(call print, "Building itest binary for $(backend) backend") - CGO_ENABLED=0 $(GOTEST) -v ./lntest/itest -tags="$(DEV_TAGS) $(RPC_TAGS) rpctest $(backend)" -logoutput -goroutinedump -c -o lntest/itest/itest.test.exe - - @$(call print, "Running tests") - EXEC_SUFFIX=".exe" echo "$$(seq 0 $$(expr $(ITEST_PARALLELISM) - 1))" | xargs -P $(ITEST_PARALLELISM) -n 1 -I {} scripts/itest_part.sh {} $(NUM_ITEST_TRANCHES) $(TEST_FLAGS) - -itest-windows: btcd build-itest-windows itest-only + EXEC_SUFFIX=$(EXEC_SUFFIX) echo "$$(seq 0 $$(expr $(ITEST_PARALLELISM) - 1))" | xargs -P $(ITEST_PARALLELISM) -n 1 -I {} scripts/itest_part.sh {} $(NUM_ITEST_TRANCHES) $(TEST_FLAGS) unit: btcd @$(call print, "Running unit tests.") diff --git a/make/testing_flags.mk b/make/testing_flags.mk index e5f309fe..f8293c1c 100644 --- a/make/testing_flags.mk +++ b/make/testing_flags.mk @@ -3,6 +3,7 @@ RPC_TAGS = autopilotrpc chainrpc invoicesrpc routerrpc signrpc verrpc walletrpc LOG_TAGS = TEST_FLAGS = ITEST_FLAGS = +EXEC_SUFFIX = COVER_PKG = $$(go list -deps ./... | grep '$(PKG)' | grep -v lnrpc) NUM_ITEST_TRANCHES = 6 ITEST_PARALLELISM = $(NUM_ITEST_TRANCHES) @@ -23,6 +24,12 @@ ifneq ($(parallel),) ITEST_PARALLELISM = $(parallel) endif +# Windows needs to append a .exe suffix to all executable files, otherwise it +# won't run them. +ifneq ($(windows),) +EXEC_SUFFIX = .exe +endif + # If specific package is being unit tested, construct the full name of the # subpackage. ifneq ($(pkg),)