@@ -28,6 +28,9 @@ readonly ARDUINO_CI_SCRIPT_REPORT_PUSH_RETRIES=10
2828readonly ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS=0
2929readonly ARDUINO_CI_SCRIPT_FAILURE_EXIT_STATUS=1
3030
31+ # Arduino IDE 1.8.2 and newer generates a ton of garbage output (appears to be something related to jmdns) that must be filtered for the log to be readable and to avoid exceeding the maximum log length
32+ readonly ARDUINO_CI_SCRIPT_ARDUINO_OUTPUT_FILTER_REGEX=' (^\[SocketListener\(travis-job-*|^ *[0-9][0-9]*: [0-9a-g][0-9a-g]*|^dns\[query,[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*:[0-9][0-9]*, length=[0-9][0-9]*, id=|^dns\[response,[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*:[0-9][0-9]*, length=[0-9][0-9]*, id=|^questions:$|\[DNSQuestion@|^\.\]$|^\.\]\]$|^.\.\]$|^.\.\]\]$)'
33+
3134# Default value
3235ARDUINO_CI_SCRIPT_TOTAL_SKETCH_BUILD_FAILURE_COUNT=0
3336
@@ -504,13 +507,28 @@ function install_package()
504507
505508 # If defined add the boards manager URL to preferences
506509 if [[ " $packageURL " != " " ]]; then
510+
511+ # grep returns 1 when a line matches the regular expression so it's necessary to unset errexit
512+ set +o errexit
507513 # shellcheck disable=SC2086
508- eval \" ${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER} /${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER} /arduino\" --pref boardsmanager.additional.urls=" $packageURL " --save-prefs " $ARDUINO_CI_SCRIPT_VERBOSITY_REDIRECT "
514+ eval \" ${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER} /${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER} /arduino\" --pref boardsmanager.additional.urls=" $packageURL " --save-prefs " $ARDUINO_CI_SCRIPT_VERBOSITY_REDIRECT " | tr -Cd ' [:print:]\n\t' | grep -E -v " $ARDUINO_CI_SCRIPT_ARDUINO_OUTPUT_FILTER_REGEX " ; local -r arduinoPreferenceSettingExitStatus=" ${PIPESTATUS[0]} "
515+ set -o errexit
516+ # this is required because otherwise the exit status of arduino is ignored
517+ if [[ " $arduinoPreferenceSettingExitStatus " != " $ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS " ]]; then
518+ return_handler " $arduinoPreferenceSettingExitStatus "
519+ fi
509520 fi
510521
511522 # Install the package
523+ # grep returns 1 when a line matches the regular expression so it's necessary to unset errexit
524+ set +o errexit
512525 # shellcheck disable=SC2086
513- eval \" ${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER} /${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER} /arduino\" --install-boards " $packageID " " $ARDUINO_CI_SCRIPT_VERBOSITY_REDIRECT "
526+ eval \" ${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER} /${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER} /arduino\" --install-boards " $packageID " " $ARDUINO_CI_SCRIPT_VERBOSITY_REDIRECT " | tr -Cd ' [:print:]\n\t' | grep -E -v " $ARDUINO_CI_SCRIPT_ARDUINO_OUTPUT_FILTER_REGEX " ; local -r arduinoInstallPackageExitStatus=" ${PIPESTATUS[0]} "
527+ set -o errexit
528+ # this is required because otherwise the exit status of arduino is ignored
529+ if [[ " $arduinoInstallPackageExitStatus " != " $ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS " ]]; then
530+ return_handler " $arduinoPreferenceSettingExitStatus "
531+ fi
514532
515533 fi
516534 fi
@@ -802,7 +820,7 @@ function build_this_sketch()
802820 while [[ $arduinoExitStatus -gt $ARDUINO_CI_SCRIPT_HIGHEST_ACCEPTABLE_ARDUINO_EXIT_STATUS && $verifyCount -le $ARDUINO_CI_SCRIPT_SKETCH_VERIFY_RETRIES ]]; do
803821 # Verify the sketch
804822 # shellcheck disable=SC2086
805- " ${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER} /${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER} /arduino" $ARDUINO_CI_SCRIPT_DETERMINED_VERBOSE_BUILD --verify " $absoluteSketchName " --board " $boardID " 2>&1 | tee " $ARDUINO_CI_SCRIPT_VERIFICATION_OUTPUT_FILENAME " ; local arduinoExitStatus=" ${PIPESTATUS[0]} "
823+ " ${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER} /${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER} /arduino" $ARDUINO_CI_SCRIPT_DETERMINED_VERBOSE_BUILD --verify " $absoluteSketchName " --board " $boardID " 2>&1 | tr -Cd ' [:print:]\n\t ' | grep -E -v " $ARDUINO_CI_SCRIPT_ARDUINO_OUTPUT_FILTER_REGEX " | tee " $ARDUINO_CI_SCRIPT_VERIFICATION_OUTPUT_FILENAME " ; local arduinoExitStatus=" ${PIPESTATUS[0]} "
806824 local verifyCount=$(( verifyCount + 1 ))
807825 done
808826
0 commit comments