Skip to content

Commit c5c7813

Browse files
authored
Merge pull request #157 from common-workflow-language/cwltest-improvements
Improve cwltest to handle keyboard interrupt.
2 parents 75dcbf5 + 219e393 commit c5c7813

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

cwltool/cwltest.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def run_test(args, i, t): # type: (argparse.Namespace, Any, Dict[str,str]) -> i
125125
_logger.error(u"Parse error %s", str(e))
126126
except KeyboardInterrupt:
127127
_logger.error(u"""Test interrupted: %s""", " ".join([pipes.quote(tc) for tc in test_command]))
128-
return 1
128+
raise
129129

130130
failed = False
131131

@@ -200,21 +200,29 @@ def main(): # type: () -> int
200200
else:
201201
ntest = range(0, len(tests))
202202

203-
for i in ntest:
204-
t = tests[i]
205-
sys.stderr.write("\rTest [%i/%i] " % (i+1, len(tests)))
206-
sys.stderr.flush()
207-
rt = run_test(args, i, t)
208-
if rt == 1:
209-
failures += 1
210-
elif rt == UNSUPPORTED_FEATURE:
211-
unsupported += 1
203+
total = 0
204+
try:
205+
for i in ntest:
206+
t = tests[i]
207+
sys.stderr.write("\rTest [%i/%i] " % (i+1, len(tests)))
208+
sys.stderr.flush()
209+
rt = run_test(args, i, t)
210+
total += 1
211+
if rt == 1:
212+
failures += 1
213+
elif rt == UNSUPPORTED_FEATURE:
214+
unsupported += 1
215+
except KeyboardInterrupt:
216+
_logger.error("Tests interrupted")
212217

213218
if failures == 0 and unsupported == 0:
214219
_logger.info("All tests passed")
215220
return 0
221+
elif failures == 0 and unsupported > 0:
222+
_logger.warn("%i tests passed, %i unsupported features", total - unsupported, unsupported)
223+
return 0
216224
else:
217-
_logger.warn("%i failures, %i unsupported features", failures, unsupported)
225+
_logger.warn("%i tests passed, %i failures, %i unsupported features", total - (failures + unsupported), failures, unsupported)
218226
return 1
219227

220228

0 commit comments

Comments
 (0)