diff tests/run-tests.py @ 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 8bce3e51b101
children d8c2db6167b3
line wrap: on
line diff
--- a/tests/run-tests.py	Wed Nov 01 17:08:33 2017 +0100
+++ b/tests/run-tests.py	Wed Aug 02 13:27:45 2017 +0900
@@ -2353,6 +2353,12 @@
 
         self._testdir = osenvironb[b'TESTDIR'] = getattr(
             os, 'getcwdb', os.getcwd)()
+        # assume all tests in same folder for now
+        if testdescs:
+            pathname = os.path.dirname(testdescs[0]['path'])
+            if pathname and not osenvironb[b'TESTDIR'].endswith('/'):
+                osenvironb[b'TESTDIR'] += '/'
+            osenvironb[b'TESTDIR'] += pathname
         if self.options.outputdir:
             self._outputdir = canonpath(_bytespath(self.options.outputdir))
         else: