Skip to content

Commit b3a43fe

Browse files
test(cli): assert -p and --run_spec drive the same end-to-end run
Signed-off-by: Patricia Pampanelli <ppampanelli@nvidia.com>
1 parent 089ec2c commit b3a43fe

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

tests/cli/test_cli.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,57 @@ def test_run_all_active_detectors(capsys):
8383
result = capsys.readouterr()
8484
last_line = result.out.strip().split("\n")[-1]
8585
assert re.match("^✔️ garak run complete in [0-9]+\\.[0-9]+s$", last_line)
86+
87+
88+
def test_legacy_probes_and_run_spec_select_same_run(capsys):
89+
"""The deprecated -p flag and the unified --run_spec must drive the same
90+
end-to-end run: identical probe + detector selection, both completing."""
91+
complete = "^✔️ garak run complete in [0-9]+\\.[0-9]+s$"
92+
93+
cli.main(
94+
[
95+
"-m",
96+
"test",
97+
"-p",
98+
"test.Blank",
99+
"-d",
100+
"always.Pass",
101+
"-g",
102+
"1",
103+
"--narrow_output",
104+
]
105+
)
106+
legacy_last = capsys.readouterr().out.strip().split("\n")[-1]
107+
legacy_spec = dict(_config.run.spec)
108+
legacy_detector = _config.plugins.detector_spec
109+
110+
cli.main(
111+
[
112+
"-m",
113+
"test",
114+
"--run_spec",
115+
"probes.test.Blank",
116+
"-d",
117+
"always.Pass",
118+
"-g",
119+
"1",
120+
"--narrow_output",
121+
]
122+
)
123+
new_last = capsys.readouterr().out.strip().split("\n")[-1]
124+
new_spec = dict(_config.run.spec)
125+
new_detector = _config.plugins.detector_spec
126+
127+
assert re.match(
128+
complete, legacy_last
129+
), f"legacy -p run did not complete; last line: {legacy_last!r}"
130+
assert re.match(
131+
complete, new_last
132+
), f"--run_spec run did not complete; last line: {new_last!r}"
133+
assert legacy_spec == new_spec == {
134+
"include": ["probes.test.Blank"],
135+
"exclude": [],
136+
}, f"old and new formats must resolve to the same run.spec; got {legacy_spec!r} vs {new_spec!r}"
137+
assert (
138+
legacy_detector == new_detector == "always.Pass"
139+
), f"both formats must select the same detector; got {legacy_detector!r} vs {new_detector!r}"

0 commit comments

Comments
 (0)