test/pathological_tests.py: Output test durations.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
diff --git a/test/pathological_tests.py b/test/pathological_tests.py
index eedcc71..96e0041 100755
--- a/test/pathological_tests.py
+++ b/test/pathological_tests.py
@@ -6,6 +6,7 @@ import argparse
import sys
import platform
from cmark import CMark
+from timeit import default_timer as timer
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Run cmark tests.')
@@ -57,23 +58,23 @@ pathological = {
("abc\u0000de\u0000",
re.compile("abc\ufffd?de\ufffd?")),
"backticks":
- ("".join(map(lambda x: ("e" + "`" * x), range(1,10000))),
+ ("".join(map(lambda x: ("e" + "`" * x), range(1,1000))),
re.compile("^<p>[e`]*</p>\r?\n$")),
"many links":
("[t](/u) " * 50000,
re.compile("(<a href=\"/u\">t</a> ?){50000}")),
"many references":
- ("".join(map(lambda x: ("[" + str(x) + "]: u\n"), range(1,50000 * 16))) + "[0] " * 50000,
- re.compile("(\[0\] ){49999}")),
+ ("".join(map(lambda x: ("[" + str(x) + "]: u\n"), range(1,20000 * 16))) + "[0] " * 20000,
+ re.compile("(\[0\] ){19999}")),
"deeply nested lists":
("".join(map(lambda x: (" " * x + "* a\n"), range(0,1000))),
re.compile("<ul>\r?\n(<li>a<ul>\r?\n){999}<li>a</li>\r?\n</ul>\r?\n(</li>\r?\n</ul>\r?\n){999}")),
- "many autolink/html openers and closers":
+ "many html openers and closers":
(("<>" * 50000),
re.compile("(<>){50000}")),
- "many codespan openers with no matching closers":
+ "many backticks and escapes":
(("\\``" * 50000),
- re.compile("(``){50000}")),
+ re.compile("(``){50000}"))
}
whitespace_re = re.compile('/s+/')
@@ -84,16 +85,18 @@ failed = 0
#print("Testing pathological cases:")
for description in pathological:
(inp, regex) = pathological[description]
+ start = timer()
[rc, actual, err] = cmark.to_html(inp)
+ end = timer()
if rc != 0:
errored += 1
- print(description, '[ERRORED (return code %d)]' %rc)
+ print('{:35} [ERRORED (return code %d)]'.format(description, rc))
print(err)
elif regex.search(actual):
- #print(description, '[PASSED]')
+ print('{:35} [PASSED] {:.3f} secs'.format(description, end-start))
passed += 1
else:
- print(description, '[FAILED]')
+ print('{:35} [FAILED]'.format(description))
print(repr(actual))
failed += 1