Patchwork run-tests: try to provide a test.env file RFC

login
register
mail settings
Submitter timeless@mozdev.org
Date Dec. 22, 2015, 11:33 a.m.
Message ID <34293f86ef44d094aeca.1450784001@waste.org>
Download mbox | patch
Permalink /patch/12246/
State Changes Requested
Headers show

Comments

timeless@mozdev.org - Dec. 22, 2015, 11:33 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1450782416 0
#      Tue Dec 22 11:06:56 2015 +0000
# Node ID 34293f86ef44d094aeca7d933c67d0f8bca8106e
# Parent  3dea4eae4eebac11741f0c1dc5dcd9c88d8f4554
run-tests: try to provide a test.env file RFC

This is a step to providing an environment file that people can use
to reproduce a failing test environment.

--
The Windows side isn't tested.
Long term, it'd be helpful if this included code or instructions
to empty the environment too...
Pierre-Yves David - Jan. 17, 2016, 6:08 p.m.
On 12/22/2015 03:33 AM, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1450782416 0
> #      Tue Dec 22 11:06:56 2015 +0000
> # Node ID 34293f86ef44d094aeca7d933c67d0f8bca8106e
> # Parent  3dea4eae4eebac11741f0c1dc5dcd9c88d8f4554
> run-tests: try to provide a test.env file RFC
>
> This is a step to providing an environment file that people can use
> to reproduce a failing test environment.

The idea seems interresting.

> --
> The Windows side isn't tested.
> Long term, it'd be helpful if this included code or instructions
> to empty the environment too...

Can we get some documentation and basic testing for this?
I would like to make sure it does not silently broke and that people are 
able to find it.

We also probably want a .hgignore rules for it.

> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -685,6 +685,18 @@
>           if self._keeptmpdir:
>               log('\nKeeping testtmp dir: %s\nKeeping threadtmp dir: %s' %
>                   (self._testtmp, self._threadtmp))
> +            env = self._getenv()
> +            quote = re.compile('"')
> +            def format(k, v):
> +                return 'export %s="%s"\n' % (k, quote.sub('\\"', v))
> +            if os.name == 'nt':
> +                amp = re.compile('&')
> +                def format(k, v):
> +                    return 'set %s=%s\r\n' % (k, amp.sub('^&', v))
> +            f = open(os.path.join(self._threadtmp, 'test.env'), 'wb')
> +            for k, v in env.iteritems():
> +                f.write(format(k, v))
> +            f.close()
>           else:
>               shutil.rmtree(self._testtmp, True)
>               shutil.rmtree(self._threadtmp, True)
timeless - Jan. 17, 2016, 10:16 p.m.
Pierre-Yves David wrote:
> The idea seems interresting.

>> --
>> The Windows side isn't tested.
>> Long term, it'd be helpful if this included code or instructions
>> to empty the environment too...

> Can we get some documentation and basic testing for this?
> I would like to make sure it does not silently broke and that people are
> able to find it.
>
> We also probably want a .hgignore rules for it.

The file is generated into the test generated directory, so no
hgignore is needed.

But yes, I can work on some basic testing for this. I'll resend after
3.7 w/ a slightly more detailed version -- possibly also testing on
Windows...

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -685,6 +685,18 @@ 
         if self._keeptmpdir:
             log('\nKeeping testtmp dir: %s\nKeeping threadtmp dir: %s' %
                 (self._testtmp, self._threadtmp))
+            env = self._getenv()
+            quote = re.compile('"')
+            def format(k, v):
+                return 'export %s="%s"\n' % (k, quote.sub('\\"', v))
+            if os.name == 'nt':
+                amp = re.compile('&')
+                def format(k, v):
+                    return 'set %s=%s\r\n' % (k, amp.sub('^&', v))
+            f = open(os.path.join(self._threadtmp, 'test.env'), 'wb')
+            for k, v in env.iteritems():
+                f.write(format(k, v))
+            f.close()
         else:
             shutil.rmtree(self._testtmp, True)
             shutil.rmtree(self._threadtmp, True)