Skip to content

Commit bc7f89a

Browse files
committed
Surpress unwanted output from arduino
Arduino IDE 1.8.2 and newer causes a lot of unwanted output (something related to jmdns?) to clutter up the log. This makes it almost unreadable and can cause the log to exceed the maximum length of 4 MB imposed by Travis CI. Workaround for #1
1 parent 23d3d2c commit bc7f89a

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

Diff for: arduino-ci-script.sh

+25-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ readonly ARDUINO_CI_SCRIPT_REPORT_PUSH_RETRIES=10
2828
readonly ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS=0
2929
readonly 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
3235
ARDUINO_CI_SCRIPT_TOTAL_SKETCH_BUILD_FAILURE_COUNT=0
3336

@@ -504,13 +507,32 @@ 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+
set +o errexit
519+
disable_verbosity
520+
exit "$arduinoPreferenceSettingExitStatus"
521+
fi
509522
fi
510523

511524
# Install the package
525+
# grep returns 1 when a line matches the regular expression so it's necessary to unset errexit
526+
set +o errexit
512527
# 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"
528+
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]}"
529+
set -o errexit
530+
# this is required because otherwise the exit status of arduino is ignored
531+
if [[ "$arduinoInstallPackageExitStatus" != "$ARDUINO_CI_SCRIPT_SUCCESS_EXIT_STATUS" ]]; then
532+
set +o errexit
533+
disable_verbosity
534+
exit "$arduinoInstallPackageExitStatus"
535+
fi
514536

515537
fi
516538
fi
@@ -802,7 +824,7 @@ function build_this_sketch()
802824
while [[ $arduinoExitStatus -gt $ARDUINO_CI_SCRIPT_HIGHEST_ACCEPTABLE_ARDUINO_EXIT_STATUS && $verifyCount -le $ARDUINO_CI_SCRIPT_SKETCH_VERIFY_RETRIES ]]; do
803825
# Verify the sketch
804826
# 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]}"
827+
"${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]}"
806828
local verifyCount=$((verifyCount + 1))
807829
done
808830

0 commit comments

Comments
 (0)