From 549157f46b7fad44a7420c5d05b71183a0d03036 Mon Sep 17 00:00:00 2001 From: Thomas Gummerer Date: Thu, 22 Feb 2024 15:39:17 -0300 Subject: [PATCH] set pipefail option when running tests (#1600) When running the tests in CI, we're piping the output of `go test` into gotestfmt to get prettier output. This works because `gotestfmt` will return a non-zero exit code when there are test failures. However when there are other failures, e.g. compilation of the tests failed, `gotestfmt` will have a 0 exit code. `go test` wouldn't, but because we're piping the results through, the shell swallows that unless we're setting the pipefail option. Set up the pipefail option here, so tests aren't accidentally green when compilation fails. /cc @thomas11 who noticed the tests were passing even though compilation failed in https://github.com/pulumi/examples/pull/1595 --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index cf4d08094..1357fd3ea 100644 --- a/Makefile +++ b/Makefile @@ -13,15 +13,15 @@ lint: tslint -c tslint.json **/*.ts only_test: - cd misc/test && go test -json ./... --timeout 4h -v -count=1 -short -parallel 40 --tags=all | gotestfmt + bash -c 'set -o pipefail && cd misc/test && go test -json ./... --timeout 4h -v -count=1 -short -parallel 40 --tags=all | gotestfmt' specific_test_set: echo "running $(TestSet) Acceptance Tests" - cd misc/test && go test -json . --timeout 4h -v -count=1 -short -parallel 40 --tags=all --run=TestAcc$(TestSet) | gotestfmt + bash -c 'set -o pipefail && cd misc/test && go test -json . --timeout 4h -v -count=1 -short -parallel 40 --tags=all --run=TestAcc$(TestSet) | gotestfmt' specific_tag_set: echo "running $(TagSet)$(TestSet) Acceptance Tests" - cd misc/test && go test -json . --timeout 4h -v -count=1 -short -parallel 40 --tags=$(TagSet) --run=TestAcc$(TagSet)$(TestSet) | gotestfmt + bash -c 'set -o pipefail && cd misc/test && go test -json . --timeout 4h -v -count=1 -short -parallel 40 --tags=$(TagSet) --run=TestAcc$(TagSet)$(TestSet) | gotestfmt' performance_test_set: cd misc/test && go test . --timeout 4h -count=1 -short -parallel 40 --tags=Performance