Skip to content

feat: add cwm ws test and cwm ws test-result - #19

Merged
HansRobo merged 1 commit into
mainfrom
feat/ws-test
Jun 2, 2026
Merged

HansRobo merged 1 commit into
mainfrom
feat/ws-test

Conversation

@HansRobo

@HansRobo HansRobo commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary

Adds diff-based testing symmetric with cwm ws build (roadmap R5, → v6.2.0).

  • cwm ws test [-w BRANCH] [--dry-run] [--no-rdeps] — runs colcon test on the change set (changed packages + their ABI reverse deps). The activate path inherits the environment; -w sources underlay+overlay so an overlay worktree can be tested without a missing-package.sh failure.
  • cwm ws test-result [-w BRANCH] — runs colcon test-result --all --return-code-on-test-failure so agents/CI get a meaningful exit code (plain colcon test exits 0 even when tests fail).

Motivation

Running colcon test in an overlay worktree alone fails because the underlay isn't sourced (review §3.2), and the passthrough cwm test requires activation and doesn't source the underlay. ws test resolves both by mirroring ws build's sourcing behaviour.

Decisions confirmed up front: test target = changed + ABI reverse deps (narrow with --no-rdeps); failure detection kept as a separate ws test-result step.

Shared infrastructure

  • Extracted resolve_worktree + a run_workspace_colcon orchestration helper into cwm/cli/_workspace.py, used by both ws build and ws test, so the scan → detect → dry-run → run flow lives in one place.
  • Added ColconDiscoveryController.generate_test_args (--packages-select only — test has no --allow-overriding/--symlink-install).
  • Added run_colcon_test_result; execution reuses the generic run_colcon / run_colcon_sourced (already parameterised over the subcommand).

Test plan

  • uv run python -m pytest tests/ → all green (new tests/unit/test_test_cmd.py covers dry-run, activate path, -w sourced path, no-changes, --no-rdeps, and test-result exit-code propagation; test_cdc.py / test_colcon_runner.py / test_cli_structure.py updated).
  • cwm ws --help lists build / test / test-result / clean / status.

…uild)

Add diff-based testing that mirrors `cwm ws build`:

- `cwm ws test [-w BRANCH] [--dry-run] [--no-rdeps]`: runs `colcon test` on
  the change set (changed packages + their ABI reverse deps). The activate
  path inherits the environment; `-w` sources underlay+overlay so an overlay
  worktree can be tested without a missing-`package.sh` failure.
- `cwm ws test-result [-w BRANCH]`: runs
  `colcon test-result --all --return-code-on-test-failure` so agents/CI get a
  meaningful exit code (plain `colcon test` exits 0 even on test failures).

Shared infrastructure:

- Extract `resolve_worktree` and a `run_workspace_colcon` orchestration helper
  into `cwm/cli/_workspace.py`, used by both `ws build` and `ws test` so the
  scan/detect/dry-run/run flow lives in one place.
- Add `ColconDiscoveryController.generate_test_args` (`--packages-select` only;
  test has no `--allow-overriding`/`--symlink-install`).
- Add `run_colcon_test_result`; reuse the generic `run_colcon` /
  `run_colcon_sourced` (parameterised over the subcommand) for execution.
@HansRobo HansRobo added the release:minor Bump minor version on merge label Jun 2, 2026
@HansRobo
HansRobo merged commit 37f6f8a into main Jun 2, 2026
11 of 12 checks passed
@HansRobo
HansRobo deleted the feat/ws-test branch June 2, 2026 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:minor Bump minor version on merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant