chiark / gitweb /
Tests: New tests/adhoc helper; document tests/using-intree too
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 3 May 2015 11:02:42 +0000 (12:02 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 31 May 2015 10:54:10 +0000 (11:54 +0100)
tests/adhoc [new file with mode: 0755]
tests/using-intree

diff --git a/tests/adhoc b/tests/adhoc
new file mode 100755 (executable)
index 0000000..f252602
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# usage:
+#  after tests/tests/some-test has been run (and maybe failed)
+#   cd tests/tmp/some-test/blah
+#   ../../adhoc ../../../dgit some options
+# or
+#  after tests/tests/some-test has been run (and maybe failed)
+#   cd tests/tmp/some-test/blah
+#   ../../adhoc some rune run by some piece of infrastructure
+#
+# effects:
+#   directly sets the env variables which arrange to use
+#   progrmas etc. from the working tree
+
+ourname=adhoc
+
+case $0 in
+*/$ourname)
+       : ${DGIT_TEST_INTREE:=$(realpath "${0%/$ourname}/..")}
+       ;;
+*)
+       echo >&2 "$ourname must be invoked as .../$ourname not $0"
+       exit 127
+       ;;
+esac
+
+export DGIT_TEST_INTREE
+
+. $DGIT_TEST_INTREE/tests/lib-core
+
+t-set-intree
+
+pwd=$(realpath "$(pwd)")
+basis=$DGIT_TEST_INTREE/tests/tmp
+case "$pwd" in
+"$basis" | "$basis"/*)
+       testname=${pwd/"$basis/"/}
+       testname=${testname%%/*}
+       tmp="$basis/$testname"
+       ;;
+*)
+       fail "$ourname pwd must be inside some test (in $basis), not $pwd"
+       ;;
+esac
+
+export ADTTMP=$tmp HOME=$tmp DGIT_TEST_DUMMY_DIR=$tmp DGIT_TEST_TMP=$tmp
+
+exec "$@"
index b907252..0235c20 100755 (executable)
@@ -1,4 +1,16 @@
 #!/bin/bash
+#
+# usage:
+#   cd .../dgit.git
+#   tests/using-intree tests/test/some-test
+# or
+#   cd .../dgit.git
+#   tests/using-intree tests/run-all
+#
+# effects:
+#   sets DGIT_TEST_INTREE which causes tests/lib to have test scripts
+#   using programs etc. from the working tree
+
 set -e
 pwd=`pwd`
 export DGIT_TEST_INTREE="$pwd"