Skip to content

Commit 010fda6

Browse files
committed
Add option to require sketch build failure
Closes #6
1 parent 4c988bb commit 010fda6

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ script:
132132
- build_sketch "${APPLICATION_FOLDER}/arduino/examples/01.Basics" "arduino:avr:uno" "false" '("1.8.1" "1.8.2")'
133133
# Test build_sketch with folder argument with an IDE version range
134134
- build_sketch "${APPLICATION_FOLDER}/arduino/examples/01.Basics" "arduino:avr:uno" "false" "1.8.1" "1.8.2"
135-
# Test build_sketch with folder argument allowed to fail (this will fail because WirelessOregonV2 is AVR specific)
136-
- build_sketch "${SKETCHBOOK_FOLDER}/libraries/WirelessOregonV2/examples" "arduino:sam:arduino_due_x_dbg" "true" "newest"
135+
# Test build_sketch with folder argument required to fail (this will fail because WirelessOregonV2 is AVR specific)
136+
- build_sketch "${SKETCHBOOK_FOLDER}/libraries/WirelessOregonV2/examples" "arduino:sam:arduino_due_x_dbg" "require" "newest"
137137

138138
- publish_report_to_gist "$REPORT_GITHUB_TOKEN" "$REPORT_GIST_URL" "true"
139139

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Turn on/off arduino verbose output during compilation. This will show all the co
8989
Pass some parameters from .travis.yml to the script. `build_sketch` will echo the arduino exit code to the log, which is documented at https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc#exit-status.
9090
- Parameter: **sketchPath** - Path to a sketch or folder containing sketches. If a folder is specified it will be recursively searched and all sketches will be verified.
9191
- Parameter: **boardID** - `package:arch:board[:parameters]` ID of the board to be compiled for. e.g. `arduino:avr:uno`. Board-specific parameters are only supported by Arduino IDE 1.5.5 and newer.
92-
- Parameter: **allowFail** - `true` or `false`. Allow the verification to fail without causing the CI build to fail.
92+
- Parameter: **allowFail** - `true`, `require`, or `false`. Allow the verification to fail without causing the CI build to fail. `require` will cause the build to fail if the sketch verification doesn't fail.
9393
- Parameter: **IDEversion** - A single version of the Arduino IDE to use to verify the sketch.
9494
- Parameter(optional): **IDEversionList** - A list of versions of the Arduino IDE to use to verify the sketch. e.g. `'("1.6.5-r5" "1.6.9" "1.8.2")'`. If no version list is provided all installed IDE versions will be used.
9595
- Parameter: **startIDEversion** - The start (inclusive) of a range of versions of the Arduino IDE to use to verify the sketch.

arduino-ci-script.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,6 @@ function build_this_sketch()
687687
local absoluteSketchName
688688
absoluteSketchName="$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
689689

690-
# Set default value of buildThisSketchExitCode
691-
local buildThisSketchExitCode=0
692-
693690
# Define a dummy value for arduinoExitCode so that the while loop will run at least once
694691
local arduinoExitCode=255
695692
# Retry the verification if arduino returns an exit code that indicates there may have been a temporary error not caused by a bug in the sketch or the arduino command
@@ -700,12 +697,25 @@ function build_this_sketch()
700697
local verifyCount=$((verifyCount + 1))
701698
done
702699

703-
# If the sketch build failed and failure is not allowed for this test then fail the Travis build after completing all sketch builds
704700
if [[ "$arduinoExitCode" != "0" ]]; then
705-
if [[ "$allowFail" != "true" ]]; then
706-
buildThisSketchExitCode=1
701+
# Sketch build failed
702+
if [[ "$allowFail" == "true" || "$allowFail" == "require" ]]; then
703+
# Failure is allowed for this test
704+
local -r buildThisSketchExitCode=0
705+
else
706+
# Failure is not allowed for this test, fail the Travis build after completing all sketch builds
707+
local -r buildThisSketchExitCode=1
707708
fi
708709
else
710+
# Sketch build succeeded
711+
if [[ "$allowFail" == "require" ]]; then
712+
# Failure is required for this test, fail the Travis build after completing all sketch builds
713+
local -r buildThisSketchExitCode=1
714+
else
715+
# Success is allowed
716+
local -r buildThisSketchExitCode=0
717+
fi
718+
709719
# Parse through the output from the sketch verification to count warnings and determine the compile size
710720
local warningCount=0
711721
while read -r outputFileLine; do

0 commit comments

Comments
 (0)