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.
--- 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)