Skip to content

Commit 51888c7

Browse files
committed
Handle the allowFail setting more efficiently
As I add more factors that determine the success of the sketch build handling all possible settings of allowFail in multiple places becomes quite messy. So instead I will adjust the exit status according to allowFail just before returning from the function.
1 parent 8bcf464 commit 51888c7

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

arduino-ci-script.sh

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -747,23 +747,11 @@ function build_this_sketch()
747747
done
748748

749749
if [[ "$arduinoExitStatus" != "$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS" ]]; then
750-
# Sketch build failed
751-
if [[ "$allowFail" == "true" || "$allowFail" == "require" ]]; then
752-
# Failure is allowed for this test
753-
local -r buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS"
754-
else
755-
# Failure is not allowed for this test, fail the Travis build after completing all sketch builds
756-
local -r buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
757-
fi
750+
# Sketch verification failed
751+
local buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
758752
else
759-
# Sketch build succeeded
760-
if [[ "$allowFail" == "require" ]]; then
761-
# Failure is required for this test, fail the Travis build after completing all sketch builds
762-
local -r buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
763-
else
764-
# Success is allowed
765-
local -r buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS"
766-
fi
753+
# Sketch verification succeeded
754+
local buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS"
767755

768756
# Parse through the output from the sketch verification to count warnings and determine the compile size
769757
local warningCount=0
@@ -814,15 +802,22 @@ function build_this_sketch()
814802
local -r programStorage=${programStorageWithComma//,}
815803
local -r dynamicMemory=${dynamicMemoryWithComma//,}
816804

817-
if [[ "$boardIssue" != "" && "$ARDUINO_CI_SCRIPT_TEST_BOARD" == "true" && "$allowFail" != "true" ]]; then
805+
if [[ "$boardIssue" != "" && "$ARDUINO_CI_SCRIPT_TEST_BOARD" == "true" ]]; then
818806
# There was a board issue and board testing is enabled so fail the build
819-
local -r buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
807+
local buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
820808
fi
821809
fi
822810

823811
# Add the build data to the report file
824812
echo "$(date -u "+%Y-%m-%d %H:%M:%S")"$'\t'"$TRAVIS_BUILD_NUMBER"$'\t'"$TRAVIS_JOB_NUMBER"$'\t'"https://travis-ci.org/${TRAVIS_REPO_SLUG}/jobs/${TRAVIS_JOB_ID}"$'\t'"$TRAVIS_EVENT_TYPE"$'\t'"$TRAVIS_ALLOW_FAILURE"$'\t'"$TRAVIS_PULL_REQUEST"$'\t'"$TRAVIS_BRANCH"$'\t'"$TRAVIS_COMMIT"$'\t'"$TRAVIS_COMMIT_RANGE"$'\t'"${TRAVIS_COMMIT_MESSAGE%%$'\n'*}"$'\t'"$sketchName"$'\t'"$boardID"$'\t'"$IDEversion"$'\t'"$programStorage"$'\t'"$dynamicMemory"$'\t'"$warningCount"$'\t'"$allowFail"$'\t'"$arduinoExitStatus"$'\t'"$boardIssueCount"$'\t'"$boardIssue"$'\r' >> "$ARDUINO_CI_SCRIPT_REPORT_FILE_PATH"
825813

814+
# Adjust the exit status according to the allowFail setting
815+
if [[ "$buildThisSketchExitStatus" == "$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS" && ("$allowFail" == "true" || "$allowFail" == "require") ]]; then
816+
buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS"
817+
elif [[ "$buildThisSketchExitStatus" == "$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS" && "$allowFail" == "require" ]]; then
818+
buildThisSketchExitStatus="$ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS"
819+
fi
820+
826821
if [[ "$buildThisSketchExitStatus" != "$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS" ]]; then
827822
ARDUINO_CI_SCRIPT_TOTAL_SKETCH_BUILD_FAILURE_COUNT=$((ARDUINO_CI_SCRIPT_TOTAL_SKETCH_BUILD_FAILURE_COUNT + 1))
828823
fi

0 commit comments

Comments
 (0)