TheLarkInn / TheLarkInn/aipm

[coverage-improver] Cover init() no-op branch when no flags are set

Open
#1,663 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
9
Forks
3
Avg merge
2d 25m
Merged PRs (30d)
2

Description

Uncovered branch

  • File: crates/libaipm/src/workspace_init/mod.rs
  • Function: init()
  • Condition (line 208): if !any_created && any_found

Coverage data showed only the true side of this condition was ever exercised (5 hits), while the false side (reached when any_found is false, short-circuiting the &&) had 0 hits.

Test added

init_with_no_flags_produces_no_actions calls init() on a fresh temp directory with both workspace: false and marketplace: false (and no_starter/manifest also false). With no scaffolding requested, init() produces zero actions, so any_created and any_found are both false, driving execution through the previously-uncovered false branch of the condition, and asserts result.actions.is_empty().

Coverage before/after

  • Overall workspace branch coverage: 90.64% before and 90.64% after (no regression; target line 208 branches now show hits on both sides, confirming both paths executed).
  • workspace_init/mod.rs branch coverage: 93.01% (186 total branches, 13 uncovered) after the change.

Test code

#[test]
fn init_with_no_flags_produces_no_actions() {
    // Both `workspace` and `marketplace` disabled: init() should
    // produce zero actions, so `any_created` and `any_found` are both
    // false and the "found nothing to do" warn is skipped entirely
    // (distinct from the "everything already existed" case where
    // `any_found` is true).
    let (tmp, _guard) = make_temp_dir("no-flags");
    let adaptors = default_adaptors();
    let opts = Options {
        dir: &tmp,
        workspace: false,
        marketplace: false,
        no_starter: false,
        manifest: false,
        marketplace_name: "local-repo-plugins",
        engines_scaffold: libaipm_engine_spec::EngineSet::CLAUDE,
        engines_support: None,
    };
    let result = init(&opts, &adaptors, &crate::fs::Real);
    assert!(result.is_ok_and(|r| r.actions.is_empty()));

    cleanup(&tmp);
}

Verified locally: cargo build --workspace, cargo test --workspace, cargo clippy --workspace -- -D warnings (2 pre-existing unrelated pedantic lint failures in resolver/mod.rs/security.rs confirmed present on main without this change), and cargo fmt --check all pass for the touched file.

Generated by Coverage Improver · auto · 563.7 AIC · ⌖ 7.31 AIC · ⊞ 13.1K ·


[!NOTE]
This was originally intended as a pull request, but PR creation failed. The changes have been pushed to the branch coverage-improver/init-no-flags-branch-72a74a2a378556af.

Original error: ERR_API: [2026-08-22T05:07:54.622Z] create pull request in TheLarkInn/aipm failed (attempt 1)

Original error: Resource not accessible by personal access token - https://docs.github.com/rest/pulls/pulls#create-a-pull-request
Retryable: false
Suggestion: This error cannot be resolved by retrying. Please check the error details and fix the underlying issue.

To create the pull request manually:

gh pr create --title "[coverage-improver] Cover init() no-op branch when no flags are set" --base main --head coverage-improver/init-no-flags-branch-72a74a2a378556af --repo TheLarkInn/aipm
Show patch preview (56 of 56 lines)
From 4a6e237b7a848bcab24d49cd53ce790f60d6be24 Mon Sep 17 00:00:00 2001
X-GH-AW-Base-Commit: 6d3368da0e97be67cb075dba37b9b384df816358
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Sat, 22 Aug 2026 05:04:29 +0000
Subject: [PATCH] test(workspace_init): cover no-op init() branch when no flags
 set

Adds a test exercising init() with workspace=false and marketplace=false,
which reaches the false branch of `if !any_created && any_found` at
workspace_init/mod.rs:208 (previously only the true branch was hit).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 crates/libaipm/src/workspace_init/mod.rs | 25 ++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/crates/libaipm/src/workspace_init/mod.rs b/crates/libaipm/src/workspace_init/mod.rs
index 17715cb..28f2818 100644
--- a/crates/libaipm/src/workspace_init/mod.rs
+++ b/crates/libaipm/src/workspace_init/mod.rs
@@ -717,6 +717,31 @@ mod tests {
         cleanup(&tmp);
     }
 
+    #[test]
+    fn init_with_no_flags_produces_no_actions() {
+        // Both `workspace` and `marketplace` disabled: init() should
+        // produce zero actions, so `any_created` and `any_found` are both
+        // false and the "found nothing to do" warn is skipped entirely
+        // (distinct from the "everything already existed" case where
+        // `any_found` is true).
+        let (tmp, _guard) = make_temp_dir("no-flags");
+        let adaptors = default_adaptors();
+        let opts = Options {
+            dir: &tmp,
+            workspace: false,
+            marketplace: false,
+            no_starter: false,
+            manifest: false,
+            marketplace_name: "local-repo-plugins",
+            engines_scaffold: libaipm_engine_spec::EngineSet::CLAUDE,
+            engines_support: None,
+        };
+        let result = init(&opts, &adaptors, &crate::fs::Real);
+        assert!(result.is_ok_and(|r| r.actions.is_empty()));
+
+        cleanup(&tmp
... (truncated)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read crates/libaipm/src/workspace_init/mod.rs, especially init() and its existing tests. Run init_with_no_flags_produces_no_actions and the workspace test suite to confirm a fresh directory with all flags disabled returns no actions and covers both sides of the target condition.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing-qa
Issue type
Feature
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.