Skip to content

Commit

Permalink
Fuzzer improvements
Browse files Browse the repository at this point in the history
- Simplify fuzzer scripts and run more API calls
  • Loading branch information
frnmst committed Apr 16, 2024
1 parent 6600444 commit b083a3b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
21 changes: 14 additions & 7 deletions md_toc/tests/fuzzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,7 @@
def TestBuildToc(data):
r"""Test the md_toc.api.build_toc function."""
with tempfile.NamedTemporaryFile() as fp:

bytez: bytes = b''.join([
bytes('#' * (secrets.randbelow(6) + 1), 'UTF-8'),
b' ',
data,
])
fp.write(bytez)
fp.write(data)

# Move pointer to the start of the file.
fp.seek(0)
Expand All @@ -48,6 +42,19 @@ def TestBuildToc(data):
api.build_toc(filename=fp.name,
parser=parser,
keep_header_levels=6)
api.build_toc(filename=fp.name,
parser=parser,
keep_header_levels=6,
ordered=True)
api.build_toc(filename=fp.name,
parser=parser,
keep_header_levels=6,
ordered=True)
api.build_toc(filename=fp.name,
parser=parser,
keep_header_levels=6,
skip_lines=secrets.randbelow(100))

except (exceptions.GithubEmptyLinkLabel,
exceptions.TocDoesNotRenderAsCoherentList,
exceptions.GithubOverflowCharsLinkLabel) as e:
Expand Down
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,8 @@ package = wheel
wheel_build_env = .pkg
deps =
atheris>=2.3,<2.4
-r requirements.txt
-r requirements-dev.txt
commands =
python3 -m md_toc.tests.fuzzer
coverage run -m md_toc.tests.fuzzer -atheris_runs=100000000
coverage html

0 comments on commit b083a3b

Please sign in to comment.