Skip to content

Commit 9a8ba1f

Browse files
committed
unittest_runner: do not count reruns of the same test with different params
1 parent 0de4e96 commit 9a8ba1f

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

graalpython/com.oracle.graal.python.test/src/python_unittests.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@
7676
PTRN_IMPORT_ERROR = re.compile(r".*cannot import name \'(?P<module>.*)\'.*", re.DOTALL)
7777
PTRN_REMOTE_HOST = re.compile(r"(?P<user>\w+)@(?P<host>[\w.]+):(?P<path>.+)")
7878
PTRN_VALID_CSV_NAME = re.compile(r"unittests-\d{4}-\d{2}-\d{2}.csv")
79-
PTRN_TEST_STATUS_INDIVIDUAL = re.compile(r"(?P<name>test_[\w_]+ \(.+\)) ... (?P<status>.+)")
80-
PTRN_TEST_STATUS_ERROR = re.compile(r"(?P<status>.+): (?P<name>test_[\w_]+ \(.+\))")
79+
PTRN_TEST_STATUS_INDIVIDUAL = re.compile(r"(?P<name>test[\w_]+ \(.+?\)) ... (?P<status>.+)")
80+
PTRN_TEST_STATUS_ERROR = re.compile(r"(?P<status>.+): (?P<name>test[\w_]+ \(.+?\))")
8181

8282

8383
# ----------------------------------------------------------------------------------------------------------------------
@@ -240,11 +240,14 @@ def __init__(self):
240240
# tracked stats
241241
self._tracked = False
242242

243-
def all_ok(self):
243+
def _reset(self):
244244
self._num_fails = 0
245245
self._num_errors = 0
246246
self._num_skipped = 0
247247

248+
def all_ok(self):
249+
self._reset()
250+
248251
@property
249252
def num_errors(self):
250253
return self._num_errors
@@ -270,7 +273,7 @@ def num_skipped(self):
270273
@num_skipped.setter
271274
def num_skipped(self, value):
272275
if not self._tracked:
273-
self._num_fails = value
276+
self._num_skipped = value
274277

275278
@property
276279
def num_passes(self):
@@ -279,25 +282,28 @@ def num_passes(self):
279282
return -1
280283

281284
def update(self, test_detailed_stats):
282-
for test, stats in test_detailed_stats.items():
285+
if len(test_detailed_stats) > 0:
283286
self._tracked = True
284-
stats = {s.lower() for s in stats}
285-
if TestStatus.ERROR in stats:
286-
self._num_errors = 1 if self._num_errors == -1 else self._num_errors + 1
287-
elif TestStatus.FAIL in stats:
288-
self._num_fails = 1 if self._num_fails == -1 else self._num_fails + 1
289-
else:
290-
for s in stats:
291-
if s.startswith(TestStatus.SKIPPED):
292-
self._num_skipped = 1 if self._num_skipped == -1 else self._num_skipped + 1
293-
break
287+
self._reset()
288+
for test, stats in test_detailed_stats.items():
289+
stats = {s.lower() for s in stats}
290+
if TestStatus.ERROR in stats:
291+
self._num_errors += 1
292+
elif TestStatus.FAIL in stats:
293+
self._num_fails += 1
294+
else:
295+
for s in stats:
296+
if s.startswith(TestStatus.SKIPPED):
297+
self._num_skipped += 1
298+
break
294299

295300

296301
def process_output(output_lines):
297302
if isinstance(output_lines, str):
298303
output_lines = output_lines.split("\n")
299304

300305
unittests = []
306+
# stats tracked per unittest
301307
unittest_tests = defaultdict(list)
302308
error_messages = defaultdict(set)
303309
java_exceptions = defaultdict(set)
@@ -308,6 +314,7 @@ def process_output(output_lines):
308314
if match:
309315
unittest = match.group('unittest')
310316
unittests.append(unittest)
317+
unittest_tests.clear()
311318
continue
312319

313320
# extract python reported python error messages
@@ -323,15 +330,10 @@ def process_output(output_lines):
323330
continue
324331

325332
# stats
326-
# tracking
333+
# tracking stats
327334
match = re.match(PTRN_TEST_STATUS_INDIVIDUAL, line)
328-
if match:
329-
name = match.group('name')
330-
status = match.group('status')
331-
unittest_tests[name].append(status)
332-
continue
333-
334-
match = re.match(PTRN_TEST_STATUS_ERROR, line)
335+
if not match:
336+
match = re.match(PTRN_TEST_STATUS_ERROR, line)
335337
if match:
336338
name = match.group('name')
337339
status = match.group('status')

0 commit comments

Comments
 (0)