run-tests: also follow symlink when update PATH with 'run-tests.py' dir
authorPierre-Yves David <pierre-yves.david@fb.com>
Sat, 11 Apr 2015 14:44:12 -0400
changeset 24742 39ee0444e27c
parent 24741 bb67e52362d6
child 24743 a2ef1dc3b59b
run-tests: also follow symlink when update PATH with 'run-tests.py' dir I'm using 'run-tests.py' from my '$PATH' and use a symlink to get 'run-tests.py' to in that '$PATH'. There is a handful of test helpers (like f) that needs to be in the '$PATH' for the test to run, and they are expected to live next to the 'run-tests.py' binary. Using a symlink confuses this logic, so we add to the '$PATH' both the 'run-tests.py' executable directory, and the actual file location direction.
tests/run-tests.py
--- a/tests/run-tests.py	Sat Apr 11 16:55:14 2015 -0400
+++ b/tests/run-tests.py	Sat Apr 11 14:44:12 2015 -0400
@@ -1693,6 +1693,11 @@
 
         runtestdir = os.path.abspath(os.path.dirname(__file__))
         path = [self._bindir, runtestdir] + os.environ["PATH"].split(os.pathsep)
+        if os.path.islink(__file__):
+            # test helper will likely be at the end of the symlink
+            realfile = os.path.realpath(__file__)
+            realdir = os.path.abspath(os.path.dirname(realfile))
+            path.insert(2, realdir)
         if self._tmpbindir != self._bindir:
             path = [self._tmpbindir] + path
         os.environ["PATH"] = os.pathsep.join(path)