chiark / gitweb /
changelog: start 7.1~
[dgit.git] / tests / run-all
1 #!/bin/bash
2 set -e
3 # convenience script for running the tests outside adt-run
4 # usage: tests/using-intree tests/run-all [-p|--progressive] [tests/tests/*]
5 #
6 # passing `:' as if it were tests/tests/something is
7 #  a no-op and therefore just means to (delete and) set up the tmpdir
8
9 set -o pipefail
10
11 while [ $# != 0 ]; do
12         case "$1" in
13         --progressive|-p)       shift; export DGIT_TESTS_PROGRESSIVE=y;;
14         --)                     shift; break ;;
15         -*)     echo >&2 "run-all: unknown option $1"; exit 20 ;;
16         *)                      break ;;
17         esac
18 done
19
20 ncpus=$(nproc || echo 1)
21 jcpus=-j$(( ncpus * 134 / 100 ))
22
23 if [ "x$DGIT_TESTS_TMPDIR" != x ]; then
24         tmpdir="$PWD"
25         tmpdir="${tmpdir#/}"
26         tmpdir="${tmpdir//!/!#!}"
27         tmpdir="${tmpdir//\//!}"
28         tmpdir="$DGIT_TESTS_TMPDIR/$tmpdir"
29         rm -f tests/tmp
30         ln -ns -- "$tmpdir" tests/tmp
31 else
32         tmpdir=tests/tmp
33 fi
34
35 case "$DGIT_TESTS_PROGRESSIVE" in
36 ''|n)
37         rm -rf -- "$tmpdir"
38         ;;
39 esac
40
41 mkdir -p -- "$tmpdir"
42
43 case "$1" in
44 :)
45         shift
46         if [ $# = 0 ]; then exit 0; fi
47         ;;
48 esac
49
50 if [ $# != 0 ]; then
51         set TESTSCRIPTS="$*"
52 fi
53
54 export DGIT_GNUPG_STUNT_ERRLOG=$( tty -s ||: )
55
56 (
57  set -x
58  exec make $jcpus -k -f tests/Makefile "$@"
59 ) 2>&1 |tee tests/tmp/run-all.log