Commit fc27108e71271d0b2aadf3c6919dd212498c24fb

Martin Mitas 2019-03-11T19:55:08

test/pathological_tests.py: Output test durations.

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("(&lt;&gt;){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