Add -q option to runtests.sh for quiet mode

This commit is contained in:
Alissa Huskey 2019-11-12 22:16:46 -07:00
parent 7f9f830022
commit 3f2b53d6b8

View file

@ -1,11 +1,40 @@
#!/usr/bin/env bash
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd $SCRIPTS_DIR/../..
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.
@ -24,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