aboutsummaryrefslogtreecommitdiff
path: root/tests/script/runtests.sh
diff options
context:
space:
mode:
authorJohn Whittington <git@jbrengineering.co.uk>2020-08-06 19:21:23 +0200
committerJohn Whittington <git@jbrengineering.co.uk>2020-08-06 20:01:05 +0200
commitbf319c49b7f7ff17e073422a3ba06a701e12f590 (patch)
tree66d05b1e87a9efcd27af2f485dc3cfae528b553d /tests/script/runtests.sh
parent185a1e9e3527794a49451915009fb48d9e678080 (diff)
platform neutral examples and manual cherry-pick merge of https://github.com/alissa-huskey/Arduino-Makefile/tree/test_fixes
Diffstat (limited to 'tests/script/runtests.sh')
-rwxr-xr-xtests/script/runtests.sh69
1 files changed, 51 insertions, 18 deletions
diff --git a/tests/script/runtests.sh b/tests/script/runtests.sh
index ba75fe4..84fa4c5 100755
--- a/tests/script/runtests.sh
+++ b/tests/script/runtests.sh
@@ -1,9 +1,41 @@
#!/usr/bin/env bash
+SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TESTS_DIR=examples
+export ARDMK_DIR="${ARDMK_DIR:-$SCRIPTS_DIR/../..}"
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 +54,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