Skip to content

πŸ§ͺ Test gap analysis β€” 6 gaps found in compile/common.rs, compile/onees.rs, fuzzy_schedule.rsΒ #162

@github-actions

Description

@github-actions

Test Gap Analysis

Test suite snapshot: 658 total tests (605 unit + 36 compiler integration + 8 MCP HTTP + 9 proxy). All tests pass. Previous run (2026-04-10): 483 tests β€” 175 new tests were added but the gaps below remain open.

Priority Gaps

Module Function/Path Why It Matters Suggested Test
compile/common.rs replace_with_indent Core template substitution engine β€” bug here silently breaks indentation in all generated pipelines Multi-line replacement preserves caller's indent; replacement ending with \n; placeholder not at line start uses no indent
compile/common.rs format_step_yaml / format_step_yaml_indented Incorrect indentation in pipeline step YAML produces invalid ADO YAML Single-line step; multi-line step; --- prefix stripped correctly; custom base indent
compile/common.rs generate_acquire_ado_token Generates the AzureCLI@2 step for minting ADO tokens β€” wrong output means agents never receive a token Some(sc) produces correct task with service connection name embedded; None returns empty string
compile/common.rs generate_copilot_ado_env / generate_executor_ado_env Security-sensitive env block generation β€” omission or double-emission silently breaks token passing Present when SC configured; empty when None; read uses SC_READ_TOKEN, write uses SC_WRITE_TOKEN
compile/onees.rs generate_agent_context_root, generate_mcp_configuration, generate_inline_steps, generate_setup_job, generate_teardown_job 0 unit tests for all 5 internal functions; only tested end-to-end which doesn't catch subtle output regressions Root vs repo workspace mapping; MCP entry format; multi-step serialization
fuzzy_schedule.rs EveryHours with non-factor-of-24 interval The bail! path for every 5h, every 7h, every 0h is never exercised parse_fuzzy_schedule("every 5h") returns Err with message containing "Valid intervals"

Suggested Test Cases

1. replace_with_indent β€” multi-line replacement inherits indentation

#[test]
fn test_replace_with_indent_multiline_replacement() {
    let template = "steps:\n    \{\{ my_marker }}\n";
    let replacement = "- bash: echo hello\n  displayName: Hello";
    let result = replace_with_indent(template, "\{\{ my_marker }}", replacement);
    assert_eq!(result, "steps:\n    - bash: echo hello\n      displayName: Hello\n");
}

#[test]
fn test_replace_with_indent_not_at_line_start_no_indent() {
    let template = "prefix \{\{ marker }} suffix";
    let result = replace_with_indent(template, "\{\{ marker }}", "VALUE");
    assert_eq!(result, "prefix VALUE suffix");
}

2. format_step_yaml β€” YAML step serialization

#[test]
fn test_format_step_yaml_single_line() {
    let result = format_step_yaml("bash: echo hi");
    assert_eq!(result, "  - bash: echo hi");
}

#[test]
fn test_format_step_yaml_multiline() {
    let result = format_step_yaml("bash: |\n  echo hi\n  echo bye");
    let lines: Vec<&str> = result.lines().collect();
    assert_eq!(lines[0], "  - bash: |");
    assert_eq!(lines[1], "        echo hi");
    assert_eq!(lines[2], "        echo bye");
}

#[test]
fn test_format_step_yaml_strips_yaml_document_separator() {
    let result = format_step_yaml("--- bash: echo hi");
    assert_eq!(result, "  - bash: echo hi");
}

#[test]
fn test_format_step_yaml_indented_custom_base() {
    let result = format_step_yaml_indented("bash: echo hi", 6);
    assert_eq!(result, "      - bash: echo hi");
}

3. generate_acquire_ado_token β€” security-critical ADO token step

#[test]
fn test_generate_acquire_ado_token_with_sc() {
    let result = generate_acquire_ado_token(Some("my-arm-sc"), "SC_READ_TOKEN");
    assert!(result.contains("AzureCLI@2"));
    assert!(result.contains("azureSubscription: 'my-arm-sc'"));
    assert!(result.contains("variable=SC_READ_TOKEN;issecret=true"));
    assert!(result.contains("az account get-access-token"));
}

#[test]
fn test_generate_acquire_ado_token_none_returns_empty() {
    let result = generate_acquire_ado_token(None, "SC_READ_TOKEN");
    assert!(result.is_empty());
}

4. generate_copilot_ado_env / generate_executor_ado_env

#[test]
fn test_generate_copilot_ado_env_with_connection() {
    let result = generate_copilot_ado_env(Some("my-sc"));
    assert!(result.contains("AZURE_DEVOPS_EXT_PAT: $(SC_READ_TOKEN)"));
    assert!(result.contains("SYSTEM_ACCESSTOKEN: $(SC_READ_TOKEN)"));
}

#[test]
fn test_generate_copilot_ado_env_none_empty() {
    assert!(generate_copilot_ado_env(None).is_empty());
}

#[test]
fn test_generate_executor_ado_env_with_connection() {
    let result = generate_executor_ado_env(Some("my-sc"));
    assert!(result.contains("SYSTEM_ACCESSTOKEN: $(SC_WRITE_TOKEN)"));
    // Must NOT expose read token in executor env
    assert!(!result.contains("SC_READ_TOKEN"));
}

5. compile/onees.rs β€” internal helper unit tests

#[test]
fn test_generate_agent_context_root_repo() {
    assert_eq!(generate_agent_context_root("repo"), "$(Build.Repository.Name)");
}

#[test]
fn test_generate_agent_context_root_root() {
    assert_eq!(generate_agent_context_root("root"), ".");
}

#[test]
fn test_generate_mcp_configuration_skips_custom_mcp_with_command() {
    let mut mcps = HashMap::new();
    mcps.insert("my-tool".to_string(), McpConfig { command: Some("node".to_string()), ..Default::default() });
    let result = generate_mcp_configuration(&mcps);
    // Custom MCPs with command are not supported in 1ES target
    assert!(!result.contains("my-tool"));
}

6. fuzzy_schedule.rs β€” invalid hour interval error path

#[test]
fn test_parse_invalid_hour_interval_5h() {
    let err = parse_fuzzy_schedule("every 5h").unwrap_err();
    assert!(err.to_string().contains("Valid intervals"));
}

#[test]
fn test_parse_invalid_hour_interval_7h() {
    let err = parse_fuzzy_schedule("every 7h").unwrap_err();
    assert!(err.to_string().contains("not recommended"));
}

#[test]
fn test_parse_zero_hour_interval() {
    assert!(parse_fuzzy_schedule("every 0h").is_err());
}

Coverage Summary

Module Public Fns Unit Tests Gap
compile/common.rs 34 82 replace_with_indent, format_step_yaml*, generate_acquire_ado_token, generate_copilot_ado_env, generate_executor_ado_env untested
compile/onees.rs 0 pub / 5 internal 0 All internal functions untested
compile/standalone.rs 1 12 Covered via integration tests
fuzzy_schedule.rs 8 20 Invalid hour interval bail! path missing
sanitize.rs 1 32 Well covered βœ…
tools/* 14 tools 9–31 each Well covered βœ…

This issue was created by the automated test gap finder. Previous run: 2026-04-10. Current run: 2026-04-13. Modules audited this cycle: compile/common.rs, compile/onees.rs, compile/standalone.rs, fuzzy_schedule.rs, sanitize.rs, ndjson.rs, tools/*. Tests grew 483 β†’ 658 since last run; these 6 gaps remain unaddressed.

Generated by Test Gap Finder Β· ● 1.5M Β· β—·

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions