Skip to content

Commit 6e1734e

Browse files
test(bash-lint): cover --debug-pipeline bash generator via compile_fixture_with_flags (#525)
Add coverage for the 'Verify MCP backends' bash step emitted by generate_debug_pipeline_replacements(true) in src/compile/common.rs. This step is only reachable via the --debug-pipeline CLI flag and was previously never shellchecked by any fixture. Changes: - Refactor compile_fixture into compile_fixture_with_flags (takes extra CLI args) plus a compile_fixture wrapper for the common case. - After the normal fixture loop, compile minimal-agent.md with --debug-pipeline and shellcheck its bash bodies. - Add 'Verify MCP backends' to REQUIRED_STEP_DISPLAY_NAMES so that if the generator is removed or renamed the test fails loudly. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f311d36 commit 6e1734e

1 file changed

Lines changed: 41 additions & 5 deletions

File tree

tests/bash_lint_tests.rs

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ const REQUIRED_STEP_DISPLAY_NAMES: &[&str] = &[
102102
"Initialize empty agent memory (clearMemory=true)",
103103
"Generate GITHUB_PATH file", // src/compile/common.rs (AWF path step)
104104
"Evaluate pipeline filters", // src/compile/extensions/trigger_filters.rs + src/compile/filter_ir.rs
105+
"Verify MCP backends", // src/compile/common.rs (--debug-pipeline only)
105106
];
106107

107108
fn ado_aw_binary() -> PathBuf {
@@ -137,16 +138,22 @@ fn fresh_workspace() -> TempDir {
137138
}
138139

139140
/// Compile a fixture by copying it into `workspace` and invoking
140-
/// `ado-aw compile`. Returns the path to the generated `.lock.yml` and the
141-
/// target (`"standalone"` or `"1es"`) reported in compiler stdout.
142-
fn compile_fixture(workspace: &Path, fixture: &str) -> (PathBuf, String) {
141+
/// `ado-aw compile [extra_flags]`. Returns the path to the generated
142+
/// `.lock.yml` and the target (`"standalone"` or `"1es"`) reported in
143+
/// compiler stdout. The `extra_flags` slice is appended after the file path,
144+
/// allowing callers to enable modes like `--debug-pipeline` that cannot be
145+
/// expressed in front matter.
146+
fn compile_fixture_with_flags(workspace: &Path, fixture: &str, extra_flags: &[&str]) -> (PathBuf, String) {
143147
let src = fixtures_dir().join(fixture);
144148
let dest = workspace.join(fixture);
145149
std::fs::copy(&src, &dest)
146150
.unwrap_or_else(|e| panic!("copy fixture {fixture}: {e}"));
147151

152+
let mut args = vec!["compile", dest.to_str().unwrap()];
153+
args.extend_from_slice(extra_flags);
154+
148155
let output = Command::new(ado_aw_binary())
149-
.args(["compile", dest.to_str().unwrap()])
156+
.args(&args)
150157
.current_dir(workspace)
151158
.output()
152159
.unwrap_or_else(|e| panic!("spawn ado-aw compile: {e}"));
@@ -176,7 +183,13 @@ fn compile_fixture(workspace: &Path, fixture: &str) -> (PathBuf, String) {
176183
(lock, target.to_string())
177184
}
178185

179-
/// A single bash body extracted from a compiled pipeline.
186+
/// Convenience wrapper around `compile_fixture_with_flags` for the common
187+
/// case where no extra CLI flags are needed.
188+
fn compile_fixture(workspace: &Path, fixture: &str) -> (PathBuf, String) {
189+
compile_fixture_with_flags(workspace, fixture, &[])
190+
}
191+
192+
180193
struct BashBody {
181194
display_name: String,
182195
body: String,
@@ -329,6 +342,29 @@ fn compiled_bash_bodies_pass_shellcheck() {
329342
}
330343
}
331344

345+
// Debug-pipeline coverage — compile one fixture with `--debug-pipeline` to
346+
// exercise the `generate_debug_pipeline_replacements(true)` path in
347+
// `src/compile/common.rs`, which emits the "Verify MCP backends" bash body.
348+
// This code path is unreachable via front matter alone.
349+
{
350+
let debug_fixture = "minimal-agent.md";
351+
let debug_label = "minimal-agent.md (--debug-pipeline)";
352+
let (lock, _) =
353+
compile_fixture_with_flags(workspace.path(), debug_fixture, &["--debug-pipeline"]);
354+
for body in extract_bash_bodies(&lock) {
355+
all_display_names.push(body.display_name.clone());
356+
let findings = run_shellcheck(&body.body);
357+
if let Some(arr) = findings.as_array() {
358+
for finding in arr {
359+
report
360+
.entry(debug_label.to_string())
361+
.or_default()
362+
.push(format_finding(debug_label, &body.display_name, finding));
363+
}
364+
}
365+
}
366+
}
367+
332368
// Target coverage — assert that every known compile target is exercised by
333369
// at least one fixture, so we shellcheck the bash output of every template
334370
// (`src/data/base.yml` and `src/data/1es-base.yml`) and every code-generated

0 commit comments

Comments
 (0)