[PATCH 1 of 3] test-runner: set an environment variable to informs test are running

Augie Fackler raf at durin42.com
Mon Apr 3 16:41:55 EDT 2017


On Mon, Apr 03, 2017 at 03:03:57PM +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> # Date 1491222747 -7200
> #      Mon Apr 03 14:32:27 2017 +0200
> # Node ID e219af4bf3d4f6b7b3b634db1f7af8eaa524c4c1
> # Parent  2632df096fc0ac7582382b1f94ea4b9ad0bce8f2
> # EXP-Topic vfs.cleanup
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r e219af4bf3d4
> test-runner: set an environment variable to informs test are running
>
> This will be use to detect test condition in a coming changeset.
>
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -877,6 +877,7 @@ class Test(unittest.TestCase):
>          env = os.environ.copy()
>          if sysconfig is not None:
>              env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase')
> +        env['HGTESTRUNNING'] = '1'

I'm...not happy about this approach. It feels like a layering violation for
hg to be explicitly collaborating with Mercurial in this way.

I think I'd be comfortable with it if it was something more like
'HGEMITWARNINGS', so that it's not explicitly "you're running inside
tests", so that people don't get tempted to do special things in "test
only" code.

>          env['TESTTMP'] = self._testtmp
>          env['HOME'] = self._testtmp
>          # This number should match portneeded in _getport
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list