Skip to content

Commit 79931cf

Browse files
test: reduce and improve tests in compiler_tests.rs (section 6) (#1480)
- Remove test_pipeline_filter_compiled_output_is_valid_yaml (vacuous: compile+valid_yaml only); merge assert_valid_yaml into the richer test_pipeline_filter_has_resources_and_gate. - Remove test_execution_context_pr_compiled_output_is_valid_yaml (same vacuous pattern); add assert_valid_yaml to the richer test_execution_context_pr_emits_prepare_step_and_prompt_supplement. - Rewrite test_pr_filter_tier1_has_native_pr_trigger: the previous contains("pr:") matched pr: none (wouldn't detect a regression that disables the trigger), and contains("main") matched anywhere in the output rather than the branches include list. Replace with !contains("pr: none"), contains("pr:\n"), and contains(" - main"). 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 edcb4a7 commit 79931cf

1 file changed

Lines changed: 19 additions & 20 deletions

File tree

tests/compiler_tests.rs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4832,17 +4832,11 @@ fn test_pr_filter_tier2_has_extension_gate() {
48324832
assert!(compiled.contains("name: prGate"), "Should have prGate step");
48334833
}
48344834

4835-
/// Pipeline filter fixture produces valid YAML.
4836-
#[test]
4837-
fn test_pipeline_filter_compiled_output_is_valid_yaml() {
4838-
let compiled = compile_fixture("pipeline-filter-agent.md");
4839-
assert_valid_yaml(&compiled, "pipeline-filter-agent.md");
4840-
}
4841-
4842-
/// Pipeline filter fixture produces correct pipeline resource + gate.
4835+
/// Pipeline filter fixture produces valid YAML and correct pipeline resource + gate.
48434836
#[test]
48444837
fn test_pipeline_filter_has_resources_and_gate() {
48454838
let compiled = compile_fixture("pipeline-filter-agent.md");
4839+
assert_valid_yaml(&compiled, "pipeline-filter-agent.md");
48464840

48474841
assert!(
48484842
compiled.contains("pipelines:"),
@@ -5050,13 +5044,26 @@ fn test_pr_filter_synth_mode_gate_step_uses_same_job_synth_ref() {
50505044
#[test]
50515045
fn test_pr_filter_tier1_has_native_pr_trigger() {
50525046
let compiled = compile_fixture("pr-filter-tier1-agent.md");
5053-
5054-
assert!(compiled.contains("pr:"), "Should have native pr: block");
5047+
assert_valid_yaml(&compiled, "pr-filter-tier1-agent.md");
5048+
// The native PR trigger block must be emitted — `pr: none` would disable it.
5049+
assert!(
5050+
!compiled.contains("pr: none"),
5051+
"Should not disable PR trigger — fixture has native pr branches filter"
5052+
);
5053+
assert!(
5054+
compiled.contains("pr:\n"),
5055+
"Should have native pr: block (not `pr: none`)"
5056+
);
50555057
assert!(
50565058
compiled.contains("branches:"),
50575059
"Should have branches filter"
50585060
);
5059-
assert!(compiled.contains("main"), "Should include main branch");
5061+
// "main" must appear as an indented list item inside the branches block,
5062+
// not just anywhere in the compiled output (comments, other fields, etc.).
5063+
assert!(
5064+
compiled.contains(" - main"),
5065+
"Should include main as an indented list item in the branches include block"
5066+
);
50605067
}
50615068

50625069
/// Extension gate steps are correctly nested inside the Setup job's steps: block.
@@ -5951,15 +5958,6 @@ fn test_job_target_with_setup_emits_dual_branch_dependson_with_each() {
59515958
// Execution-context extension (issue #860)
59525959
// ============================================================================
59535960

5954-
/// The execution-context extension is always-on and emits an `aw-context`
5955-
/// prepare step on PR-triggered agents. This sanity check makes sure the
5956-
/// generated YAML round-trips through `serde_yaml`.
5957-
#[test]
5958-
fn test_execution_context_pr_compiled_output_is_valid_yaml() {
5959-
let compiled = compile_fixture("execution-context-agent.md");
5960-
assert_valid_yaml(&compiled, "execution-context-agent.md");
5961-
}
5962-
59635961
/// Spot-checks the key components of the precompute step. v7 ports
59645962
/// the precompute logic to an `ado-script` bundle
59655963
/// (`exec-context-pr.js`), so the bash step is now a slim node
@@ -5971,6 +5969,7 @@ fn test_execution_context_pr_compiled_output_is_valid_yaml() {
59715969
#[test]
59725970
fn test_execution_context_pr_emits_prepare_step_and_prompt_supplement() {
59735971
let compiled = compile_fixture("execution-context-agent.md");
5972+
assert_valid_yaml(&compiled, "execution-context-agent.md");
59745973

59755974
assert!(
59765975
compiled.contains("Stage PR execution context (aw-context/pr/*)"),

0 commit comments

Comments
 (0)