# HG changeset patch # User FUJIWARA Katsunori # Date 1435874163 -32400 # Node ID 57dfadc4f46c404b58bc452ef6ed3f74104c10cf # Parent 905c32321cfb48a3a90036eef091ee37b3c63bca run-tests.py: add RUNTESTDIR to refer `tests` of Mercurial Before this patch, there is no way to refer files under `tests` or so of Mercurial source tree, when `run-tests.py` runs in `tests` of third party tools. In this case, `TESTDIR` refers the latter `tests`. This prevents third party tools from using useful tools in Mercurial source tree (e.g. `contrib/check-code.py`). This patch adds `RUNTESTDIR` environment variable to refer `tests` of Mercurial source tree, in which `run-tests.py` now running is placed. For example, tests of third party tools can refer `contrib/check-code.py` in Mercurial source tree as `$RUNTESTDIR/../contrib/check-code.py`. BTW, for similarity with `TESTDIR` referring `test*s*` directory, newly added environment variable isn't named as `RUNTEST*S*DIR`. In addition to it, the corresponded local variable is also named as `runtestdir`. This is a one of preparations for issue4677. diff -r 905c32321cfb -r 57dfadc4f46c tests/run-tests.py --- a/tests/run-tests.py Fri Jul 03 06:56:03 2015 +0900 +++ b/tests/run-tests.py Fri Jul 03 06:56:03 2015 +0900 @@ -1801,6 +1801,7 @@ fileb = _bytespath(__file__) runtestdir = os.path.abspath(os.path.dirname(fileb)) + osenvironb[b'RUNTESTDIR'] = runtestdir if PYTHON3: sepb = _bytespath(os.pathsep) else: @@ -1835,6 +1836,7 @@ self._coveragefile = os.path.join(self._testdir, b'.coverage') vlog("# Using TESTDIR", self._testdir) + vlog("# Using RUNTESTDIR", osenvironb[b'RUNTESTDIR']) vlog("# Using HGTMP", self._hgtmp) vlog("# Using PATH", os.environ["PATH"]) vlog("# Using", IMPL_PATH, osenvironb[IMPL_PATH]) diff -r 905c32321cfb -r 57dfadc4f46c tests/test-run-tests.t --- a/tests/test-run-tests.t Fri Jul 03 06:56:03 2015 +0900 +++ b/tests/test-run-tests.t Fri Jul 03 06:56:03 2015 +0900 @@ -583,3 +583,22 @@ $ run-tests.py test-hghave.t . # Ran 1 tests, 0 skipped, 0 warned, 0 failed. + +test that RUNTESTDIR refers the directory, in which `run-tests.py` now +running is placed. + + $ cat > test-runtestdir.t < - $TESTDIR, in which test-run-tests.t is placed + > - \$TESTDIR, in which test-runtestdir.t is placed (expanded at runtime) + > - \$RUNTESTDIR, in which run-tests.py is placed (expanded at runtime) + > + > $ test "\$TESTDIR" = "$TESTTMP"/anothertests + > $ test "\$RUNTESTDIR" = "$TESTDIR" + > $ head -n 3 "\$RUNTESTDIR"/../contrib/check-code.py + > #!/usr/bin/env python + > # + > # check-code - a style and portability checker for Mercurial + > EOF + $ run-tests.py test-runtestdir.t + . + # Ran 1 tests, 0 skipped, 0 warned, 0 failed.