Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions html2pdf4doc/main_fuzzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def mutate_and_print(
path_to_input_file: str,
path_to_root: str,
path_to_failed_mutants_dir: str,
strict_mode: bool = False,
strict_mode_2: bool = False,
) -> bool:
assert os.path.isfile(path_to_input_file), path_to_input_file
Expand Down Expand Up @@ -79,9 +78,8 @@ def mutate_and_print(
"-m",
"html2pdf4doc.main",
"print",
"--strict",
]
if strict_mode:
cmd.append("--strict")
if strict_mode_2:
cmd.append("--strict2")

Expand Down Expand Up @@ -167,7 +165,6 @@ def fuzz_test(
path_to_root: str,
path_to_failed_mutants_dir: str,
total_mutations: int = 20,
strict_mode: bool = False,
strict_mode_2: bool = False,
) -> None:
success_count, failure_count = 0, 0
Expand All @@ -181,7 +178,6 @@ def fuzz_test(
path_to_input_file=path_to_input_file,
path_to_root=path_to_root,
path_to_failed_mutants_dir=path_to_failed_mutants_dir,
strict_mode=strict_mode,
strict_mode_2=strict_mode_2,
)
if success:
Expand Down Expand Up @@ -235,15 +231,13 @@ def main() -> None:
total_mutations = args.total_mutations
assert 1 <= total_mutations <= 1000, total_mutations

strict_mode = args.strict
strict_mode_2 = args.strict2

fuzz_test(
path_to_input_file=path_to_input_file,
path_to_root=path_to_root,
path_to_failed_mutants_dir=path_to_failed_mutants_dir,
total_mutations=total_mutations,
strict_mode=strict_mode,
strict_mode_2=strict_mode_2,
)

Expand Down
10 changes: 9 additions & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,13 @@ def test_integration(


@task(aliases=["tf"])
def test_fuzz(context, focus=None, total_mutations: int = 10, output=False):
def test_fuzz(
context,
focus=None,
total_mutations: int = 10,
output=False,
strict2: bool = False,
):
"""
@relation(SDOC-SRS-44, scope=function)
"""
Expand All @@ -212,6 +218,7 @@ def test_fuzz(context, focus=None, total_mutations: int = 10, output=False):
long_argument = (
f"--fuzz-total-mutations={total_mutations}" if total_mutations else ""
)
strict2_argument = "--fuzz-strict2" if strict2 else ""
output_argument = "--capture=no" if output else ""

run_invoke(
Expand All @@ -227,6 +234,7 @@ def test_fuzz(context, focus=None, total_mutations: int = 10, output=False):
pytest
{focus_argument}
{long_argument}
{strict2_argument}
{output_argument}
-o cache_dir=build/tests_fuzz_cache
tests/fuzz/
Expand Down
3 changes: 1 addition & 2 deletions tests/fuzz/00_hello_world/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ def test(fuzz_config: FuzzConfig):
path_to_root=build_folder,
path_to_failed_mutants_dir=create_failed_mutants_folder(PATH_TO_THIS_FOLDER),
total_mutations=fuzz_config.total_mutations,
strict_mode=True,
strict_mode_2=False,
strict_mode_2=fuzz_config.strict_mode_2,
)
3 changes: 1 addition & 2 deletions tests/fuzz/01_strictdoc_guide_202510/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ def test(fuzz_config: FuzzConfig):
path_to_root=build_folder,
path_to_failed_mutants_dir=create_failed_mutants_folder(PATH_TO_THIS_FOLDER),
total_mutations=fuzz_config.total_mutations,
strict_mode=True,
strict_mode_2=False,
strict_mode_2=fuzz_config.strict_mode_2,
)
3 changes: 1 addition & 2 deletions tests/fuzz/20_L1_Open_Requirements_Tool_202511/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ def test(fuzz_config: FuzzConfig):
path_to_root=build_folder,
path_to_failed_mutants_dir=create_failed_mutants_folder(PATH_TO_THIS_FOLDER),
total_mutations=fuzz_config.total_mutations,
strict_mode=True,
strict_mode_2=False,
strict_mode_2=fuzz_config.strict_mode_2,
)
3 changes: 1 addition & 2 deletions tests/fuzz/21_L2_StrictDoc_Requirements_202511/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ def test(fuzz_config: FuzzConfig):
path_to_root=build_folder,
path_to_failed_mutants_dir=create_failed_mutants_folder(PATH_TO_THIS_FOLDER),
total_mutations=fuzz_config.total_mutations,
strict_mode=True,
strict_mode_2=False,
strict_mode_2=fuzz_config.strict_mode_2,
)
11 changes: 10 additions & 1 deletion tests/fuzz/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@

@dataclass
class FuzzConfig:
strict_mode_2: bool
total_mutations: bool


def pytest_addoption(parser):
parser.addoption(
"--fuzz-strict2",
action="store_true",
help="Enables Strict mode (level 2).",
)
parser.addoption(
"--fuzz-total-mutations",
action="store",
Expand All @@ -26,7 +32,10 @@ def pytest_addoption(parser):

@pytest.fixture
def fuzz_config(request):
return FuzzConfig(total_mutations=request.config.getoption("--fuzz-total-mutations"))
return FuzzConfig(
strict_mode_2=request.config.getoption("--fuzz-strict2"),
total_mutations=request.config.getoption("--fuzz-total-mutations")
)


def create_build_folder(test_folder: str) -> str:
Expand Down
Loading