diff --git a/.gitignore b/.gitignore index a0d6d59..2fa5764 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ *.o build-cli /.project -/dependencies build-* diff --git a/.travis.yml b/.travis.yml index 68efeb5..f97a4ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: c compiler: - gcc -script: script/runtests.sh -before_install: script/bootstrap.sh +script: tests/script/runtests.sh +before_install: tests/script/bootstrap.sh diff --git a/README.md b/README.md index b929f6c..a5f1cff 100644 --- a/README.md +++ b/README.md @@ -215,9 +215,12 @@ Then, the following line must be added to the project Makefile : ## Test Suite This project includes a suite of example Makefiles and small Arduino and chipKIT -programs to assist the developers. Run `script/bootstrap.sh` to attempt to -automatically install the dependencies (Arduino IDE, MPIDE, etc.). Run -`script/runtests.sh` to attempt to compile all of the examples. +programs to assist the maintainers of the Makefile. Run +`tests/script/bootstrap.sh` to attempt to automatically install the dependencies +(Arduino IDE, MPIDE, etc.). Run `tests/script/runtests.sh` to attempt to compile +all of the examples. The bootstrap script is primarily intended for use by a +continuous integration server, specifically Travis CI. It is not intended for +normal users. ### Bare-Arduino–Project diff --git a/tests/AnalogInOutSerial/AnalogInOutSerial.ino b/examples/AnalogInOutSerial/AnalogInOutSerial.ino similarity index 100% rename from tests/AnalogInOutSerial/AnalogInOutSerial.ino rename to examples/AnalogInOutSerial/AnalogInOutSerial.ino diff --git a/tests/AnalogInOutSerial/Makefile b/examples/AnalogInOutSerial/Makefile similarity index 100% rename from tests/AnalogInOutSerial/Makefile rename to examples/AnalogInOutSerial/Makefile diff --git a/tests/Blink/Blink.ino b/examples/Blink/Blink.ino similarity index 100% rename from tests/Blink/Blink.ino rename to examples/Blink/Blink.ino diff --git a/tests/Blink/Makefile b/examples/Blink/Makefile similarity index 100% rename from tests/Blink/Makefile rename to examples/Blink/Makefile diff --git a/tests/BlinkChipKIT/BlinkChipKIT.pde b/examples/BlinkChipKIT/BlinkChipKIT.pde similarity index 100% rename from tests/BlinkChipKIT/BlinkChipKIT.pde rename to examples/BlinkChipKIT/BlinkChipKIT.pde diff --git a/tests/BlinkChipKIT/Makefile b/examples/BlinkChipKIT/Makefile similarity index 100% rename from tests/BlinkChipKIT/Makefile rename to examples/BlinkChipKIT/Makefile diff --git a/tests/BlinkInAVRC/Makefile b/examples/BlinkInAVRC/Makefile similarity index 100% rename from tests/BlinkInAVRC/Makefile rename to examples/BlinkInAVRC/Makefile diff --git a/tests/BlinkInAVRC/blink.c b/examples/BlinkInAVRC/blink.c similarity index 100% rename from tests/BlinkInAVRC/blink.c rename to examples/BlinkInAVRC/blink.c diff --git a/tests/BlinkWithoutDelay/BlinkWithoutDelay.ino b/examples/BlinkWithoutDelay/BlinkWithoutDelay.ino similarity index 100% rename from tests/BlinkWithoutDelay/BlinkWithoutDelay.ino rename to examples/BlinkWithoutDelay/BlinkWithoutDelay.ino diff --git a/tests/BlinkWithoutDelay/Makefile b/examples/BlinkWithoutDelay/Makefile similarity index 100% rename from tests/BlinkWithoutDelay/Makefile rename to examples/BlinkWithoutDelay/Makefile diff --git a/tests/Fade/Fade.ino b/examples/Fade/Fade.ino similarity index 100% rename from tests/Fade/Fade.ino rename to examples/Fade/Fade.ino diff --git a/tests/Fade/Makefile b/examples/Fade/Makefile similarity index 100% rename from tests/Fade/Makefile rename to examples/Fade/Makefile diff --git a/tests/HelloWorld/HelloWorld.ino b/examples/HelloWorld/HelloWorld.ino similarity index 100% rename from tests/HelloWorld/HelloWorld.ino rename to examples/HelloWorld/HelloWorld.ino diff --git a/tests/HelloWorld/Makefile b/examples/HelloWorld/Makefile similarity index 100% rename from tests/HelloWorld/Makefile rename to examples/HelloWorld/Makefile diff --git a/tests/TestSuiteCommon.mk b/examples/TestSuiteCommon.mk similarity index 81% rename from tests/TestSuiteCommon.mk rename to examples/TestSuiteCommon.mk index 5fa4f50..a66a007 100644 --- a/tests/TestSuiteCommon.mk +++ b/examples/TestSuiteCommon.mk @@ -1,5 +1,5 @@ ARDMK_DIR=../../ -DEPENDENCIES_FOLDER = ../../dependencies +DEPENDENCIES_FOLDER = /var/tmp/Arduino-Makefile-testing-dependencies DEPENDENCIES_MPIDE_DIR = $(DEPENDENCIES_FOLDER)/mpide-0023-linux64-20130817-test ifeq ($(MPIDE_DIR),) diff --git a/tests/WebServer/Makefile b/examples/WebServer/Makefile similarity index 100% rename from tests/WebServer/Makefile rename to examples/WebServer/Makefile diff --git a/tests/WebServer/WebServer.ino b/examples/WebServer/WebServer.ino similarity index 100% rename from tests/WebServer/WebServer.ino rename to examples/WebServer/WebServer.ino diff --git a/tests/master_reader/Makefile b/examples/master_reader/Makefile similarity index 100% rename from tests/master_reader/Makefile rename to examples/master_reader/Makefile diff --git a/tests/master_reader/master_reader.ino b/examples/master_reader/master_reader.ino similarity index 100% rename from tests/master_reader/master_reader.ino rename to examples/master_reader/master_reader.ino diff --git a/tests/toneMelody/Makefile b/examples/toneMelody/Makefile similarity index 100% rename from tests/toneMelody/Makefile rename to examples/toneMelody/Makefile diff --git a/tests/toneMelody/pitches.h b/examples/toneMelody/pitches.h similarity index 100% rename from tests/toneMelody/pitches.h rename to examples/toneMelody/pitches.h diff --git a/tests/toneMelody/toneMelody.ino b/examples/toneMelody/toneMelody.ino similarity index 100% rename from tests/toneMelody/toneMelody.ino rename to examples/toneMelody/toneMelody.ino diff --git a/script/runtests.sh b/script/runtests.sh deleted file mode 100755 index ad42f74..0000000 --- a/script/runtests.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -failures=() - -for dir in tests/*/ -do - dir=${dir%*/} - example=${dir##*/} - pushd $dir - echo "Compiling $example..." - make_output=`make clean` - make_output=`make` - if [[ $? -ne 0 ]]; then - failures+=("$example") - echo "Example $example failed" - fi - popd -done - -for failure in "${failures[@]}"; do - echo "Example $failure failed" -done - -if [[ ${#failures[@]} -eq 0 ]]; then - echo "All tests passed." -else - exit 1 -fi diff --git a/script/bootstrap.sh b/tests/script/bootstrap.sh similarity index 100% rename from script/bootstrap.sh rename to tests/script/bootstrap.sh diff --git a/script/bootstrap/arduino.sh b/tests/script/bootstrap/arduino.sh similarity index 100% rename from script/bootstrap/arduino.sh rename to tests/script/bootstrap/arduino.sh diff --git a/script/bootstrap/chipkit.sh b/tests/script/bootstrap/chipkit.sh similarity index 100% rename from script/bootstrap/chipkit.sh rename to tests/script/bootstrap/chipkit.sh diff --git a/script/bootstrap/common.sh b/tests/script/bootstrap/common.sh similarity index 98% rename from script/bootstrap/common.sh rename to tests/script/bootstrap/common.sh index 695d6b7..a6b6415 100644 --- a/script/bootstrap/common.sh +++ b/tests/script/bootstrap/common.sh @@ -132,7 +132,7 @@ if [ -z $COMMON_SOURCED ]; then echo "Storing all downloaded dependencies in the \"dependencies\" folder" - DEPENDENCIES_FOLDER="dependencies" + DEPENDENCIES_FOLDER="/var/tmp/Arduino-Makefile-testing-dependencies" mkdir -p $DEPENDENCIES_FOLDER if ! command -v make >/dev/null 2>&1; then diff --git a/script/bootstrap/pip-requirements.txt b/tests/script/bootstrap/pip-requirements.txt similarity index 100% rename from script/bootstrap/pip-requirements.txt rename to tests/script/bootstrap/pip-requirements.txt diff --git a/tests/script/runtests.sh b/tests/script/runtests.sh new file mode 100755 index 0000000..5f513da --- /dev/null +++ b/tests/script/runtests.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +TESTS_DIR=examples + +failures=() + +# 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. +NON_TESTABLE_EXAMPLES=(ATtinyBlink MakefileExample TinySoftWareSerial) + +for dir in $TESTS_DIR/*/ +do + dir=${dir%*/} + example=${dir##*/} + example_is_testable=true + for non_testable_example in "${NON_TESTABLE_EXAMPLES[@]}"; do + if [[ $example == $non_testable_example ]]; then + example_is_testable=false + break + fi + done + + if ! $example_is_testable; then + echo "Skipping non-testable example $example..." + continue + fi + + pushd $dir + echo "Compiling $example..." + make_output=`make clean` + make_output=`make` + if [[ $? -ne 0 ]]; then + failures+=("$example") + echo "Example $example failed" + fi + popd +done + +for failure in "${failures[@]}"; do + echo "Example $failure failed" +done + +if [[ ${#failures[@]} -eq 0 ]]; then + echo "All tests passed." +else + exit 1 +fi