Skip to content

Commit 6437b49

Browse files
committed
tests(fuzz): enable optionally running the whole test suite with --strict2
1 parent 375f122 commit 6437b49

File tree

7 files changed

+24
-17
lines changed

7 files changed

+24
-17
lines changed

html2pdf4doc/main_fuzzer.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def mutate_and_print(
3131
path_to_input_file: str,
3232
path_to_root: str,
3333
path_to_failed_mutants_dir: str,
34-
strict_mode: bool = False,
3534
strict_mode_2: bool = False,
3635
) -> bool:
3736
assert os.path.isfile(path_to_input_file), path_to_input_file
@@ -79,9 +78,8 @@ def mutate_and_print(
7978
"-m",
8079
"html2pdf4doc.main",
8180
"print",
81+
"--strict",
8282
]
83-
if strict_mode:
84-
cmd.append("--strict")
8583
if strict_mode_2:
8684
cmd.append("--strict2")
8785

@@ -167,7 +165,6 @@ def fuzz_test(
167165
path_to_root: str,
168166
path_to_failed_mutants_dir: str,
169167
total_mutations: int = 20,
170-
strict_mode: bool = False,
171168
strict_mode_2: bool = False,
172169
) -> None:
173170
success_count, failure_count = 0, 0
@@ -181,7 +178,6 @@ def fuzz_test(
181178
path_to_input_file=path_to_input_file,
182179
path_to_root=path_to_root,
183180
path_to_failed_mutants_dir=path_to_failed_mutants_dir,
184-
strict_mode=strict_mode,
185181
strict_mode_2=strict_mode_2,
186182
)
187183
if success:
@@ -235,15 +231,13 @@ def main() -> None:
235231
total_mutations = args.total_mutations
236232
assert 1 <= total_mutations <= 1000, total_mutations
237233

238-
strict_mode = args.strict
239234
strict_mode_2 = args.strict2
240235

241236
fuzz_test(
242237
path_to_input_file=path_to_input_file,
243238
path_to_root=path_to_root,
244239
path_to_failed_mutants_dir=path_to_failed_mutants_dir,
245240
total_mutations=total_mutations,
246-
strict_mode=strict_mode,
247241
strict_mode_2=strict_mode_2,
248242
)
249243

tasks.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,13 @@ def test_integration(
199199

200200

201201
@task(aliases=["tf"])
202-
def test_fuzz(context, focus=None, total_mutations: int = 10, output=False):
202+
def test_fuzz(
203+
context,
204+
focus=None,
205+
total_mutations: int = 10,
206+
output=False,
207+
strict2: bool = False,
208+
):
203209
"""
204210
@relation(SDOC-SRS-44, scope=function)
205211
"""
@@ -212,6 +218,7 @@ def test_fuzz(context, focus=None, total_mutations: int = 10, output=False):
212218
long_argument = (
213219
f"--fuzz-total-mutations={total_mutations}" if total_mutations else ""
214220
)
221+
strict2_argument = "--fuzz-strict2" if strict2 else ""
215222
output_argument = "--capture=no" if output else ""
216223

217224
run_invoke(
@@ -227,6 +234,7 @@ def test_fuzz(context, focus=None, total_mutations: int = 10, output=False):
227234
pytest
228235
{focus_argument}
229236
{long_argument}
237+
{strict2_argument}
230238
{output_argument}
231239
-o cache_dir=build/tests_fuzz_cache
232240
tests/fuzz/

tests/fuzz/00_hello_world/test_case.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ def test(fuzz_config: FuzzConfig):
1616
path_to_root=build_folder,
1717
path_to_failed_mutants_dir=create_failed_mutants_folder(PATH_TO_THIS_FOLDER),
1818
total_mutations=fuzz_config.total_mutations,
19-
strict_mode=True,
20-
strict_mode_2=False,
19+
strict_mode_2=fuzz_config.strict_mode_2,
2120
)

tests/fuzz/01_strictdoc_guide_202510/test_case.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ def test(fuzz_config: FuzzConfig):
1616
path_to_root=build_folder,
1717
path_to_failed_mutants_dir=create_failed_mutants_folder(PATH_TO_THIS_FOLDER),
1818
total_mutations=fuzz_config.total_mutations,
19-
strict_mode=True,
20-
strict_mode_2=False,
19+
strict_mode_2=fuzz_config.strict_mode_2,
2120
)

tests/fuzz/20_L1_Open_Requirements_Tool_202511/test_case.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ def test(fuzz_config: FuzzConfig):
1616
path_to_root=build_folder,
1717
path_to_failed_mutants_dir=create_failed_mutants_folder(PATH_TO_THIS_FOLDER),
1818
total_mutations=fuzz_config.total_mutations,
19-
strict_mode=True,
20-
strict_mode_2=False,
19+
strict_mode_2=fuzz_config.strict_mode_2,
2120
)

tests/fuzz/21_L2_StrictDoc_Requirements_202511/test_case.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ def test(fuzz_config: FuzzConfig):
1616
path_to_root=build_folder,
1717
path_to_failed_mutants_dir=create_failed_mutants_folder(PATH_TO_THIS_FOLDER),
1818
total_mutations=fuzz_config.total_mutations,
19-
strict_mode=True,
20-
strict_mode_2=False,
19+
strict_mode_2=fuzz_config.strict_mode_2,
2120
)

tests/fuzz/conftest.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@
1111

1212
@dataclass
1313
class FuzzConfig:
14+
strict_mode_2: bool
1415
total_mutations: bool
1516

1617

1718
def pytest_addoption(parser):
19+
parser.addoption(
20+
"--fuzz-strict2",
21+
action="store_true",
22+
help="Enables Strict mode (level 2).",
23+
)
1824
parser.addoption(
1925
"--fuzz-total-mutations",
2026
action="store",
@@ -26,7 +32,10 @@ def pytest_addoption(parser):
2632

2733
@pytest.fixture
2834
def fuzz_config(request):
29-
return FuzzConfig(total_mutations=request.config.getoption("--fuzz-total-mutations"))
35+
return FuzzConfig(
36+
strict_mode_2=request.config.getoption("--fuzz-strict2"),
37+
total_mutations=request.config.getoption("--fuzz-total-mutations")
38+
)
3039

3140

3241
def create_build_folder(test_folder: str) -> str:

0 commit comments

Comments
 (0)