Skip to content

Commit 14a7f7c

Browse files
test: reduce and improve tests in compiler_tests.rs (section 3) (#1448)
- Remove test_network_allow_trailing_wildcard_fails: duplicate of test_network_allow_mid_wildcard_fails — both test the same !host.starts_with("*.") branch in validate_dns_domain with inputs that produce the same error path and message. - Rewrite test_parameters_no_unreplaced_markers → renamed to test_parameters_coexist_with_cache_memory_clear_memory: the original only asserted no unreplaced markers (a meta-property of compilation). The rewrite adds meaningful assertions that the user-defined param (myParam) and the auto-injected clearMemory param both appear exactly once in the output, making it a real regression guard for the parameters + cache-memory combination. 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 ded336a commit 14a7f7c

1 file changed

Lines changed: 35 additions & 53 deletions

File tree

tests/compiler_tests.rs

Lines changed: 35 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,9 +2217,14 @@ Do the thing.
22172217
let _ = fs::remove_dir_all(&temp_dir);
22182218
}
22192219

2220-
/// Test that parameters block has no unreplaced markers
2220+
/// Test that user-defined parameters and cache-memory auto-injected clearMemory coexist
2221+
///
2222+
/// Verifies that when a pipeline defines its own parameters AND cache-memory, the
2223+
/// compiled output contains both the user-defined parameter and the auto-injected
2224+
/// `clearMemory` parameter without either clobbering the other. Also guards that
2225+
/// no unreplaced `{{ }}` markers remain after compilation.
22212226
#[test]
2222-
fn test_parameters_no_unreplaced_markers() {
2227+
fn test_parameters_coexist_with_cache_memory_clear_memory() {
22232228
let temp_dir = std::env::temp_dir().join(format!(
22242229
"agentic-pipeline-params-markers-{}",
22252230
std::process::id()
@@ -2228,7 +2233,7 @@ fn test_parameters_no_unreplaced_markers() {
22282233

22292234
let input = r#"---
22302235
name: "Markers Agent"
2231-
description: "Tests no unreplaced markers with parameters"
2236+
description: "Tests user param + cache-memory clearMemory coexistence"
22322237
parameters:
22332238
- name: myParam
22342239
type: string
@@ -2265,7 +2270,33 @@ tools:
22652270

22662271
let compiled = fs::read_to_string(&output_path).unwrap();
22672272

2268-
// Verify no unreplaced {{ markers }} remain (excluding ${{ }} which are ADO expressions)
2273+
// User-defined parameter must be present
2274+
assert!(
2275+
compiled.contains("name: myParam"),
2276+
"Should contain user-defined 'myParam' parameter"
2277+
);
2278+
assert!(
2279+
compiled.contains("default: hello"),
2280+
"Should contain user-defined default value"
2281+
);
2282+
2283+
// cache-memory must auto-inject clearMemory alongside the user param
2284+
assert!(
2285+
compiled.contains("name: clearMemory"),
2286+
"Should auto-inject clearMemory parameter when cache-memory is enabled"
2287+
);
2288+
assert!(
2289+
compiled.contains("displayName: Clear agent memory"),
2290+
"clearMemory should carry the standard displayName"
2291+
);
2292+
2293+
// Neither parameter should shadow the other — both must appear
2294+
let param_count = compiled.matches("name: myParam").count();
2295+
assert_eq!(param_count, 1, "myParam should appear exactly once");
2296+
let clear_count = compiled.matches("name: clearMemory").count();
2297+
assert_eq!(clear_count, 1, "clearMemory should appear exactly once");
2298+
2299+
// No unreplaced {{ markers }} should remain (excluding ${{ }} ADO expressions)
22692300
for line in compiled.lines() {
22702301
let stripped = line.replace("${{", "");
22712302
assert!(
@@ -2333,55 +2364,6 @@ network:
23332364
let _ = fs::remove_dir_all(&temp_dir);
23342365
}
23352366

2336-
/// Test that network.allowed with a trailing wildcard (example.*) fails compilation
2337-
#[test]
2338-
fn test_network_allow_trailing_wildcard_fails() {
2339-
let temp_dir = std::env::temp_dir().join(format!(
2340-
"agentic-pipeline-network-trailing-wildcard-{}",
2341-
std::process::id()
2342-
));
2343-
fs::create_dir_all(&temp_dir).expect("Failed to create temp directory");
2344-
2345-
let input = r#"---
2346-
name: "Network Trailing Wildcard Agent"
2347-
description: "Agent with trailing wildcard in network.allowed"
2348-
network:
2349-
allowed:
2350-
- "example.*"
2351-
---
2352-
2353-
## Test
2354-
"#;
2355-
2356-
let input_path = temp_dir.join("network-trailing-wildcard.md");
2357-
let output_path = temp_dir.join("network-trailing-wildcard.yml");
2358-
fs::write(&input_path, input).unwrap();
2359-
2360-
let binary_path = PathBuf::from(env!("CARGO_BIN_EXE_ado-aw"));
2361-
let output = std::process::Command::new(&binary_path)
2362-
.args([
2363-
"compile",
2364-
input_path.to_str().unwrap(),
2365-
"-o",
2366-
output_path.to_str().unwrap(),
2367-
])
2368-
.output()
2369-
.expect("Failed to run compiler");
2370-
2371-
assert!(
2372-
!output.status.success(),
2373-
"Compiler should fail for trailing wildcard 'example.*'"
2374-
);
2375-
2376-
let stderr = String::from_utf8_lossy(&output.stderr);
2377-
assert!(
2378-
stderr.contains("unsupported position"),
2379-
"Error message should mention unsupported position: {stderr}"
2380-
);
2381-
2382-
let _ = fs::remove_dir_all(&temp_dir);
2383-
}
2384-
23852367
/// Test that network.allowed with a mid-string wildcard (ex*ample.com) fails compilation
23862368
#[test]
23872369
fn test_network_allow_mid_wildcard_fails() {

0 commit comments

Comments
 (0)