Skip to content

Commit 27f4da6

Browse files
committed
Report 'xfail' marked tests as skipped.
1 parent 4ab3781 commit 27f4da6

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ def get_fixture_values(test_class_instance, names):
201201
import itertools as _itertools_module
202202
return list(_itertools_module.product(*result_vector))
203203

204+
_skipped_marker = object()
204205

205206
class Mark:
206207
@staticmethod
@@ -213,7 +214,7 @@ def decorator(obj):
213214

214215
@staticmethod
215216
def xfail(obj):
216-
def foo():
217+
def foo(self):
217218
pass
218219
foo.__name__ = obj.__name__
219220
return foo
@@ -312,6 +313,7 @@ def __init__(self):
312313
self.exceptions = []
313314
self.passed = 0
314315
self.failed = 0
316+
self.skipped_n = 0
315317

316318
def get_useful_frame(self, tb):
317319
from traceback import extract_tb
@@ -329,6 +331,9 @@ def run_safely(self, func, print_immediately=False):
329331
with print_lock:
330332
print(u"\n\t\u21B3 ", func.__name__, " ", end="", flush=True)
331333

334+
if func.__code__ is Mark.xfail(func).__code__:
335+
return _skipped_marker
336+
332337
# insert fixture params
333338
co = func.__code__
334339
fixture_args = []
@@ -376,7 +381,10 @@ def do_run():
376381
r = self.run_safely(func)
377382
end = time.monotonic() - start
378383
with print_lock:
379-
self.success(end) if r else self.failure(end)
384+
if r is _skipped_marker:
385+
self.skipped()
386+
else:
387+
self.success(end) if r else self.failure(end)
380388
ThreadPool.start(do_run)
381389

382390
def success(self, time):
@@ -392,6 +400,10 @@ def failure(self, time):
392400
print("[%.3fs]" % time, end=" ")
393401
print(fail_msg, end="", flush=True)
394402

403+
def skipped(self):
404+
self.skipped_n += 1
405+
print("s ", end="", flush=True)
406+
395407
def assertIsInstance(self, value, cls):
396408
assert isinstance(value, cls), "Expected %r to be instance of %r" % (value, cls)
397409

@@ -541,6 +553,7 @@ def __init__(self, paths):
541553
self.exceptions = []
542554
self.passed = 0
543555
self.failed = 0
556+
self.skipped_n = 0
544557

545558
@staticmethod
546559
def find_testfiles(paths):
@@ -635,10 +648,11 @@ def run(self):
635648
self.exceptions += testcase.exceptions
636649
self.passed += testcase.passed
637650
self.failed += testcase.failed
651+
self.skipped_n += testcase.skipped_n
638652
if verbose:
639653
print()
640654
ThreadPool.shutdown()
641-
print("\n\nRan %d tests (%d passes, %d failures)" % (self.passed + self.failed, self.passed, self.failed))
655+
print("\n\nRan %d tests (%d passes, %d failures, %d skipped)" % (self.passed + self.failed, self.passed, self.failed, self.skipped_n))
642656
for e in self.exceptions:
643657
msg, exc = e
644658
print(msg)

0 commit comments

Comments
 (0)