diff --git a/html2pdf4doc/main_fuzzer.py b/html2pdf4doc/main_fuzzer.py index 5dfa9dd..eac8b07 100644 --- a/html2pdf4doc/main_fuzzer.py +++ b/html2pdf4doc/main_fuzzer.py @@ -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 @@ -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") @@ -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 @@ -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: @@ -235,7 +231,6 @@ 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( @@ -243,7 +238,6 @@ def main() -> None: 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, ) diff --git a/tasks.py b/tasks.py index 22fdc3d..2393656 100644 --- a/tasks.py +++ b/tasks.py @@ -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) """ @@ -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( @@ -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/ diff --git a/tests/fuzz/00_hello_world/test_case.py b/tests/fuzz/00_hello_world/test_case.py index d79a10d..40902e7 100644 --- a/tests/fuzz/00_hello_world/test_case.py +++ b/tests/fuzz/00_hello_world/test_case.py @@ -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, ) diff --git a/tests/fuzz/01_strictdoc_guide_202510/test_case.py b/tests/fuzz/01_strictdoc_guide_202510/test_case.py index 25a57f8..1cd3e75 100644 --- a/tests/fuzz/01_strictdoc_guide_202510/test_case.py +++ b/tests/fuzz/01_strictdoc_guide_202510/test_case.py @@ -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, ) diff --git a/tests/fuzz/20_L1_Open_Requirements_Tool_202511/test_case.py b/tests/fuzz/20_L1_Open_Requirements_Tool_202511/test_case.py index 0a4cf1e..34a3b81 100644 --- a/tests/fuzz/20_L1_Open_Requirements_Tool_202511/test_case.py +++ b/tests/fuzz/20_L1_Open_Requirements_Tool_202511/test_case.py @@ -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, ) diff --git a/tests/fuzz/21_L2_StrictDoc_Requirements_202511/test_case.py b/tests/fuzz/21_L2_StrictDoc_Requirements_202511/test_case.py index 5cc8ff9..70217b8 100644 --- a/tests/fuzz/21_L2_StrictDoc_Requirements_202511/test_case.py +++ b/tests/fuzz/21_L2_StrictDoc_Requirements_202511/test_case.py @@ -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, ) diff --git a/tests/fuzz/conftest.py b/tests/fuzz/conftest.py index 90fe516..77ffaf4 100644 --- a/tests/fuzz/conftest.py +++ b/tests/fuzz/conftest.py @@ -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", @@ -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: