Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions testflo/filters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import print_function

import os


class TimeFilter(object):
"""This iterator saves to the specified output file only those tests
that complete successfully in max_time seconds or less. This output
Expand Down Expand Up @@ -29,13 +32,17 @@ def __init__(self, outfile):
self.outfile = outfile

def get_iter(self, input_iter):
fails = []
try:
os.remove(self.outfile)
except OSError:
pass

for result in input_iter:
if result.status == 'FAIL' and not result.expected_fail:
fails.append(result.spec)
yield result

if fails:
with open(self.outfile, 'w') as f:
for spec in sorted(fails):
with open(self.outfile, 'a') as f:
if result.nprocs > 1:
spec = f"{result.spec} # mpi, nprocs={result.nprocs}"
else:
spec = result.spec
print(spec, file=f)
yield result
4 changes: 4 additions & 0 deletions testflo/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def testcontext(test):
global _testing_path
old_sys_path = sys.path

os.environ['TESTFLO_SPEC'] = test.spec

_testing_path[0] = test.test_dir
sys.path = _testing_path

Expand All @@ -61,6 +63,8 @@ def testcontext(test):
test.err_msg = traceback.format_exc()
finally:
sys.path = old_sys_path
if 'TESTFLO_SPEC' in os.environ:
del os.environ['TESTFLO_SPEC']


class Test(object):
Expand Down