Skip to content

Expand TestCommand test coverage: timeout, failure, and sub-package paths #32

@tsavo-at-pieces

Description

@tsavo-at-pieces

Context

PR #29 added test_command_test.dart with 3 tests covering:

  • No test/ directory → skip
  • Log directory resolution
  • Full passing test flow → results.json + summary

And cli_utils_test.dart with comprehensive coverage of:

  • resolveTestLogDir (6 tests)
  • Filesystem safety (5 tests)
  • parseTestResultsJson (8 tests including edge cases)
  • writeTestJobSummary (7 tests including escaping, truncation, backticks)
  • StepSummary.write byte guard + collapsible content escaping

Gaps to fill

TestCommand paths not yet tested:

  • Process timeout → _killAndAwaitExit invoked (difficult: requires slow child process)
  • Failing root tests → exit code propagation + failure summary
  • Sub-package with missing pubspec → failure recorded
  • Sub-package pub get timeout → _runPubGetWithTimeout returns null
  • Sub-package test failure → accumulated in failures list
  • Multiple sub-packages with mixed pass/fail → correct summary

Design constraint: TestCommand spawns real dart test processes, making pure unit tests difficult. Options:

  1. Extract orchestration into testable function with injectable process spawner
  2. Integration tests with synthetic Dart packages (current approach for the 3 existing tests)
  3. Accept current coverage as sufficient for CI-only code

Priority

P3 — the existing tests cover the critical paths (parsing, summary generation, log dir resolution). The untested paths are process management edge cases that are hard to trigger reliably in tests.

Identified during PR #29 review.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions