chiark / gitweb /
git-debrebase: wip new-upstream, ready for testing
[dgit.git] / tests / adhoc
1 #!/bin/bash
2 #
3 # usage:
4 #  after tests/tests/some-test has been run (and maybe failed)
5 #   cd tests/tmp/some-test/blah
6 #   ../../adhoc ../../../dgit some options
7 # or
8 #  after tests/tests/some-test has been run (and maybe failed)
9 #   cd tests/tmp/some-test/blah
10 #   ../../adhoc some rune run by some piece of infrastructure
11 #
12 # effects:
13 #   directly sets the env variables which arrange to use
14 #   programs etc. from the working tree
15
16 ourname=adhoc
17
18 case $0 in
19 */$ourname)
20         : ${DGIT_TEST_INTREE:=$(realpath "${0%/$ourname}/..")}
21         ;;
22 *)
23         echo >&2 "$ourname must be invoked as .../$ourname not $0"
24         exit 127
25         ;;
26 esac
27
28 export DGIT_TEST_INTREE
29
30 . $DGIT_TEST_INTREE/tests/lib-core
31
32 t-set-intree
33
34 pwd=$(realpath "$(pwd)")
35 basis=$DGIT_TEST_INTREE/tests/tmp
36 case "$pwd" in
37 "$basis" | "$basis"/*)
38         testname=${pwd/"$basis/"/}
39         testname=${testname%%/*}
40         tmp="$basis/$testname"
41         ;;
42 *)
43         fail "$ourname pwd must be inside some test (in $basis), not $pwd"
44         ;;
45 esac
46
47 export ADTTMP=$tmp
48
49 t-set-using-tmp
50
51 exec "$@"