Skip to content

Add test coverage for main.rs pipeline orchestration #30

@codesoda

Description

@codesoda

Summary

main.rs contains the bulk pipeline orchestration — run_single_test_file, run_all_test_files, run_discovered_file — with critical error handling, multi-file summary, and teardown logic, but these functions have zero test coverage. The existing integration test re-implements the pipeline rather than calling these functions.

Severity: S2 (Medium) | Confidence: 0.90 | Blast radius: Medium — regressions in the most user-facing code path go undetected.

Technical Details

Untested orchestration functions in src/main.rs:

Function Lines What it does
run_single_test_file 158-580 Full single-file pipeline: config load → commands → execution → report
run_all_test_files 587-670 Multi-file orchestration with summary aggregation
run_discovered_file 679-780 Discovery-mode wrapper with glob matching

What is currently tested:

  • src/main.rs lines 810-946: 10 tests, but they only cover CLI argument parsing via Cli::parse_from
  • tests/pipeline_integration.rs: Tests individual phases (command execution, step execution) using a mock provider, but does not call run_single_test_file or run_all_test_files

What's at risk without coverage:

  • Error handling and graceful degradation when commands fail mid-pipeline
  • Multi-file summary aggregation logic (exit code selection, report merging)
  • Best-effort teardown ordering (processes killed in correct order on failure)
  • Config validation + merge logic in the orchestration path
  • Edge cases: empty test files, all steps skipped, provider init failure

Proposed Fix

  1. Refactor for testability: Extract an AgentSessionFactory trait or closure parameter so run_single_test_file can accept a mock provider:

    pub fn run_single_test_file(
        config: &Config,
        test_file: &TestFile,
        session_factory: impl Fn(&Config) -> Box<dyn AgentSession>,
        // ...
    ) -> Result<RunResult, PipelineError>
  2. Write integration tests that call run_single_test_file directly:

    • Happy path: all steps pass
    • Command failure: short-lived command exits non-zero
    • Provider failure: session init returns error
    • Partial success: some steps pass, some fail
    • Teardown verification: long-lived processes are cleaned up
  3. Write a multi-file test for run_all_test_files:

    • Two test files, one passes, one fails → verify correct exit code and summary

Estimated effort: 1-2 days

Related

  • Related to F9: shared test infrastructure needed first
  • Part of refactor Bundle 8: Orchestration Test Coverage

🔍 Found by vibe-code-audit — automated codebase audit skill for Claude Code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    auditFound via automated code auditenhancementNew feature or requesttestingTest coverage and test infrastructure

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions