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

login
register
mail settings
Submitter Pierre-Yves David
Date April 3, 2017, 1:03 p.m.
Message ID <e219af4bf3d4f6b7b3b6.1491224637@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/19931/
State Changes Requested
Headers show

Comments

Pierre-Yves David - April 3, 2017, 1:03 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.
Augie Fackler - April 3, 2017, 8:41 p.m.
On Mon, Apr 03, 2017 at 03:03:57PM +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@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@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Pierre-Yves David - April 4, 2017, 9:01 a.m.
On 04/03/2017 10:41 PM, Augie Fackler wrote:
> On Mon, Apr 03, 2017 at 03:03:57PM +0200, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@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.

Good idea, V2, coming.

Patch

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'
         env['TESTTMP'] = self._testtmp
         env['HOME'] = self._testtmp
         # This number should match portneeded in _getport