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

login
register
mail settings
Submitter timeless@mozdev.org
Date March 24, 2016, 8:16 p.m.
Message ID <1187c2c232ee7f23711d.1458850587@waste.org>
Download mbox | patch
Permalink /patch/14060/
State Superseded
Headers show

Comments

timeless@mozdev.org - March 24, 2016, 8:16 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1450782416 0
#      Tue Dec 22 11:06:56 2015 +0000
# Node ID 1187c2c232ee7f23711dc3c0857ea2e1cc92a42d
# Parent  1a1e4350b560cf2f49fe235d2e5168471877462d
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...
Yuya Nishihara - March 29, 2016, 2:05 p.m.
On Thu, 24 Mar 2016 15:16:27 -0500, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1450782416 0
> #      Tue Dec 22 11:06:56 2015 +0000
> # Node ID 1187c2c232ee7f23711dc3c0857ea2e1cc92a42d
> # Parent  1a1e4350b560cf2f49fe235d2e5168471877462d
> 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.

I think this is good direction. A couple of nits follow.

> Long term, it'd be helpful if this included code or instructions
> to empty the environment too...

(+CC Piotr Listkiewicz as he seems to work on test environment)

> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -730,6 +730,16 @@
>              log('\nKeeping testtmp dir: %s\nKeeping threadtmp dir: %s' %
>                  (self._testtmp.decode('utf-8'),
>                   self._threadtmp.decode('utf-8')))
> +            env = self._getenv()
> +            def format(k, v):
> +                return 'export %s="%s"\n' % (k, v.replace('"', r'\"'))

"export X=Y" is bashism.

> +            if os.name == 'nt':
> +                def format(k, v):
> +                    return 'set %s=%s\r\n' % (k, v.replace('&', '^&'))

Perhaps we won't need Windows batch file since most of us will use MSYS bash
or zsh to run tests 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
@@ -730,6 +730,16 @@ 
             log('\nKeeping testtmp dir: %s\nKeeping threadtmp dir: %s' %
                 (self._testtmp.decode('utf-8'),
                  self._threadtmp.decode('utf-8')))
+            env = self._getenv()
+            def format(k, v):
+                return 'export %s="%s"\n' % (k, v.replace('"', r'\"'))
+            if os.name == 'nt':
+                def format(k, v):
+                    return 'set %s=%s\r\n' % (k, v.replace('&', '^&'))
+            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)
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -465,6 +465,18 @@ 
   .
   # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
 
+  $ egrep 'HGEDITOR|HGPORT|PYTHONHASHSEED|PYTHON|HGPORT|DAEMON_PIDS|EMAIL' \
+  > keep/child1/test.env | sort
+  export DAEMON_PIDS="$TESTTMP/keep/child1/daemon.pids" (glob)
+  export EMAIL="Foo Bar <foo.bar@example.com>"
+  export HGEDITOR="* -c \"import sys; sys.exit(0)\"" (glob)
+  export HGPORT1="*" (glob)
+  export HGPORT2="*" (glob)
+  export HGPORT="*" (glob)
+  export PYTHON="*" (glob)
+  export PYTHONHASHSEED="*" (glob)
+  export PYTHONPATH="*:$TESTTMP:*" (glob)
+
 timeouts
 ========
   $ cat > test-timeout.t <<EOF