Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail the test-example.sh if go test fail, but after post.sh got executed #92

Merged
merged 1 commit into from
Mar 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion avm_scripts/test-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was -- doing before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is a mistake.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will go test return a none 0 exit code if it fails? Is that how this will work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, once go test failed we'll set test_failed to true, then return 1 finally.


# change dir back into the example and run post.sh if it exists
cd "$AVM_MOD_PATH/examples/$AVM_EXAMPLE"
Expand All @@ -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