diff options
author | Rob Landley <rob@landley.net> | 2016-10-18 16:52:17 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2016-10-18 16:52:17 -0500 |
commit | ee14fc396dff50a263b62670f5484efcd6316aeb (patch) | |
tree | 55d8f9643ec81b4151e346fc9fa8e68ad7aa6a7d | |
parent | 54e8313d6ac41fb822ce8f15e7cbffcff44f58e0 (diff) | |
download | toybox-ee14fc396dff50a263b62670f5484efcd6316aeb.tar.gz |
Test infrastructure: collate make "test_single" and "make tests" into common
function, and add $C variable with an absolute path to the command being tested
(you need to call things like printf by path to avoid shell builtins, might as
well be consistent).
-rwxr-xr-x | scripts/test.sh | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/scripts/test.sh b/scripts/test.sh index 1337c529..01f9ea34 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -26,25 +26,35 @@ export LC_COLLATE=C . "$TOPDIR"/scripts/runtest.sh [ -f "$TOPDIR/generated/config.h" ] && export OPTIONFLAGS=:$(echo $(sed -nr 's/^#define CFG_(.*) 1/\1/p' "$TOPDIR/generated/config.h") | sed 's/ /:/g') +do_test() +{ + CMDNAME="${1##*/}" + CMDNAME="${CMDNAME%.test}" + [ -z "$2" ] && C="$(readlink -f ../$CMDNAME)" || C="$(which $CMDNAME)" + if [ ! -z "$C" ] + then + . "$1" + else + echo "$CMDNAME disabled" + fi +} + if [ $# -ne 0 ] then for i in "$@" do - CMDNAME="${i##*/}" - CMDNAME="${CMDNAME%.test}" - . "$TOPDIR"/tests/$i.test + do_test "$TOPDIR"/tests/$i.test done else for i in "$TOPDIR"/tests/*.test do - CMDNAME="${i##*/}" - CMDNAME="${CMDNAME%.test}" - if [ -h ../$CMDNAME ] || [ ! -z "$TEST_HOST" ] + if [ -z "$TEST_HOST" ] then - cd .. && rm -rf testdir && mkdir testdir && cd testdir || exit 1 - . $i + do_test "$i" 1 else - echo "$CMDNAME disabled" + rm -rf testdir && mkdir testdir && cd testdir || exit 1 + do_test "$i" + cd .. fi done fi |