Skip to content

Commit ef5e44a

Browse files
Merge pull request OpenLiberty#505 from gilbysunil14/Issue481-Green-Builds-Showing-Despite-Test-Failures
Issue 481 - Green Builds Showing Despite Test Failures
2 parents 889f172 + 9c700fe commit ef5e44a

File tree

1 file changed

+22
-5
lines changed
  • src/test/resources/ci/scripts

1 file changed

+22
-5
lines changed

src/test/resources/ci/scripts/exec.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
############################################################################
4-
# Copyright (c) 2022 IBM Corporation and others.
4+
# Copyright (c) 2022, 2025 IBM Corporation and others.
55
#
66
# This program and the accompanying materials are made available under the
77
# terms of the Eclipse Public License v. 2.0 which is available at
@@ -26,6 +26,9 @@ currentTime=(date +"%Y/%m/%d-%H:%M:%S:%3N")
2626
# Operating system.
2727
OS=$(uname -s)
2828

29+
# Boolean to see if any failure has occured while executing commands
30+
failure="false"
31+
2932
main() {
3033

3134
setVscodeVersionToTest
@@ -40,6 +43,7 @@ main() {
4043
npm run build
4144
npm run compile
4245
vsce package
46+
updateExitStatus
4347
else
4448

4549
#Initialisation step
@@ -67,9 +71,12 @@ main() {
6771
chown -R runner src/test/resources/gradle
6872
# Gradle tests should be run before Maven tests because the after hook for copying the screeshots from temporary to a permananet location is written in the Maven tests so that the copying will be done at the end of every test cases.
6973
npm run test-mac-gradle -- -u
74+
updateExitStatus
7075
npm run test-mac-maven -- -u
76+
updateExitStatus
7177
else
7278
npm run test -- -u
79+
updateExitStatus
7380
fi
7481
else
7582
# Run the plugin's install goal against the target vscode version
@@ -78,18 +85,19 @@ main() {
7885
chown -R runner src/test/resources/gradle
7986
# Gradle tests should be run before Maven tests because the after hook for copying the screeshots from temporary to a permananet location is written in the Maven tests so that the copying will be done at the end of every test cases.
8087
npm run test-mac-gradle -- -u -c $VSCODE_VERSION_TO_RUN
88+
updateExitStatus
8189
npm run test-mac-maven -- -u -c $VSCODE_VERSION_TO_RUN
82-
90+
updateExitStatus
8391
else
8492
npm run test -- -u -c $VSCODE_VERSION_TO_RUN
93+
updateExitStatus
8594
fi
8695
fi
8796
fi
8897

8998
# If there were any errors, gather some debug data before exiting.
90-
rc=$?
91-
if [ "$rc" -ne 0 ]; then
92-
echo "ERROR: Failure while driving npm install on plugin. rc: ${rc}."
99+
if [ "$failure" = "true" ]; then
100+
echo "ERROR: Failure occurred while running ${TYPE} step."
93101

94102
if [ $TYPE = "TEST" ]; then
95103
echo "DEBUG: Maven Liberty messages.log:\n"
@@ -152,4 +160,13 @@ setVscodeVersionToTest() {
152160
fi
153161
}
154162

163+
# Finding the exit status of a command and updating failure boolean.
164+
# Need to call this method after executing each npm command to store the status.
165+
updateExitStatus() {
166+
status=$?
167+
if [ "$failure" = "false" ] && [ $status -ne 0 ]; then
168+
failure="true"
169+
fi
170+
}
171+
155172
main "$@"

0 commit comments

Comments
 (0)