Mercurial > hg-stable
changeset 25729:57dfadc4f46c
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.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 03 Jul 2015 06:56:03 +0900 |
parents | 905c32321cfb |
children | c380d5273e91 |
files | tests/run-tests.py tests/test-run-tests.t |
diffstat | 2 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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])
--- 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 <<EOF + > - $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.