Skip to content

Commit

Permalink
set pipefail option when running tests (pulumi#1600)
Browse files Browse the repository at this point in the history
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 pulumi#1595
  • Loading branch information
tgummerer committed Feb 22, 2024
1 parent 5e3fbc8 commit 549157f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 549157f

Please sign in to comment.