Skip to content

Commit 162947e

Browse files
authored
Merge pull request #155 from IABTechLab/aaq-check-test-failures-java-build
Check for test failures and errors in java build
2 parents 2168d20 + 35acfff commit 162947e

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

scripts/compile_java_test_and_verify.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ mvn_command+=" clean compile test"
5353
echo "DEBUG: Executing Maven command: ${mvn_command}"
5454
${mvn_command} | tee build.log
5555

56-
tests_run=$(cat build.log | grep "Tests run:" | tail -n 1 | sed 's/.*Tests run: \([0-9]*\).*/\1/')
56+
TEST_RESULTS=$(cat build.log | grep "Tests run:" | tail -n 1)
57+
tests_run=$(echo $TEST_RESULTS | sed 's/.*Tests run: \([0-9]*\).*/\1/')
58+
tests_failed=$(echo $TEST_RESULTS | sed 's/.*Failures: \([0-9]*\).*/\1/')
59+
tests_errors=$(echo $TEST_RESULTS | sed 's/.*Errors: \([0-9]*\).*/\1/')
5760

58-
echo "DEBUG: tests_run = $tests_run"
61+
echo "DEBUG: tests_run = $tests_run tests_failed = $tests_failed tests_errors = $tests_errors"
5962

6063
if [ -z "$tests_run" ]; then
6164
echo "WARNING: Could not determine the number of tests run."
@@ -67,4 +70,14 @@ if [ "$tests_run" -eq 0 ]; then
6770
exit 1
6871
fi
6972

70-
echo "INFO: $tests_run tests were run!"
73+
echo "INFO: $tests_run tests were run!"
74+
75+
if [ "$tests_failed" -ne 0 ]; then
76+
echo "ERROR: $tests_failed Tests Failed!"
77+
exit 1
78+
fi
79+
80+
if [ "$tests_errors" -ne 0 ]; then
81+
echo "ERROR: $tests_errors Tests had errors!"
82+
exit 1
83+
fi

0 commit comments

Comments
 (0)