diff --git a/.gitignore b/.gitignore index 2fa5764..fe7cef4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build-cli /.project build-* +.tags diff --git a/Common.mk b/Common.mk index 0c1f92c..b534ae3 100644 --- a/Common.mk +++ b/Common.mk @@ -64,12 +64,18 @@ $(call show_config_variable,CURRENT_OS,[AUTODETECTED]) ifneq ($(TEST),) DEPENDENCIES_DIR = /var/tmp/Arduino-Makefile-testing-dependencies - DEPENDENCIES_MPIDE_DIR = $(DEPENDENCIES_DIR)/mpide-0023-linux64-20130817-test + DEPENDENCIES_MPIDE_DIR = $(shell find $(DEPENDENCIES_DIR) -name 'mpide-0023-*' -type d -exec ls -dt {} + | head -n 1) ifeq ($(MPIDE_DIR),) MPIDE_DIR = $(DEPENDENCIES_MPIDE_DIR) endif - DEPENDENCIES_ARDUINO_DIR = $(DEPENDENCIES_DIR)/arduino-1.0.6 + ifeq ($(CURRENT_OS),MAC) + IDE_DIRNAME=Arduino.app/Contents/Resources/Java + else + IDE_DIRNAME=arduino-1.0.6 + endif + + DEPENDENCIES_ARDUINO_DIR = $(DEPENDENCIES_DIR)/$(IDE_DIRNAME) ifeq ($(ARDUINO_DIR),) ARDUINO_DIR = $(DEPENDENCIES_ARDUINO_DIR) endif diff --git a/tests/script/bootstrap/arduino.sh b/tests/script/bootstrap/arduino.sh index 7c2c9ac..fe163a0 100644 --- a/tests/script/bootstrap/arduino.sh +++ b/tests/script/bootstrap/arduino.sh @@ -9,6 +9,7 @@ if [ -z "$ARDUINO_DIR" ] || ! test -e $ARDUINO_DIR || [ $OS == "cygwin" ]; then echo "Installing Arduino..." ARDUINO_BASENAME="arduino-1.0.6" + if [ $OS == "cygwin" ]; then ARDUINO_FILE="$ARDUINO_BASENAME-windows".zip EXTRACT_COMMAND="unzip -q" @@ -20,13 +21,27 @@ if [ -z "$ARDUINO_DIR" ] || ! test -e $ARDUINO_DIR || [ $OS == "cygwin" ]; then EXTRACT_COMMAND="tar -xzf" fi - ARDUINO_URL=http://arduino.cc/download.php?f=/$ARDUINO_FILE + ARDUINO_URL=https://downloads.arduino.cc/$ARDUINO_FILE _pushd $DEPENDENCIES_FOLDER if ! test -e $ARDUINO_FILE then echo "Downloading Arduino IDE..." download $ARDUINO_URL $ARDUINO_FILE + + download_type="$(file --mime-type $DEPENDENCIES_FOLDER/$ARDUINO_FILE)" + if [[ ! "$download_type" =~ zip ]]; then + mv $ARDUINO_FILE "bad-$ARDUINO_FILE" + + echo + echo "[ERROR] Unable to download valid IDE for testing" + echo " Downloaded file should be a zip but is: ${download_type##* }." + echo + echo " Download the IDE manually then try again." + echo " Download from: https://www.arduino.cc/en/Main/Software" + echo " Save to : $DEPENDENCIES_FOLDER" + exit 1 + fi fi if ! test -d $ARDUINO_BASENAME diff --git a/tests/script/bootstrap/common.sh b/tests/script/bootstrap/common.sh index c3cd90e..abfef88 100644 --- a/tests/script/bootstrap/common.sh +++ b/tests/script/bootstrap/common.sh @@ -184,7 +184,7 @@ if [ -z $COMMON_SOURCED ]; then PIP_SUDO_CMD=$SUDO_CMD fi - $PIP_SUDO_CMD pip install --src dependencies --pre -Ur $BOOTSTRAP_DIR/pip-requirements.txt + $PIP_SUDO_CMD pip install --ignore-installed --src dependencies --pre -Ur $BOOTSTRAP_DIR/pip-requirements.txt COMMON_SOURCED=1 fi diff --git a/tests/script/runtests.sh b/tests/script/runtests.sh index fd05c30..aec209e 100755 --- a/tests/script/runtests.sh +++ b/tests/script/runtests.sh @@ -1,9 +1,40 @@ #!/usr/bin/env bash +SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" TESTS_DIR=examples failures=() +if [[ "$1" == "-q" ]]; then + QUIET=1 +fi + +runtest() { + if [[ $QUIET ]]; then + make $* TEST=1 > /dev/null 2>&1 + else + output=`make $* TEST=1` + fi +} + +run() { + if [[ $QUIET ]]; then + "$@" > /dev/null 2>&1 + else + "$@" + fi +} + +info() { + if [[ $QUIET ]]; then + return + fi + + echo "$@" +} + +run pushd $SCRIPTS_DIR/../.. + # These examples cannot be tested easily at the moment as they require # alternate cores. The MakefileExample doesn't actually contain any source code # to compile. @@ -22,46 +53,47 @@ do done if ! $example_is_testable; then - echo "Skipping non-testable example $example..." + info "Skipping non-testable example $example..." continue fi - pushd $dir - echo "Compiling $example..." - make_output=`make clean TEST=1` - make_output=`make TEST=1` + run pushd $dir + info "Compiling $example..." + runtest clean + runtest + if [[ $? -ne 0 ]]; then failures+=("$example") - echo "Example $example failed" + info "Example $example failed" fi - make_output=`make disasm TEST=1` + runtest disasm if [[ $? -ne 0 ]]; then failures+=("$example disasm") - echo "Example $example disasm failed" + info "Example $example disasm failed" fi - make_output=`make generate_assembly TEST=1` + runtest generate_assembly if [[ $? -ne 0 ]]; then failures+=("$example generate_assembly") - echo "Example $example generate_assembly failed" + info "Example $example generate_assembly failed" fi - make_output=`make symbol_sizes TEST=1` + runtest symbol_sizes if [[ $? -ne 0 ]]; then failures+=("$example symbol_sizes") - echo "Example $example symbol_sizes failed" + info "Example $example symbol_sizes failed" fi - popd -done - -for failure in "${failures[@]}"; do - echo "Example $failure failed" + run popd done if [[ ${#failures[@]} -eq 0 ]]; then echo "All tests passed." else - exit 1 + for failure in "${failures[@]}"; do + echo "Example $failure failed" + done + + exit 1 fi