[PATCH] run-tests: $TESTDIR can be something else than $PWD
Yuya Nishihara
yuya at tcha.org
Thu Nov 2 22:09:42 EDT 2017
On Thu, 02 Nov 2017 22:37:45 +0900, matthieu.laneuville at octobus.net wrote:
> # HG changeset patch
> # User Matthieu Laneuville <matthieu.laneuville at octobus.net>
> # Date 1501648065 -32400
> # Wed Aug 02 13:27:45 2017 +0900
> # Node ID c4cc170d65e2dbcb075d09c26f5884aa8c0ceb31
> # Parent 3ce0e4b51f789eff195ec900a07c1fa5e8d5c5f2
> # EXP-Topic hg122
> 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.
>
> diff -r 3ce0e4b51f78 -r c4cc170d65e2 tests/run-tests.py
> --- a/tests/run-tests.py Wed Nov 01 17:19:45 2017 -0500
> +++ b/tests/run-tests.py Wed Aug 02 13:27:45 2017 +0900
> @@ -2353,6 +2353,12 @@ class TestRunner(object):
>
> 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'] += '/'
Not work on Python 3 because of u'/' vs b'/' issue. Can you send a follow up?
More information about the Mercurial-devel
mailing list