chiark / gitweb /
b18822304ae04d6712dfcc57b11d7d4f7ceabfb7
[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 set -o pipefail
7
8 while [ $# != 0 ]; do
9         case "$1" in
10         --progressive|-p)       shift; export DGIT_TESTS_PROGRESSIVE=y;;
11         --)                     shift; break ;;
12         -*)     echo >&2 "run-all: unknown option $1"; exit 20 ;;
13         *)                      break ;;
14         esac
15 done
16
17 ncpus=$(nproc || echo 1)
18 jcpus=-j$(( ncpus * 134 / 100 ))
19
20 if [ "x$DGIT_TESTS_TMPDIR" != x ]; then
21         tmpdir="$PWD"
22         tmpdir="${tmpdir#/}"
23         tmpdir="${tmpdir//!/!#!}"
24         tmpdir="${tmpdir//\//!}"
25         tmpdir="$DGIT_TESTS_TMPDIR/$tmpdir"
26         rm -f tests/tmp
27         ln -ns -- "$tmpdir" tests/tmp
28 else
29         tmpdir=tests/tmp
30 fi
31
32 case "$DGIT_TESTS_PROGRESSIVE" in
33 ''|n)
34         rm -rf -- "$tmpdir"
35         ;;
36 esac
37
38 mkdir -p -- "$tmpdir"
39
40 if [ $# != 0 ]; then
41         set TESTSCRIPTS="$*"
42 fi
43
44 export DGIT_GNUPG_STUNT_ERRLOG=$( tty -s ||: )
45
46 (
47  set -x
48  exec make $jcpus -k -f tests/Makefile "$@"
49 ) 2>&1 |tee tests/tmp/run-all.log