From 2454df7e0e93bb7d833f83c7d55df03261c208d4 Mon Sep 17 00:00:00 2001 From: Ephraiem Sarabamoun Date: Sat, 30 May 2026 07:00:32 -0700 Subject: [PATCH] tests: cover a completed parallel_attempts run Add a parametrized test that runs garak through garak.cli.main with --parallel_attempts set to 1 and to 4, against the CPU-only test.Blank generator and the multi-prompt test.Test probe, and asserts the run completes without error. The only existing --parallel_attempts run deliberately expects a ValueError from the max_workers cap, so the path where parallel_attempts is greater than 1 and a run finishes was not covered anywhere. test.Test carries 8 prompts, so the greater than 1 case actually reaches the multiprocessing path in Probe._execute_all. Closes #338 Signed-off-by: Ephraiem Sarabamoun --- tests/test_config.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_config.py b/tests/test_config.py index bf712623b..9f5786b87 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -847,6 +847,20 @@ def test_site_yaml_overrides_max_workers(capsys): assert exc_info.value.code == 1 +# a run with parallel_attempts set should complete without error, for both the +# serial case (1) and a parallel case (>1). uses the cheap CPU-only test +# generator and the multi-prompt test.Test probe so that the >1 case actually +# reaches the multiprocessing path in garak.probes.base.Probe._execute_all +@pytest.mark.parametrize("parallel_attempts", [1, 4]) +def test_parallel_attempts_run_completes(parallel_attempts): + args = ( + f"--parallel_attempts {parallel_attempts} -m test.Blank -p test.Test -g 1" + ).split() + garak.cli.main(args) + + assert _config.system.parallel_attempts == parallel_attempts + + model_target_data = [ ("model_type", "model_name"), ("model_type", "target_name"),