Patchwork [075,of,179,tests-refactor] run-tests: move hash seed logic to TestRunner

login
register
mail settings
Submitter Gregory Szorc
Date May 2, 2014, 6:38 p.m.
Message ID <335f0364ed5aee334971.1399055912@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4569/
State Accepted
Commit 97475f27bebeb30fedff437a6b7af716f3b8a598
Headers show

Comments

Gregory Szorc - May 2, 2014, 6:38 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1398013141 25200
#      Sun Apr 20 09:59:01 2014 -0700
# Branch stable
# Node ID 335f0364ed5aee334971d46f7fa95c4ece17b732
# Parent  294b4e4d280cdedb9a01b4887272d39fe0c848f4
run-tests: move hash seed logic to TestRunner

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1019,16 +1019,21 @@  class TestRunner(object):
         oldenv = dict(os.environ)
         try:
             return self._run(tests)
         finally:
             os.environ.clear()
             os.environ.update(oldenv)
 
     def _run(self, tests):
+        if 'PYTHONHASHSEED' not in os.environ:
+            # use a random python hash seed all the time
+            # we do the randomness ourself to know what seed is used
+            os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32))
+
         if self.options.tmpdir:
             self.options.keep_tmpdir = True
             tmpdir = self.options.tmpdir
             if os.path.exists(tmpdir):
                 # Meaning of tmpdir has changed since 1.3: we used to create
                 # HGTMP inside tmpdir; now HGTMP is tmpdir.  So fail if
                 # tmpdir already exists.
                 print "error: temp dir %r already exists" % tmpdir
@@ -1456,19 +1461,14 @@  def main(args, runner=None, parser=None)
                     raise
                 return -1e9 # file does not exist, tell early
             for kw in slow:
                 if kw in f:
                     val *= 10
             return val
         tests.sort(key=sortkey)
 
-    if 'PYTHONHASHSEED' not in os.environ:
-        # use a random python hash seed all the time
-        # we do the randomness ourself to know what seed is used
-        os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32))
-
     runner.testdir = os.environ['TESTDIR'] = os.getcwd()
 
     return runner.run(tests)
 
 if __name__ == '__main__':
     sys.exit(main(sys.argv[1:]))