mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
test/problems: Report when tests do not run properly
When some of the individual tests fail to run, the `make test` target would still pass since test/problems would not return an error which could hide the fact that there are problems in the test. With this change, if you do not have the python dateutil package, you will now get output like: 'test_totals.t' failed to run any tests. Passed: 975 Failed: 1 Unexpected successes: 0 Skipped: 0 Expected failures: 0 Runtime: 4.83 seconds Or, if you do not have UTF-8 encoding set in your language you will get something like: 'track.t' failed to run all tests. 'stop.t' failed to run all tests. 'start.t' failed to run all tests. 'test_totals.t' failed to run all tests. Passed: 941 Failed: 50 Unexpected successes: 0 Skipped: 0 Expected failures: 0 Runtime: 4.55 seconds
This commit is contained in:
parent
d62fc02649
commit
6852fd2924
1 changed files with 23 additions and 5 deletions
|
@ -60,10 +60,13 @@ if __name__ == "__main__":
|
||||||
ok = re.compile(r"^ok ", re.I)
|
ok = re.compile(r"^ok ", re.I)
|
||||||
not_ok = re.compile(r"^not ok", re.I)
|
not_ok = re.compile(r"^not ok", re.I)
|
||||||
comment = re.compile(r"^#")
|
comment = re.compile(r"^#")
|
||||||
plan = re.compile(r"^1..\d+\s*(?:#.*)?$")
|
plan = re.compile(r"^1..(\d+)\s*(?:#.*)?$")
|
||||||
|
|
||||||
start = None
|
start = None
|
||||||
stop = None
|
stop = None
|
||||||
|
filename = None
|
||||||
|
expected_test_count = 0
|
||||||
|
need_plan = False
|
||||||
|
|
||||||
with open(cmd_args.tapfile) as fh:
|
with open(cmd_args.tapfile) as fh:
|
||||||
for line in fh:
|
for line in fh:
|
||||||
|
@ -74,22 +77,39 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
match = file.match(line)
|
match = file.match(line)
|
||||||
if match:
|
if match:
|
||||||
|
if filename:
|
||||||
|
if expected_test_count > 0:
|
||||||
|
print(color("'{}' failed to run all tests.".format(filename), "red"), file=sys.stderr)
|
||||||
|
errors[filename] += expected_test_count
|
||||||
|
elif need_plan:
|
||||||
|
print(color("'{}' failed to run any tests.".format(filename), "red"), file=sys.stderr)
|
||||||
|
errors[filename] += 1
|
||||||
filename = match.group(1)
|
filename = match.group(1)
|
||||||
|
need_plan = True
|
||||||
|
continue
|
||||||
|
|
||||||
|
match = plan.match(line)
|
||||||
|
if match:
|
||||||
|
expected_test_count = int(match.group(1))
|
||||||
|
need_plan = False
|
||||||
continue
|
continue
|
||||||
|
|
||||||
match = expected_fail.match(line)
|
match = expected_fail.match(line)
|
||||||
if match:
|
if match:
|
||||||
expected[filename] += 1
|
expected[filename] += 1
|
||||||
|
expected_test_count -= 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
match = unexpected_pass.match(line)
|
match = unexpected_pass.match(line)
|
||||||
if match:
|
if match:
|
||||||
unexpected[filename] += 1
|
unexpected[filename] += 1
|
||||||
|
expected_test_count -= 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
match = skip.match(line)
|
match = skip.match(line)
|
||||||
if match:
|
if match:
|
||||||
skipped[filename] += 1
|
skipped[filename] += 1
|
||||||
|
expected_test_count -= 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# It's important these come last, since they're subpatterns of the above
|
# It's important these come last, since they're subpatterns of the above
|
||||||
|
@ -97,15 +117,13 @@ if __name__ == "__main__":
|
||||||
match = ok.match(line)
|
match = ok.match(line)
|
||||||
if match:
|
if match:
|
||||||
passed[filename] += 1
|
passed[filename] += 1
|
||||||
|
expected_test_count -= 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
match = not_ok.match(line)
|
match = not_ok.match(line)
|
||||||
if match:
|
if match:
|
||||||
errors[filename] += 1
|
errors[filename] += 1
|
||||||
continue
|
expected_test_count -= 1
|
||||||
|
|
||||||
match = plan.match(line)
|
|
||||||
if match:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
match = comment.match(line)
|
match = comment.match(line)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue