annotate scripts/test.sh @ 1485:8700cbe1cb29 draft

Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
author Rob Landley <rob@landley.net>
date Sat, 20 Sep 2014 13:09:14 -0500
parents 7dd487ddd7dc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
204
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
1 #!/bin/bash
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
2
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
3 [ -z "$TOPDIR" ] && TOPDIR="$(pwd)"
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
4
1485
8700cbe1cb29 Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
Rob Landley <rob@landley.net>
parents: 1376
diff changeset
5 trap 'kill $(jobs -p) 2>/dev/null; exit 1' INT
8700cbe1cb29 Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
Rob Landley <rob@landley.net>
parents: 1376
diff changeset
6
8700cbe1cb29 Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
Rob Landley <rob@landley.net>
parents: 1376
diff changeset
7 rm -rf generated/testdir
8700cbe1cb29 Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
Rob Landley <rob@landley.net>
parents: 1376
diff changeset
8 mkdir -p generated/testdir/testdir
204
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
9
291
620a2eab6b82 More tweaks to rmdir.test and the testing infrastructure.
Rob Landley <rob@landley.net>
parents: 287
diff changeset
10 if [ -z "$TEST_HOST" ]
204
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
11 then
1088
4948a942de49 Teach scripts/test.sh to call scripts/single.sh.
Rob Landley <rob@landley.net>
parents: 606
diff changeset
12 if [ $# -ne 0 ]
4948a942de49 Teach scripts/test.sh to call scripts/single.sh.
Rob Landley <rob@landley.net>
parents: 606
diff changeset
13 then
1485
8700cbe1cb29 Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
Rob Landley <rob@landley.net>
parents: 1376
diff changeset
14 PREFIX=generated/testdir/ scripts/single.sh "$@" || exit 1
1088
4948a942de49 Teach scripts/test.sh to call scripts/single.sh.
Rob Landley <rob@landley.net>
parents: 606
diff changeset
15 else
1485
8700cbe1cb29 Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
Rob Landley <rob@landley.net>
parents: 1376
diff changeset
16 make install_flat PREFIX=generated/testdir || exit 1
1088
4948a942de49 Teach scripts/test.sh to call scripts/single.sh.
Rob Landley <rob@landley.net>
parents: 606
diff changeset
17 fi
204
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
18 fi
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
19
1485
8700cbe1cb29 Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
Rob Landley <rob@landley.net>
parents: 1376
diff changeset
20 cd generated/testdir
1376
7dd487ddd7dc Have "make test" run tests in testdir/testdir instead of same directory as command symlinks. (Makes cleanup easier.)
Rob Landley <rob@landley.net>
parents: 1120
diff changeset
21 PATH="$PWD:$PATH"
7dd487ddd7dc Have "make test" run tests in testdir/testdir instead of same directory as command symlinks. (Makes cleanup easier.)
Rob Landley <rob@landley.net>
parents: 1120
diff changeset
22 cd testdir
204
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
23
1485
8700cbe1cb29 Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
Rob Landley <rob@landley.net>
parents: 1376
diff changeset
24 . "$TOPDIR"/scripts/runtest.sh
300
8f481b23138b Adjust "optional" function (gen_config.h became generated/config.h).
Rob Landley <rob@landley.net>
parents: 291
diff changeset
25 [ -f "$TOPDIR/generated/config.h" ] && export OPTIONFLAGS=:$(echo $(sed -nr 's/^#define CFG_(.*) 1/\1/p' "$TOPDIR/generated/config.h") | sed 's/ /:/g')
204
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
26
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
27 if [ $# -ne 0 ]
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
28 then
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
29 for i in "$@"
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
30 do
1485
8700cbe1cb29 Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
Rob Landley <rob@landley.net>
parents: 1376
diff changeset
31 . "$TOPDIR"/tests/$i.test
204
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
32 done
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
33 else
1485
8700cbe1cb29 Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
Rob Landley <rob@landley.net>
parents: 1376
diff changeset
34 for i in "$TOPDIR"/tests/*.test
204
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
35 do
287
977302071875 Teach run-all-tests mode to only test enabled commands.
Rob Landley <rob@landley.net>
parents: 275
diff changeset
36 CMDNAME="$(echo "$i" | sed 's@.*/\(.*\)\.test@\1@')"
1376
7dd487ddd7dc Have "make test" run tests in testdir/testdir instead of same directory as command symlinks. (Makes cleanup easier.)
Rob Landley <rob@landley.net>
parents: 1120
diff changeset
37 if [ -h ../$CMDNAME ] || [ ! -z "$TEST_HOST" ]
287
977302071875 Teach run-all-tests mode to only test enabled commands.
Rob Landley <rob@landley.net>
parents: 275
diff changeset
38 then
1376
7dd487ddd7dc Have "make test" run tests in testdir/testdir instead of same directory as command symlinks. (Makes cleanup easier.)
Rob Landley <rob@landley.net>
parents: 1120
diff changeset
39 cd .. && rm -rf testdir && mkdir testdir && cd testdir || exit 1
287
977302071875 Teach run-all-tests mode to only test enabled commands.
Rob Landley <rob@landley.net>
parents: 275
diff changeset
40 . $i
977302071875 Teach run-all-tests mode to only test enabled commands.
Rob Landley <rob@landley.net>
parents: 275
diff changeset
41 else
977302071875 Teach run-all-tests mode to only test enabled commands.
Rob Landley <rob@landley.net>
parents: 275
diff changeset
42 echo "$CMDNAME disabled"
977302071875 Teach run-all-tests mode to only test enabled commands.
Rob Landley <rob@landley.net>
parents: 275
diff changeset
43 fi
204
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
44 done
64b6941c2f51 Add a wrapper to run tests out of scripts/test. With no arguments, runs all
Rob Landley <rob@landley.net>
parents:
diff changeset
45 fi