Skip to content

fix: Support cargo build --tests by skipping test artifacts#239

Open
jssblck wants to merge 15 commits into
mainfrom
jess/fix/tests-on-234
Open

fix: Support cargo build --tests by skipping test artifacts#239
jssblck wants to merge 15 commits into
mainfrom
jess/fix/tests-on-234

Conversation

@jssblck
Copy link
Copy Markdown
Contributor

@jssblck jssblck commented Nov 21, 2025

Summary

Resolves #196.

This PR fixes a crash when running hurry cargo build --tests by explicitly handling and skipping TargetKind::Test artifacts in the build plan.

Context

The crash occurred because hurry encountered an unhandled TargetKind::Test when analyzing the build plan. These artifacts represent the final test binaries (first-party code), which we do not want to cache.

By simply skipping these test artifacts (treating them like TargetKind::Bin), we allow hurry to proceed and correctly process and cache the third-party dependencies that these tests rely on.

Validation

We confirmed that dependencies appear as separate TargetKind::Lib invocations in the build plan, while the test binary itself is TargetKind::Test.

Build Plan Snippet:
(Generated with RUSTC_BOOTSTRAP=1 cargo build --tests --build-plan -Z unstable-options)

{
  "package_name": "serde",
  "target_kind": ["lib"]
},
{
  "package_name": "hurry",
  "target_kind": ["test"]
}

Data Flow

The following diagram demonstrates how hurry processes the build plan, skipping the test binary but capturing its dependencies:

graph TD
    subgraph Cargo["Cargo Build Plan Generation"]
        A["Run: cargo build --tests --build-plan"] --> B{Build Plan Invocations}
        B --> C["Invocation 1: serde (Lib)"]
        B --> D["Invocation 2: tokio (Lib)"]
        B --> E["Invocation 3: my-app (Test Binary)"]
    end

    subgraph Hurry["Hurry Processing Loop (workspace.rs)"]
        F[Start Loop over Invocations] --> G{Check TargetKind}
        
        G -- "TargetKind::Lib / RLib" --> H[Process Dependency]
        H --> I[Create UnitPlan]
        I --> J[Cache/Restore Enabled]
        
        G -- "TargetKind::Bin" --> K["Skip (First-Party)"]
        K --> L[Continue Loop]
        
        G -- "TargetKind::Test" --> M["Skip (First-Party)"]
        M --> N[Continue Loop]
        
        G -- "Other" --> O["Error / Handle"]
    end

    C --> G
    D --> G
    E --> G

    style J fill:#bbf,stroke:#333,stroke-width:2px
    style M fill:#bfb,stroke:#333,stroke-width:2px
    style K fill:#bfb,stroke:#333,stroke-width:2px
Loading

Areas of Interest

  • Workspace Logic: packages/hurry/src/cargo/workspace.rs - Added TargetKind::Test to the skip condition in the units() method. This ensures test binaries are treated as first-party code (like TargetKind::Bin) and ignored, preventing the "unsupported target kind" error.

Testing

  • Manual Verification: Run hurry cargo build --tests --hurry-skip-restore (or with valid credentials) to verify that the build completes successfully without crashing.

Verification Output

$ cargo run --bin hurry -- cargo build --hurry-skip-restore --tests
...
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 5.44s
Exit code: 0

Code Map

🤖 Generated with Antigravity

@jssblck jssblck requested review from Copilot and elldritch and removed request for Copilot November 21, 2025 20:08
@jssblck jssblck marked this pull request as ready for review November 21, 2025 20:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a crash when running hurry cargo build --tests by adding support for test artifacts in the build plan processing logic. The fix treats test binaries as first-party code (similar to regular binaries) and skips them during caching operations, while still processing their third-party dependencies.

Key changes:

  • Extended the skip condition in workspace.rs to handle TargetKind::Test artifacts alongside TargetKind::Bin
  • Updated the associated comment to reflect that both binaries and tests are first-party code

Base automatically changed from eliza/feat/fingerprint-rewriting to main November 24, 2025 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants