Skip to content

Commit

Permalink
test/run-testsuite.py: Allow disabling normalisation on per-unittest …
Browse files Browse the repository at this point in the history
…basis.

And use it for few tests in regressions.txt where the whitespace
matters.
  • Loading branch information
mity committed Jan 25, 2024
1 parent 4933a89 commit d082cdd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions test/regressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -690,14 +690,14 @@ _*xx-_-
If from one side (and the other has no space/newline), replace new line with
space.

```````````````````````````````` example
```````````````````````````````` example [no-normalize]
`
foo`
.
<p><code> foo</code></p>
````````````````````````````````

```````````````````````````````` example
```````````````````````````````` example [no-normalize]
`foo
`
.
Expand All @@ -706,14 +706,15 @@ foo`

If from both side, eat it.

```````````````````````````````` example
```````````````````````````````` example [no-normalize]
`
foo
`
.
<p><code>foo</code></p>
````````````````````````````````


## [Issue 226](https://github.com/mity/md4c/issues/226)

```````````````````````````````` example
Expand Down
9 changes: 7 additions & 2 deletions test/run-testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def do_test(test, normalize, result_counts):
if retcode == 0:
expected_html = test['html']
unicode_error = None
if normalize:
if normalize and not test['no_normalize']:
try:
passed = normalize_html(actual_html) == normalize_html(expected_html)
except UnicodeDecodeError as e:
Expand Down Expand Up @@ -84,6 +84,7 @@ def get_tests(specfile):
state = 0 # 0 regular text, 1 markdown example, 2 html output
headertext = ''
tests = []
no_normalize = 0

header_re = re.compile('#+ ')

Expand All @@ -93,22 +94,26 @@ def get_tests(specfile):
l = line.strip()
if re.match("`{32} example( [a-z]{1,})?", l):
state = 1
if re.search("\\[no-normalize\\]", l):
no_normalize = 1
elif state >= 2 and l == "`" * 32:
state = 0
example_number = example_number + 1
end_line = line_number
tests.append({
"markdown":''.join(markdown_lines).replace('→',"\t"),
"html":''.join(html_lines).replace('→',"\t"),
"no_normalize": no_normalize,
"cmdline_options":''.join(cmdline_lines),
"example": example_number,
"start_line": start_line,
"end_line": end_line,
"section": headertext})
"section": headertext,})
start_line = 0
markdown_lines = []
html_lines = []
cmdline_lines = []
no_normalize = 0
elif l == ".":
state += 1
elif state == 1:
Expand Down

0 comments on commit d082cdd

Please sign in to comment.