mirror of
https://github.com/denoland/deno.git
synced 2025-09-14 22:55:03 +00:00
Improve tools/unit_tests.py (#958)
Checks the output more carefully. The first line of output from js/unit_tests.ts should be something like "running 96 tests" And the last line should be something like "test result: ok. 96 passed; 0 failed; 0 ignored; 0 measured; 36 filtered out" This parses those strings and make sure they align. This will catch silent death bugs.
This commit is contained in:
parent
c814d5a914
commit
d4f72e18be
6 changed files with 675 additions and 20 deletions
|
@ -1,5 +1,8 @@
|
|||
# Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
from util import pattern_match, parse_exit_code, shell_quote_win
|
||||
import util
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def pattern_match_test():
|
||||
|
@ -44,10 +47,42 @@ def shell_quote_win_test():
|
|||
'a"b""c\\d\\"e\\\\')
|
||||
|
||||
|
||||
def parse_unit_test_output_test():
|
||||
print "Testing util.parse_unit_test_output()..."
|
||||
# This is an example of a successful unit test output.
|
||||
output = open(
|
||||
os.path.join(util.root_path, "tools/testdata/unit_test_output1.txt"))
|
||||
(actual, expected) = util.parse_unit_test_output(output, False)
|
||||
assert actual == 96
|
||||
assert expected == 96
|
||||
|
||||
# This is an example of a silently dying unit test.
|
||||
output = open(
|
||||
os.path.join(util.root_path, "tools/testdata/unit_test_output2.txt"))
|
||||
(actual, expected) = util.parse_unit_test_output(output, False)
|
||||
assert actual == None
|
||||
assert expected == 96
|
||||
|
||||
# This is an example of compiling before successful unit tests.
|
||||
output = open(
|
||||
os.path.join(util.root_path, "tools/testdata/unit_test_output3.txt"))
|
||||
(actual, expected) = util.parse_unit_test_output(output, False)
|
||||
assert actual == 96
|
||||
assert expected == 96
|
||||
|
||||
# Check what happens on empty output.
|
||||
from StringIO import StringIO
|
||||
output = StringIO("\n\n\n")
|
||||
(actual, expected) = util.parse_unit_test_output(output, False)
|
||||
assert actual == None
|
||||
assert expected == None
|
||||
|
||||
|
||||
def util_test():
|
||||
pattern_match_test()
|
||||
parse_exit_code_test()
|
||||
shell_quote_win_test()
|
||||
parse_unit_test_output_test()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue