diff tests/test-run-tests.t @ 34962:a18eef03d879

run-tests: $TESTDIR can be something else than $PWD $TESTDIR is expected to be the directory were the test lives, and is often used to reference helper functions. However, it is now set to $PWD at test invocation time, so if `run-tests.py` is called from another folder, the test will fail. The solution is to force $TESTDIR to be the base directory of the test itself, irrespective of where the runner is called from.
author Matthieu Laneuville <matthieu.laneuville@octobus.net>
date Wed, 02 Aug 2017 13:27:45 +0900
parents b63a7d839c33
children d600bda4a3e1
line wrap: on
line diff
--- a/tests/test-run-tests.t	Wed Nov 01 17:08:33 2017 +0100
+++ b/tests/test-run-tests.t	Wed Aug 02 13:27:45 2017 +0900
@@ -1261,6 +1261,22 @@
   .
   # Ran 1 tests, 0 skipped, 0 failed.
 
+support for running run-tests.py from another directory
+  $ mkdir tmp && cd tmp
+  $ cat > useful-file.sh << EOF
+  > important command
+  > EOF
+
+  $ cat > test-folder.t << EOF
+  >   $ cat \$TESTDIR/useful-file.sh
+  >   important command
+  > EOF
+
+  $ cd ..
+  $ $PYTHON $TESTDIR/run-tests.py tmp/test-folder.t
+  .
+  # Ran 1 tests, 0 skipped, 0 failed.
+
 support for bisecting failed tests automatically
   $ hg init bisect
   $ cd bisect