Skip to content

Commit 8a38175

Browse files
committed
keep a heap dump when the leak test fails
1 parent 8333bee commit 8a38175

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,8 +1991,10 @@ def import_files(from_dir, to_dir):
19911991
SUITE.vc.git_command(SUITE.dir, ["merge", HPY_IMPORT_ORPHAN_BRANCH_NAME])
19921992

19931993

1994-
def run_leak_launcher(args):
1995-
print("Leak test: " + " ".join(args))
1994+
def run_leak_launcher(input_args, out=None):
1995+
print("mx python-leak-test " + " ".join(input_args))
1996+
1997+
args = input_args
19961998
capi_home = _get_capi_home()
19971999
args.insert(0, "--experimental-options")
19982000
args.insert(0, "--python.CAPI=%s" % capi_home)
@@ -2006,10 +2008,24 @@ def run_leak_launcher(args):
20062008
vm_args += mx.get_runtime_jvm_args(dists)
20072009
jdk = mx.get_jdk(tag=None)
20082010
vm_args.append("com.oracle.graal.python.test.advance.LeakTest")
2009-
retval = mx.run_java(vm_args + graalpython_args, jdk=jdk, env=env, nonZeroIsFatal=False)
2011+
retval = mx.run_java(vm_args + graalpython_args, jdk=jdk, env=env, nonZeroIsFatal=False, out=out)
20102012
if retval == 0:
20112013
print("PASSED")
20122014
return True
2015+
elif os.environ.get("CI") and "--keep-dump" not in input_args:
2016+
# rerun once with heap dumping enabled
2017+
out = mx.OutputCapture()
2018+
run_leak_launcher(["--keep-dump"] + input_args, out=out)
2019+
path = out.data.strip().split("Dump file:")[2].strip()
2020+
if path:
2021+
save_path = os.path.join(SUITE.dir, "dumps", "leak_test")
2022+
try:
2023+
os.makedirs(save_path)
2024+
except OSError:
2025+
pass
2026+
dest = shutil.copy(path, save_path)
2027+
print("Heapdump file kept in " + dest)
2028+
return False
20132029
else:
20142030
print("FAILED")
20152031
return False

0 commit comments

Comments
 (0)