Patchwork [RESEND] test: display used python hash seed

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 9, 2013, 10:09 p.m.
Message ID <27f60febcba4f36ec23d.1360447749@serpens.logilab.fr>
Download mbox | patch
Permalink /patch/913/
State Accepted
Commit 35b4affe6fdd7198f524f3393cd1b967ab85caee
Headers show

Comments

Pierre-Yves David - Feb. 9, 2013, 10:09 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1359505444 -3600
# Node ID 27f60febcba4f36ec23d8e6cc67be54f176eea33
# Parent  0b6e6eacc939c303136cb38af108e307d640c26e
test: display used python hash seed

We keep using a random seed for each run, but we "compute" it ourself to be able
to reproduce a failed test run.
Bryan O'Sullivan - Feb. 9, 2013, 10:21 p.m.
On Sat, Feb 9, 2013 at 2:09 PM, <pierre-yves.david@ens-lyon.org> wrote:

> test: display used python hash seed
>

Pushed to crew, thanks.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -50,10 +50,11 @@  import shutil
 import subprocess
 import signal
 import sys
 import tempfile
 import time
+import random
 import re
 import threading
 import killdaemons as killmod
 import cPickle as pickle
 import Queue as queue
@@ -1251,11 +1252,15 @@  def main():
     os.environ['GREP_OPTIONS'] = ''
     os.environ['http_proxy'] = ''
     os.environ['no_proxy'] = ''
     os.environ['NO_PROXY'] = ''
     os.environ['TERM'] = 'xterm'
-    os.environ['PYTHONHASHSEED'] = os.environ.get('PYTHONHASHSEED', 'random')
+    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))
+        print 'python hash seed:', os.environ['PYTHONHASHSEED']
 
     # unset env related to hooks
     for k in os.environ.keys():
         if k.startswith('HG_'):
             # can't remove on solaris