From d81ce6a6d8e4c2213791bed981b86ab5e79d885b Mon Sep 17 00:00:00 2001 From: zjhe Date: Thu, 6 Mar 2025 21:39:30 +0800 Subject: [PATCH] fail the test-example.sh if go test fail, but after post.sh got executed --- avm_scripts/test-example.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/avm_scripts/test-example.sh b/avm_scripts/test-example.sh index 98813c7..18a346d 100644 --- a/avm_scripts/test-example.sh +++ b/avm_scripts/test-example.sh @@ -28,7 +28,8 @@ fi echo "==> go test" echo $TEST_TIMEOUT terraform version -go test -v -timeout=$TEST_TIMEOUT -run TestExample -- +test_failed=false +go test -v -timeout=$TEST_TIMEOUT -run TestExample || test_failed=true # change dir back into the example and run post.sh if it exists cd "$AVM_MOD_PATH/examples/$AVM_EXAMPLE" @@ -37,3 +38,8 @@ if [ -f post.sh ]; then chmod +x ./post.sh ./post.sh fi + +if [ "$test_failed" = true ]; then + echo "==> Test failed" + exit 1 +fi \ No newline at end of file