Skip to content

Commit b51d74e

Browse files
committed
add --skip_tests for unittests report generator
1 parent fad98f0 commit b51d74e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,17 @@ def run_unittests(unittests):
151151
return [res.get()[1] for res in results]
152152

153153

154-
def get_unittests(base_tests_path, limit=None, sort=True):
154+
def get_unittests(base_tests_path, limit=None, sort=True, skip_tests=None):
155155
def _sorter(iterable):
156156
return sorted(iterable) if sort else iterable
157157
unittests = [os.path.join(base_tests_path, name)
158158
for name in _sorter(os.listdir(base_tests_path))
159159
if name.startswith("test_")]
160+
if skip_tests:
161+
log("[INFO] skipping unittests: {}", skip_tests)
162+
cnt = len(unittests)
163+
unittests = [t for t in unittests if t not in skip_tests]
164+
log("[INFO] running {} of {} unittests", len(unittests), cnt)
160165
return unittests[:limit] if limit else unittests
161166

162167

@@ -624,6 +629,8 @@ def main(prog, args):
624629
parser.add_argument("-l", "--limit", help="Limit the number of unittests to run.", default=None, type=int)
625630
parser.add_argument("-t", "--tests_path", help="Unittests path.", default=PATH_UNITTESTS)
626631
parser.add_argument("-o", "--only_tests", help="Run only these unittests (comma sep values).", default=None)
632+
parser.add_argument("-s", "--skip_tests", help="Run all unittests except (comma sep values)."
633+
"the only_tets option takes precedence", default=None)
627634
parser.add_argument("path", help="Path to store the csv output and logs to.", nargs='?', default=None)
628635

629636
global flags
@@ -638,14 +645,16 @@ def main(prog, args):
638645
else:
639646
log("[INFO] results will not be saved remotely")
640647

648+
def _fmt(t):
649+
t = t.strip()
650+
return os.path.join(flags.tests_path, t if t.endswith(".py") else t + ".py")
651+
641652
if flags.only_tests:
642-
def _fmt(t):
643-
t = t.strip()
644-
return os.path.join(flags.tests_path, t if t.endswith(".py") else t + ".py")
645653
only_tests = set([_fmt(test) for test in flags.only_tests.split(",")])
646654
unittests = [t for t in get_unittests(flags.tests_path) if t in only_tests]
647655
else:
648-
unittests = get_unittests(flags.tests_path, limit=flags.limit)
656+
skip_tests = set([_fmt(test) for test in flags.skip_tests.split(",")]) if flags.skip_tests else None
657+
unittests = get_unittests(flags.tests_path, limit=flags.limit, skip_tests=skip_tests)
649658

650659
results = run_unittests(unittests)
651660
txt_report_path = file_name(TXT_RESULTS_NAME, current_date)

0 commit comments

Comments
 (0)