From 8c112200424c17042f1071a1854211804e2541dc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 2 Sep 2018 03:27:39 -0500 Subject: [PATCH] [2.0.x] Debug Travis tests and scripts (#11704) --- .circleci/config.yml | 12 +++------ .travis.yml | 2 +- buildroot/bin/env_backup | 4 +-- buildroot/bin/env_restore | 27 ++++++++++++++----- ...ion_header_for_marlin => generate_version} | 15 +++++------ buildroot/bin/restore_configs | 16 ++++------- buildroot/bin/update_defaults | 2 +- buildroot/share/tests/DUE_tests | 7 +---- buildroot/share/tests/LPC1768_tests | 8 +++--- buildroot/share/tests/STM32F1_tests | 8 +++--- buildroot/share/tests/megaatmega2560_tests | 11 +++++--- buildroot/share/tests/start_tests | 14 ++++------ buildroot/share/tests/teensy35_tests | 9 +++---- 13 files changed, 64 insertions(+), 71 deletions(-) rename buildroot/bin/{generate_version_header_for_marlin => generate_version} (87%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 45dbf96bb3..13342b6fc6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -51,13 +51,13 @@ jobs: export PATH=`pwd`/buildroot/bin/:${PATH} # Generate custom version include - generate_version_header_for_marlin ./Marlin/src/inc + generate_version ./Marlin/src/inc cat ./Marlin/src/inc/_Version.h - # - # Back up the environment + # Backup pins_RAMPS.h + # + cp Marlin/src/pins/pins_RAMPS.h Marlin/src/pins/pins_RAMPS.h.backup # - env_backup ################################# # Build all sample configurations @@ -279,10 +279,6 @@ jobs: # Remove temp files from dependencies tree prior to caching rm -rf ~/Marlin/.piolibdeps/_tmp_* - # - # Restore the environment - # - env_restore - save_cache: diff --git a/.travis.yml b/.travis.yml index 39f21eaded..7a80292f3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ before_script: - cd ${TRAVIS_BUILD_DIR} # # Generate custom version include - - generate_version_header_for_marlin ${TRAVIS_BUILD_DIR}/Marlin/src/inc + - generate_version ${TRAVIS_BUILD_DIR}/Marlin/src/inc - cat ${TRAVIS_BUILD_DIR}/Marlin/src/inc/_Version.h # script: diff --git a/buildroot/bin/env_backup b/buildroot/bin/env_backup index 392ec425c1..164582de60 100755 --- a/buildroot/bin/env_backup +++ b/buildroot/bin/env_backup @@ -2,13 +2,13 @@ [ -z "$1" ] || cd $1 -if [ -d .test ]; then +if [ -d ".test" ]; then printf "\033[0;31mEnvironment backup already exists!\033[0m\n" else mkdir .test - cp -r Marlin/src/pins .test/pins cp Marlin/Configuration*.h .test/ [ -f Marlin/_Bootscreen.h ] && cp Marlin/_Bootscreen.h .test/ [ -f Marlin/_Statusscreen.h ] && cp Marlin/_Statusscreen.h .test/ + cp -r Marlin/src/pins .test/pins printf "\033[0;32mEnvironment Backup created\033[0m\n" fi diff --git a/buildroot/bin/env_restore b/buildroot/bin/env_restore index ed40211c34..defc6d8431 100755 --- a/buildroot/bin/env_restore +++ b/buildroot/bin/env_restore @@ -2,10 +2,25 @@ [ -z "$1" ] || cd $1 -cp Marlin/src/config/default/* Marlin/ -[ -f Marlin/_Bootscreen.h ] && rm Marlin/_Bootscreen.h -[ -f Marlin/_Statusscreen.h ] && rm Marlin/_Statusscreen.h -[ -d .test/pins ] && { cp .test/pins/* Marlin/src/pins/ ; rm -rf .test/pins ; } -[ -d .test ] && rm -r .test +if [ -d ".test" ]; then + cp .test/Configuration*.h Marlin/ + rm .test/Configuration*.h -printf "\033[0;32mEnvironment Restored\033[0m\n" + if [ -f .test/_Bootscreen.h ]; then + cp .test/_Bootscreen.h Marlin/ + rm .test/_Bootscreen.h + fi + + if [ -f .test/_Statusscreen.h ]; then + cp .test/_Statusscreen.h Marlin/ + rm .test/_Statusscreen.h + fi + + cp -r .test/pins Marlin/src + rm -r .test/pins + + rmdir .test + printf "\033[0;32mEnvironment Restored\033[0m\n" +else + printf "\033[0;31mEnvironment Backup not available!\033[0m\n" +fi diff --git a/buildroot/bin/generate_version_header_for_marlin b/buildroot/bin/generate_version similarity index 87% rename from buildroot/bin/generate_version_header_for_marlin rename to buildroot/bin/generate_version index 4310084618..292fe59225 100755 --- a/buildroot/bin/generate_version_header_for_marlin +++ b/buildroot/bin/generate_version @@ -1,5 +1,9 @@ #!/usr/bin/env bash -# generate_version_header_for_marlin +# +# generate_version +# +# Make a _Version.h file +# DIR="${1}" @@ -9,13 +13,8 @@ DISTDATE=$(date '+%Y-%m-%d %H:%M') BRANCH=$(git -C "${DIR}" symbolic-ref -q --short HEAD) VERSION=$(git -C "${DIR}" describe --tags --first-parent 2>/dev/null) -if [ -z "${BRANCH}" ]; then - BRANCH=$(echo "${TRAVIS_BRANCH}") -fi - -if [ -z "${VERSION}" ]; then - VERSION=$(git -C "${DIR}" describe --tags --first-parent --always 2>/dev/null) -fi +[ -z "${BRANCH}" ] && BRANCH=$(echo "${TRAVIS_BRANCH}") +[ -z "${VERSION}" ] && VERSION=$(git -C "${DIR}" describe --tags --first-parent --always 2>/dev/null) SHORT_BUILD_VERSION=$(echo "${BRANCH}") DETAILED_BUILD_VERSION=$(echo "${BRANCH}-${VERSION}") diff --git a/buildroot/bin/restore_configs b/buildroot/bin/restore_configs index 6f08363af8..aa0766b20b 100755 --- a/buildroot/bin/restore_configs +++ b/buildroot/bin/restore_configs @@ -1,15 +1,9 @@ #!/usr/bin/env bash -# -# restore_configs -# -# Restore default configs, delete pins backup and dogm bitmaps -# -# Restore the (possibly modified) Configurations -[ -d ".test" -a -f ".test/Configuration.h" ] && cp .test/Configuration*.h Marlin/ +cp Marlin/src/config/default/Configuration*.h Marlin -# Restore the original unmodified pins -[ -d ".test/pins" ] && cp -r .test/pins Marlin/src/pins/ +[ -f Marlin/src/pins/pins_RAMPS.h.backup ] && cp Marlin/src/pins/pins_RAMPS.h.backup Marlin/src/pins/pins_RAMPS.h +rm -f Marlin/src/pins/pins_RAMPS.h.backup -# Delete DOGM bitmaps -rm -f Marlin/_*screen.h +rm -f Marlin/_Bootscreen.h +rm -f Marlin/_Statusscreen.h diff --git a/buildroot/bin/update_defaults b/buildroot/bin/update_defaults index 2379eb5ca1..2dcea0d155 100755 --- a/buildroot/bin/update_defaults +++ b/buildroot/bin/update_defaults @@ -1,3 +1,3 @@ #!/usr/bin/env bash -cp Marlin/Configuration*.h .test/ +cp Marlin/Configuration*.h Marlin/src/config/default diff --git a/buildroot/share/tests/DUE_tests b/buildroot/share/tests/DUE_tests index 270fa0ab37..100cdd570b 100755 --- a/buildroot/share/tests/DUE_tests +++ b/buildroot/share/tests/DUE_tests @@ -3,14 +3,9 @@ # exit on first failure set -e -env_backup - +restore_configs opt_set MOTHERBOARD BOARD_RAMPS4DUE_EFB -update_defaults - opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS opt_set E0_AUTO_FAN_PIN 8 opt_set EXTRUDER_AUTO_FAN_SPEED 100 exec_test $1 $2 "RAMPS4DUE_EFB S_CURVE_ACCELERATION EEPROM_SETTINGS" - -env_restore diff --git a/buildroot/share/tests/LPC1768_tests b/buildroot/share/tests/LPC1768_tests index ee0f699cac..b9f1e0cf45 100755 --- a/buildroot/share/tests/LPC1768_tests +++ b/buildroot/share/tests/LPC1768_tests @@ -3,11 +3,8 @@ # exit on first failure set -e -env_backup - +restore_configs opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB -update_defaults - exec_test $1 $2 "Build Re-ARM Default Configuration" restore_configs @@ -63,4 +60,5 @@ opt_enable FAN_SOFT_PWM SDSUPPORT opt_enable USE_XMAX_PLUG exec_test $1 $2 "MKS SBASE Many less common options" -env_restore +#clean up +restore_configs diff --git a/buildroot/share/tests/STM32F1_tests b/buildroot/share/tests/STM32F1_tests index 0d9790d712..0d1fd90991 100755 --- a/buildroot/share/tests/STM32F1_tests +++ b/buildroot/share/tests/STM32F1_tests @@ -3,12 +3,10 @@ # exit on first failure set -e -env_backup - +restore_configs opt_set MOTHERBOARD BOARD_STM32F1R -update_defaults - opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT exec_test $1 $2 "STM32F1R EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT" -env_restore +#cleanup +restore_configs diff --git a/buildroot/share/tests/megaatmega2560_tests b/buildroot/share/tests/megaatmega2560_tests index d1a13e1785..faf7cd0af0 100755 --- a/buildroot/share/tests/megaatmega2560_tests +++ b/buildroot/share/tests/megaatmega2560_tests @@ -3,13 +3,15 @@ # exit on first failure set -e -env_backup - +# +# Backup pins_RAMPS.h +# +cp Marlin/src/pins/pins_RAMPS.h Marlin/src/pins/pins_RAMPS.h.backup # # Build with the default configurations # +restore_configs exec_test $1 $2 "Default Configuration" - # # Test 2 extruders (one MAX6675) and heated bed on basic RAMPS 1.4 # Test a "Fix Mounted" Probe with Safe Homing, some arc options, @@ -309,4 +311,5 @@ exec_test $1 $2 "TMC2208 Config" # # -env_restore +#clean up +restore_configs diff --git a/buildroot/share/tests/start_tests b/buildroot/share/tests/start_tests index 6905d80a7c..53c24f44d8 100755 --- a/buildroot/share/tests/start_tests +++ b/buildroot/share/tests/start_tests @@ -1,17 +1,11 @@ #!/usr/bin/env bash -# -# start_tests -# -# Run one or more tests -# - export PATH="$PATH:$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )" export PATH="$PATH:./buildroot/bin" # exit on first failure set -e -exec_test() { +exec_test () { printf "\033[0;32m[Test $2] \033[0m$3... " if build_marlin_pio $1 "-e $2"; then printf "\033[0;32mPassed\033[0m\n" @@ -24,6 +18,9 @@ exec_test() { } export -f exec_test +env_backup +printf "Running \033[0;32m$2\033[0m Tests\n" + if [[ $3 = "--deep-clean" ]]; then echo "Deleting all PlatformIO caches, downloads and installed packages..." env_clean --deep @@ -39,9 +36,8 @@ if [[ $2 = "ALL" ]]; then $f $1 $testenv done else - printf "Running \033[0;32m$2\033[0m Tests\n" exec_test $1 "$2 --target clean" "Setup Build Environment" $2_tests $1 $2 fi - printf "\033[0;32mAll tests completed successfully\033[0m\n" +env_restore diff --git a/buildroot/share/tests/teensy35_tests b/buildroot/share/tests/teensy35_tests index 4ed4ba6a20..0adb977cbc 100755 --- a/buildroot/share/tests/teensy35_tests +++ b/buildroot/share/tests/teensy35_tests @@ -3,11 +3,9 @@ # exit on first failure set -e -env_backup - +restore_configs opt_set MOTHERBOARD BOARD_TEENSY35_36 -update_defaults - +cp Marlin/src/pins/pins_RAMPS.h Marlin/src/pins/pins_RAMPS.h.backup # # Test Teensy3.5 with default config # @@ -94,4 +92,5 @@ opt_add_adv Z2_MAX_PIN 2 opt_enable USE_XMAX_PLUG exec_test $1 $2 "Z_DUAL_STEPPER_DRIVERS, Z_DUAL_ENDSTOPS" -env_restore +#cleanup +restore_configs