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

timeless timeless at mozdev.org
Thu Mar 24 16:16:27 EDT 2016


# HG changeset patch
# User timeless <timeless at 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...

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 at 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


More information about the Mercurial-devel mailing list