Skip to content

Commit 7b0f7e5

Browse files
committed
include more tests by being more clever about excluding failed test patterns
1 parent 7e962a8 commit 7b0f7e5

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def fun():
100100

101101
executable = sys.executable.split(" ") # HACK: our sys.executable on Java is a cmdline
102102
re_success = re.compile("(test\S+) \(([^\s]+)\) \.\.\. ok$", re.MULTILINE)
103+
re_failure = re.compile("(test\S+) \(([^\s]+)\) \.\.\. (?:ERROR|FAIL)$", re.MULTILINE)
103104
kwargs = {"stdout": subprocess.PIPE, "stderr": subprocess.PIPE, "text": True, "check": False}
104105

105106
glob_pattern = os.path.join(os.path.dirname(test.__file__), "test_*.py")
@@ -169,6 +170,7 @@ def fun():
169170
# we failed the first run, create a tag file with the passing
170171
# tests (if any)
171172
passing_tests = []
173+
failed_tests = []
172174

173175
try:
174176
imported_test_module = __import__(testmod)
@@ -191,13 +193,24 @@ def get_pass_name(funcname, classname):
191193

192194
# n.b.: we add a '*' in the front, so that unittests doesn't add
193195
# its own asterisks, because now this is already a pattern
196+
197+
for funcname,classname in re_failure.findall(p.stdout):
198+
failed_tests.append("*" + get_pass_name(funcname, classname))
199+
for funcname,classname in re_failure.findall(p.stderr):
200+
failed_tests.append("*" + get_pass_name(funcname, classname))
201+
194202
for funcname,classname in re_success.findall(p.stdout):
195203
passing_tests.append("*" + get_pass_name(funcname, classname))
196204
for funcname,classname in re_success.findall(p.stderr):
197205
passing_tests.append("*" + get_pass_name(funcname, classname))
198206

207+
# n.b.: unittests uses the __qualname__ of the function as
208+
# pattern, which we're trying to do as well. however, sometimes
209+
# the same function is shared in multiple test classes, and
210+
# fails in some. so we always subtract the failed patterns from
211+
# the passed patterns
199212
with open(tagfile, "w") as f:
200-
for passing_test in passing_tests:
213+
for passing_test in set(passing_tests) - set(failed_tests):
201214
f.write(passing_test)
202215
f.write("\n")
203216
if not passing_tests:

0 commit comments

Comments
 (0)