Skip to content

Commit c8260e3

Browse files
committed
Build svm images for our CI tests with assertions enabled
1 parent f626c72 commit c8260e3

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,17 @@
9797

9898
_COLLECTING_COVERAGE = False
9999

100-
def is_collectiong_coverage():
101-
return bool(mx_gate.get_jacoco_agent_args() or _COLLECTING_COVERAGE)
102-
100+
CI = os.environ.get("CI") == "true"
101+
BUILD_NATIVE_IMAGE_WITH_ASSERTIONS = CI and sys.platform != "win32" # disable assertions on win32 until we properly support that platform
103102

104-
if os.environ.get("CI") == "true" and not os.environ.get("GRAALPYTEST_FAIL_FAST"):
103+
if CI and not os.environ.get("GRAALPYTEST_FAIL_FAST"):
105104
os.environ["GRAALPYTEST_FAIL_FAST"] = "true"
106105

107106

107+
def is_collecting_coverage():
108+
return bool(mx_gate.get_jacoco_agent_args() or _COLLECTING_COVERAGE)
109+
110+
108111
def wants_debug_build(flags=os.environ.get("CFLAGS", "")):
109112
return any(x in flags for x in ["-g", "-ggdb", "-ggdb3"])
110113

@@ -252,7 +255,7 @@ def do_run_python(args, extra_vm_args=None, env=None, jdk=None, extra_dists=None
252255
if extra_dists:
253256
dists += extra_dists
254257

255-
if not os.environ.get("CI"):
258+
if not CI:
256259
# Try eagerly to include tools for convenience when running Python
257260
if not mx.suite("tools", fatalIfMissing=False):
258261
SUITE.import_suite("tools", version=None, urlinfos=None, in_subdir=True)
@@ -697,6 +700,9 @@ def _graalvm_home(*, envfile, extra_dy=""):
697700
mx_args = ["--dy", dy] + mx_args
698701
if mx._opts.verbose:
699702
mx.run_mx(mx_args + ["graalvm-show"])
703+
if BUILD_NATIVE_IMAGE_WITH_ASSERTIONS:
704+
mx_args.append("--extra-image-builder-argument=-ea")
705+
mx_args.append("--extra-image-builder-argument=--verbose")
700706
mx.run_mx(mx_args + ["build"])
701707
out = mx.OutputCapture()
702708
mx.run_mx(mx_args + ["graalvm-home"], out=out)
@@ -722,7 +728,7 @@ def python_gvm(_=None):
722728

723729
if mx_gate.get_jacoco_agent_args():
724730
# patch our launchers created under jacoco to also run with jacoco.
725-
# do not use is_collectiong_coverage() here, we only want to patch when
731+
# do not use is_collecting_coverage() here, we only want to patch when
726732
# jacoco agent is requested.
727733
def graalvm_vm_arg(java_arg):
728734
if java_arg.startswith("@") and os.path.exists(java_arg[1:]):
@@ -918,7 +924,7 @@ def run_python_unittests(python_binary, args=None, paths=None, aot_compatible=Fa
918924
args += ["--report", reportfile]
919925

920926
result = 0
921-
if is_collectiong_coverage():
927+
if is_collecting_coverage():
922928
env['ENABLE_THREADED_GRAALPYTEST'] = "false"
923929
if mx_gate.get_jacoco_agent_args():
924930
with open(python_binary, "r") as f:
@@ -1021,7 +1027,7 @@ def run_hpy_unittests(python_binary, args=None, include_native=True, env=None, n
10211027
nonZeroIsFatal=nonZeroIsFatal, env=env, timeout=timeout)
10221028
mx.run([python_binary] + args + ["-m", "pip", "install", "--user", "pytest<=6.2.3", "pytest-xdist", "filelock"],
10231029
nonZeroIsFatal=nonZeroIsFatal, env=env, timeout=timeout)
1024-
if not is_collectiong_coverage():
1030+
if not is_collecting_coverage():
10251031
# parallelize
10261032
import threading
10271033
threads = []
@@ -1115,8 +1121,8 @@ def run_tagged_unittests(python_binary, env=None, cwd=None, javaAsserts=False, n
11151121

11161122

11171123
def graalpython_gate_runner(args, tasks):
1118-
report = lambda: (not is_collectiong_coverage()) and task
1119-
nonZeroIsFatal = not is_collectiong_coverage()
1124+
report = lambda: (not is_collecting_coverage()) and task
1125+
nonZeroIsFatal = not is_collecting_coverage()
11201126

11211127
# JUnit tests
11221128
with Task('GraalPython JUnit', tasks, tags=[GraalPythonTags.junit]) as task:
@@ -1173,7 +1179,7 @@ def graalpython_gate_runner(args, tasks):
11731179
with Task('GraalPython Python tests', tasks, tags=[GraalPythonTags.tagged]) as task:
11741180
if task:
11751181
# don't fail this task if we're running with the jacoco agent, we know that some tests don't pass with it enabled
1176-
run_tagged_unittests(python_svm(), nonZeroIsFatal=(not is_collectiong_coverage()), report=report())
1182+
run_tagged_unittests(python_svm(), nonZeroIsFatal=(not is_collecting_coverage()), report=report())
11771183

11781184
with Task('GraalPython sandboxed Python tests', tasks, tags=[GraalPythonTags.tagged_sandboxed]) as task:
11791185
if task:

0 commit comments

Comments
 (0)