Skip to content

Commit 7e412cb

Browse files
committed
[hotfix] mx python3_unittests utility: fix regex for passing unittests with skipped tests
PullRequest: graalpython/104
2 parents 6d9d321 + 4d376e6 commit 7e412cb

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@
4040
import os
4141
import re
4242
import subprocess
43-
import sys
4443
from collections import defaultdict
4544
from json import dumps
4645
from multiprocessing import Pool
4746
from pprint import pformat
48-
from time import gmtime, strftime
4947

5048
import argparse
49+
import sys
50+
from time import gmtime, strftime
5151

5252
# global CLI flags
5353
flags = None
@@ -64,8 +64,10 @@
6464
PTRN_ERROR = re.compile(r'^(?P<error>[A-Z][a-z][a-zA-Z]+):(?P<message>.*)$')
6565
PTRN_UNITTEST = re.compile(r'^#### running: graalpython/lib-python/3/test/(?P<unittest>.*)$')
6666
PTRN_NUM_TESTS = re.compile(r'^Ran (?P<num_tests>\d+) test.*$')
67-
PTRN_NUM_ERRORS = re.compile(
67+
PTRN_FAILED = re.compile(
6868
r'^FAILED \((failures=(?P<failures>\d+))?(, )?(errors=(?P<errors>\d+))?(, )?(skipped=(?P<skipped>\d+))?\)$')
69+
PTRN_OK = re.compile(
70+
r'^OK \((failures=(?P<failures>\d+))?(, )?(errors=(?P<errors>\d+))?(, )?(skipped=(?P<skipped>\d+))?\)$')
6971
PTRN_JAVA_EXCEPTION = re.compile(r'^(?P<exception>com\.oracle\.[^:]*):(?P<message>.*)')
7072
PTRN_MODULE_NOT_FOUND = re.compile(r'.*ModuleNotFound: \'(?P<module>.*)\'\..*', re.DOTALL)
7173

@@ -169,8 +171,8 @@ def __init__(self):
169171
self.num_skipped = -1
170172

171173
def all_ok(self):
172-
self.num_errors = 0
173174
self.num_fails = 0
175+
self.num_errors = 0
174176
self.num_skipped = 0
175177

176178
@property
@@ -212,12 +214,23 @@ def process_output(output_lines):
212214
stats[unittests[-1]].all_ok()
213215
continue
214216

217+
match = re.match(PTRN_OK, line)
218+
if match:
219+
fails = match.group('failures')
220+
errs = match.group('errors')
221+
skipped = match.group('skipped')
222+
223+
stats[unittests[-1]].num_fails = int(fails) if fails else 0
224+
stats[unittests[-1]].num_errors = int(errs) if errs else 0
225+
stats[unittests[-1]].num_skipped = int(skipped) if skipped else 0
226+
continue
227+
215228
match = re.match(PTRN_NUM_TESTS, line)
216229
if match:
217230
stats[unittests[-1]].num_tests = int(match.group('num_tests'))
218231
continue
219232

220-
match = re.match(PTRN_NUM_ERRORS, line)
233+
match = re.match(PTRN_FAILED, line)
221234
if match:
222235
fails = match.group('failures')
223236
errs = match.group('errors')

0 commit comments

Comments
 (0)