Skip to content

Commit

Permalink
pathological tests: half the number of repetitions, and the timeout.
Browse files Browse the repository at this point in the history
This reduces the time needed for the pathological tests.
  • Loading branch information
jgm committed Aug 13, 2022
1 parent 0169d38 commit eb54ef4
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions test/pathological_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import time
from cmark import CMark

TIMEOUT = 10
TIMEOUT = 5

parser = argparse.ArgumentParser(description='Run cmark tests.')
parser.add_argument('--program', dest='program', nargs='?', default=None,
Expand All @@ -26,7 +26,7 @@

def hash_collisions():
REFMAP_SIZE = 16
COUNT = 50000
COUNT = 25000

def badhash(ref):
h = 0
Expand All @@ -51,52 +51,52 @@ def badhash(ref):
pathological = {
# note - some pythons have limit of 65535 for {num-matches} in re.
"nested strong emph":
(("*a **a " * 65000) + "b" + (" a** a*" * 65000),
re.compile("(<em>a <strong>a ){65000}b( a</strong> a</em>){65000}")),
(("*a **a " * 32500) + "b" + (" a** a*" * 32500),
re.compile("(<em>a <strong>a ){32500}b( a</strong> a</em>){32500}")),
"many emph closers with no openers":
(("a_ " * 65000),
re.compile("(a[_] ){64999}a_")),
(("a_ " * 32500),
re.compile("(a[_] ){32499}a_")),
"many emph openers with no closers":
(("_a " * 65000),
re.compile("(_a ){64999}_a")),
(("_a " * 32500),
re.compile("(_a ){32499}_a")),
"many link closers with no openers":
(("a]" * 65000),
re.compile("(a\]){65000}")),
(("a]" * 32500),
re.compile("(a\]){32500}")),
"many link openers with no closers":
(("[a" * 65000),
re.compile("(\[a){65000}")),
(("[a" * 32500),
re.compile("(\[a){32500}")),
"mismatched openers and closers":
(("*a_ " * 50000),
re.compile("([*]a[_] ){49999}[*]a_")),
(("*a_ " * 25000),
re.compile("([*]a[_] ){24999}[*]a_")),
"issue #389":
(("*a " * 20000 + "_a*_ " * 20000),
re.compile("(<em>a ){20000}(_a<\/em>_ ?){20000}")),
"openers and closers multiple of 3":
(("a**b" + ("c* " * 50000)),
re.compile("a[*][*]b(c[*] ){49999}c[*]")),
(("a**b" + ("c* " * 25000)),
re.compile("a[*][*]b(c[*] ){24999}c[*]")),
"link openers and emph closers":
(("[ a_" * 50000),
re.compile("(\[ a_){50000}")),
(("[ a_" * 25000),
re.compile("(\[ a_){25000}")),
"pattern [ (]( repeated":
(("[ (](" * 80000),
re.compile("(\[ \(\]\(){80000}")),
(("[ (](" * 40000),
re.compile("(\[ \(\]\(){40000}")),
"hard link/emph case":
("**x [a*b**c*](d)",
re.compile("\\*\\*x <a href=\"d\">a<em>b\\*\\*c</em></a>")),
"nested brackets":
(("[" * 50000) + "a" + ("]" * 50000),
re.compile("\[{50000}a\]{50000}")),
(("[" * 25000) + "a" + ("]" * 25000),
re.compile("\[{25000}a\]{25000}")),
"nested block quotes":
((("> " * 50000) + "a"),
re.compile("(<blockquote>\n){50000}")),
((("> " * 25000) + "a"),
re.compile("(<blockquote>\n){25000}")),
"deeply nested lists":
("".join(map(lambda x: (" " * x + "* a\n"), range(0,1000))),
re.compile("<ul>\n(<li>a\n<ul>\n){999}<li>a</li>\n</ul>\n(</li>\n</ul>\n){999}")),
("".join(map(lambda x: (" " * x + "* a\n"), range(0,500))),
re.compile("<ul>\n(<li>a\n<ul>\n){499}<li>a</li>\n</ul>\n(</li>\n</ul>\n){499}")),
"U+0000 in input":
("abc\u0000de\u0000",
re.compile("abc\ufffd?de\ufffd?")),
"backticks":
("".join(map(lambda x: ("e" + "`" * x), range(1,5000))),
("".join(map(lambda x: ("e" + "`" * x), range(1,2500))),
re.compile("^<p>[e`]*</p>\n$")),
"unclosed links A":
("[a](<b" * 30000,
Expand All @@ -112,7 +112,7 @@ def badhash(ref):

pathological_cmark = {
"nested inlines":
("*" * 40000 + "a" + "*" * 40000,
("*" * 20000 + "a" + "*" * 20000,
re.compile("^\*+a\*+$")),
}

Expand Down

0 comments on commit eb54ef4

Please sign in to comment.