Skip to content

Commit c96b673

Browse files
committed
Set PYTHONHASHSEED=0 when running our unittests to ensure deterministic hash behavior
1 parent 02af354 commit c96b673

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,12 @@ def graalpytest(args):
521521
cmd_args += testfiles
522522
if args.filter:
523523
cmd_args += ["-k", args.filter]
524+
env = os.environ.copy()
525+
env['PYTHONHASHSEED'] = '0'
524526
if args.python:
525-
return mx.run([args.python] + cmd_args, nonZeroIsFatal=True)
527+
return mx.run([args.python] + cmd_args, nonZeroIsFatal=True, env=env)
526528
else:
527-
return do_run_python(cmd_args)
529+
return do_run_python(cmd_args, env=env)
528530

529531

530532
def _list_graalpython_unittests(paths=None, exclude=None):
@@ -563,6 +565,7 @@ def run_python_unittests(python_binary, args=None, paths=None, aot_compatible=Tr
563565
exclude = exclude or []
564566
if env is None:
565567
env = os.environ.copy()
568+
env['PYTHONHASHSEED'] = '0'
566569

567570
# list of excluded tests
568571
if aot_compatible:
@@ -644,8 +647,10 @@ def graalpython_gate_runner(args, tasks):
644647
exe = os.path.join(exe, "python")
645648
else:
646649
exe = "python3"
650+
env = os.environ.copy()
651+
env['PYTHONHASHSEED'] = '0'
647652
test_args = [exe, _graalpytest_driver(), "-v", _graalpytest_root()]
648-
mx.run(test_args, nonZeroIsFatal=True)
653+
mx.run(test_args, nonZeroIsFatal=True, env=env)
649654
mx.run(["env"])
650655
run_python_unittests(python_gvm())
651656

0 commit comments

Comments
 (0)