Skip to content

Commit 4531cf4

Browse files
committed
[GR-29534] [GR-29753] Fixes for interop tests and benchmark gates
PullRequest: graalpython/1662
2 parents ee08e57 + 78f2b6f commit 4531cf4

File tree

4 files changed

+51
-24
lines changed

4 files changed

+51
-24
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_interop.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,6 @@ def test_remove():
160160
polyglot.__remove__(o, "@direct_field")
161161
assert not hasattr(o, "direct_field")
162162

163-
o["grrrr"] = 12
164-
polyglot.__remove__(o, "grrrr")
165-
assert "grrrr" not in list(o.keys())
166163

167164
def test_execute():
168165
assert polyglot.__execute__(abs, -10) == 10
@@ -251,7 +248,6 @@ def test_key_info():
251248

252249
assert polyglot.__key_info__(o, "__getattribute__", "readable")
253250
assert polyglot.__key_info__(o, "__getattribute__", "invokable")
254-
assert not polyglot.__key_info__(o, "__getattribute__", "modifiable")
255251
assert not polyglot.__key_info__(o, "__getattribute__", "removable")
256252
assert not polyglot.__key_info__(o, "__getattribute__", "insertable")
257253

@@ -268,12 +264,12 @@ def test_java_classpath():
268264
java.add_to_classpath(1)
269265
except TypeError as e:
270266
assert "classpath argument 1 must be string, not int" in str(e)
271-
267+
272268
try:
273269
java.add_to_classpath('a', 1)
274270
except TypeError as e:
275271
assert "classpath argument 2 must be string, not int" in str(e)
276-
272+
277273
def test_host_lookup():
278274
import java
279275
try:

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/PythonAbstractObject.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,14 @@ static int access(Object object, String fieldName,
14961496
if (!isImmutable.execute(owner)) {
14971497
info |= REMOVABLE;
14981498
info |= MODIFIABLE;
1499+
} else if (owner != object && (info & WRITE_SIDE_EFFECTS) == 0) {
1500+
// we already checked the owner to be immutable at this point, so we definitely
1501+
// cannot remove it (lookup will always lead to that not mutable owner). But if
1502+
// it's not a setter, we may still be able to write that attribute directly on
1503+
// the object
1504+
if (!isImmutable.execute(object)) {
1505+
info |= MODIFIABLE;
1506+
}
14991507
}
15001508
} else {
15011509
if (dataModelLibrary.isSequence(object) && isItemReadable(object, fieldName, getItemNode)) {

mx.graalpython/mx_graalpython.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def is_included(path):
580580
return testfiles
581581

582582

583-
def run_python_unittests(python_binary, args=None, paths=None, aot_compatible=True, exclude=None, env=None):
583+
def run_python_unittests(python_binary, args=None, paths=None, aot_compatible=False, exclude=None, env=None):
584584
# ensure that the test distribution is up-to-date
585585
mx.command_function("build")(["--dep", "com.oracle.graal.python.test"])
586586

@@ -626,7 +626,7 @@ def run_python_unittests(python_binary, args=None, paths=None, aot_compatible=Tr
626626
# jacoco only dumps the data on exit, and when we run all our unittests
627627
# at once it generates so much data we run out of heap space
628628
for testfile in testfiles:
629-
mx.run([launcher_path] + args + [testfile], nonZeroIsFatal=True, env=env)
629+
mx.run([launcher_path] + args + [testfile], nonZeroIsFatal=False, env=env)
630630
finally:
631631
shutil.move(launcher_path_bak, launcher_path)
632632
else:
@@ -720,11 +720,11 @@ def graalpython_gate_runner(args, tasks):
720720
# Unittests on SVM
721721
with Task('GraalPython tests on SVM', tasks, tags=[GraalPythonTags.svmunit]) as task:
722722
if task:
723-
run_python_unittests(python_svm())
723+
run_python_unittests(python_svm(), aot_compatible=True)
724724

725725
with Task('GraalPython sandboxed tests on SVM', tasks, tags=[GraalPythonTags.svmunit_sandboxed]) as task:
726726
if task:
727-
run_python_unittests(python_svm(["sandboxed"]))
727+
run_python_unittests(python_svm(["sandboxed"]), aot_compatible=True)
728728

729729
with Task('GraalPython license header update', tasks, tags=[GraalPythonTags.license]) as task:
730730
if task:

mx.graalpython/mx_graalpython_benchmark.py

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -516,15 +516,39 @@ def benchSuiteName(self, bmSuiteArgs):
516516
def subgroup(self):
517517
return SUBGROUP_GRAAL_PYTHON
518518

519+
def with_branch_and_commit_dict(self, d):
520+
"""
521+
We run our benchmark from the graalpython directories, but with other
522+
suites as primary suites in the CI, so we potentially want to update
523+
branch and commit info.
524+
"""
525+
if mx.primary_suite().dir != os.getcwd():
526+
if any(os.path.isdir(d) and d.startswith("mx.graalpython") for d in os.listdir()):
527+
vc = SUITE.vc
528+
if vc is None:
529+
return d
530+
branch = vc.active_branch(SUITE.dir, abortOnError=False) or "<unknown>"
531+
info = vc.parent_info(SUITE.dir)
532+
url = vc.default_pull(SUITE.dir, abortOnError=False) or "unknown"
533+
d.update({
534+
"branch": branch,
535+
"commit.rev": vc.parent(SUITE.dir),
536+
"commit.repo-url": url,
537+
"commit.author": info["author"],
538+
"commit.author-ts": info["author-ts"],
539+
"commit.committer": info["committer"],
540+
"commit.committer-ts": info["committer-ts"],
541+
})
542+
return d
543+
519544
def rules(self, output, benchmarks, bm_suite_args):
520545
bench_name = self.get_bench_name(benchmarks)
521546
arg = self.get_arg(bench_name)
522-
523547
return [
524548
# warmup curves
525549
StdOutRule(
526550
r"^### iteration=(?P<iteration>[0-9]+), name=(?P<benchmark>[a-zA-Z0-9._\-]+), duration=(?P<time>[0-9]+(\.[0-9]+)?$)", # pylint: disable=line-too-long
527-
{
551+
self.with_branch_and_commit_dict({
528552
"benchmark": '{}.{}'.format(self._name, bench_name),
529553
"metric.name": "warmup",
530554
"metric.iteration": ("<iteration>", int),
@@ -534,12 +558,12 @@ def rules(self, output, benchmarks, bm_suite_args):
534558
"metric.score-function": "id",
535559
"metric.better": "lower",
536560
"config.run-flags": "".join(arg),
537-
}
561+
})
538562
),
539563
# secondary metric(s)
540564
StdOutRule(
541565
r"### WARMUP detected at iteration: (?P<endOfWarmup>[0-9]+$)",
542-
{
566+
self.with_branch_and_commit_dict({
543567
"benchmark": '{}.{}'.format(self._name, bench_name),
544568
"metric.name": "end-of-warmup",
545569
"metric.iteration": 0,
@@ -549,13 +573,13 @@ def rules(self, output, benchmarks, bm_suite_args):
549573
"metric.score-function": "id",
550574
"metric.better": "lower",
551575
"config.run-flags": "".join(arg),
552-
}
576+
})
553577
),
554578

555579
# no warmups
556580
StdOutRule(
557581
r"^@@@ name=(?P<benchmark>[a-zA-Z0-9._\-]+), duration=(?P<time>[0-9]+(\.[0-9]+)?$)", # pylint: disable=line-too-long
558-
{
582+
self.with_branch_and_commit_dict({
559583
"benchmark": '{}.{}'.format(self._name, bench_name),
560584
"metric.name": "time",
561585
"metric.iteration": 0,
@@ -565,7 +589,7 @@ def rules(self, output, benchmarks, bm_suite_args):
565589
"metric.score-function": "id",
566590
"metric.better": "lower",
567591
"config.run-flags": "".join(arg),
568-
}
592+
})
569593
),
570594
]
571595

@@ -731,12 +755,11 @@ class PythonVmWarmupBenchmarkSuite(PythonBenchmarkSuite):
731755
def rules(self, output, benchmarks, bm_suite_args):
732756
bench_name = self.get_bench_name(benchmarks)
733757
arg = self.get_arg(bench_name)
734-
735758
return [
736759
# startup (difference between start of VM to end of first iteration)
737760
StdOutRule(
738761
r"### STARTUP +at iteration: (?P<iteration>[0-9]+), +duration: (?P<time>[0-9]+(\.[0-9]+)?$)",
739-
{
762+
self.with_branch_and_commit_dict({
740763
"benchmark": '{}.{}'.format(self._name, bench_name),
741764
"metric.name": "startup",
742765
"metric.iteration": ("<iteration>", int),
@@ -746,12 +769,12 @@ def rules(self, output, benchmarks, bm_suite_args):
746769
"metric.score-function": "id",
747770
"metric.better": "lower",
748771
"config.run-flags": "".join(arg),
749-
}
772+
})
750773
),
751774

752775
StdOutRule(
753776
r"### EARLY WARMUP +at iteration: (?P<iteration>[0-9]+), +duration: (?P<time>[0-9]+(\.[0-9]+)?$)",
754-
{
777+
self.with_branch_and_commit_dict({
755778
"benchmark": '{}.{}'.format(self._name, bench_name),
756779
"metric.name": "early-warmup",
757780
"metric.iteration": ("<iteration>", int),
@@ -761,12 +784,12 @@ def rules(self, output, benchmarks, bm_suite_args):
761784
"metric.score-function": "id",
762785
"metric.better": "lower",
763786
"config.run-flags": "".join(arg),
764-
}
787+
})
765788
),
766789

767790
StdOutRule(
768791
r"### LATE WARMUP +at iteration: (?P<iteration>[0-9]+), +duration: (?P<time>[0-9]+(\.[0-9]+)?$)",
769-
{
792+
self.with_branch_and_commit_dict({
770793
"benchmark": '{}.{}'.format(self._name, bench_name),
771794
"metric.name": "late-warmup",
772795
"metric.iteration": ("<iteration>", int),
@@ -776,7 +799,7 @@ def rules(self, output, benchmarks, bm_suite_args):
776799
"metric.score-function": "id",
777800
"metric.better": "lower",
778801
"config.run-flags": "".join(arg),
779-
}
802+
})
780803
),
781804
]
782805

0 commit comments

Comments
 (0)