[Test Improver] test: add unit tests for compile command logic (38% -> ~50%)#859
Draft
danielmeppiel wants to merge 1 commit intomainfrom
Draft
Conversation
…ate mode, early exits) - Tests for _resolve_compile_target: all target resolution paths (None, single string passthrough, list with claude-only, agents-family, mixed -> all) - Tests for _get_validation_suggestion: covers Missing description, applyTo, empty content, and unknown-error fallback cases - CLI integration tests for early-exit paths: no apm.yml, no content, empty .apm/ - CLI integration tests for --validate mode: success, failure, and exception paths - CLI integration test for --dry-run suppressing the no-content early exit Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🔒 Supply Chain Security Review — PASSReviewed
No required fixes, no suggestions. Clean from a supply-chain security perspective.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Test Improver - automated AI assistant for improving test coverage.
Goal and Rationale
src/apm_cli/commands/compile/cli.py(622 lines) was at ~38% coverage. This PR adds focused unit tests for:_resolve_compile_target- A pure function mapping CLI target inputs to compiler-understood strings. This function handles the logic for multi-target lists (["claude", "copilot"]→"all") and is called on everyapm compileinvocation._get_validation_suggestion- A pure helper providing actionable error messages during--validatemode.compileCLI early-exit paths - Validates the guard rails that prevent compilation on invalid project states (noapm.yml, no content, empty.apm/).--validatemode - Tests the validation-only code path including success, validation errors, and exception handling.--dry-runsuppression of the no-content early exit (enabling preview in empty projects).These paths were completely untested despite being exercised on every
apm compilecall.Approach
_resolve_compile_target,_get_validation_suggestion) tested directly with no mocking needed.CliRunnerwithisolated_filesystem()to avoid filesystem side effects.AgentsCompileranddiscover_primitivesare mocked to isolate the CLI dispatch logic from compilation internals.Coverage Impact
commands/compile/cli.pyTest Status
All 18 new tests pass. Full unit suite (5173 tests) passes:
Note:
test_policy_status.pyhas one pre-existing failure (unrelated to this PR — the_ascii_onlycheck conflicts with ANSI codes in Rich's table output) and is ignored for baseline comparison.Trade-offs
--validatemockdiscover_primitivesandAgentsCompilerto stay fast and deterministic.--dry-runtest exercises the path broadly rather than asserting specific output since the distributed/single-file fork has many state combinations.Reproducibility