Skip to content

fix(cargo-gamma): support binary-only package selections - #241

Open
chinayangxiaowei wants to merge 3 commits into
microsoft:mainfrom
chinayangxiaowei:fix/cargo-gamma-binary-mixed-workspaces
Open

chinayangxiaowei wants to merge 3 commits into
microsoft:mainfrom
chinayangxiaowei:fix/cargo-gamma-binary-mixed-workspaces

Conversation

@chinayangxiaowei

@chinayangxiaowei chinayangxiaowei commented Oct 10, 2026 •

Copy link
Copy Markdown

Problem

cargo gamma run cannot complete when every selected package has only binary targets. Schema convergence always runs cargo check --lib --bins --tests; Cargo rejects --lib with no library targets found in package before any mutant can be measured. A mixed selection containing at least one library package already works with those selectors.

Change

  • Omit --lib when every selected package is binary-only.
  • Retain the existing --lib --bins --tests command for mixed selections. No manifest or source rewrite is needed.
  • Cover binary-only and mixed selections, including a library without a test harness. Update the design and CLI documentation.

Validation

  • cargo fmt --all -- --check passed.
  • A direct Cargo 1.97.1 check of a two-member fixture confirmed that --lib --bins --tests --workspace succeeds, while selecting only its binary package fails with no library targets found.
  • On macOS 15.7.2, the new convergence and end-to-end session tests passed with the macOS process cleanup changes from fix(cargo-gamma): handle macOS process group cleanup and CLI builds #240 applied. The convergence test fails on the unmodified upstream base at the existing macOS process cleanup assertion addressed by fix(cargo-gamma): handle macOS process group cleanup and CLI builds #240.
  • End-to-end macOS tests used TMPDIR=/private/tmp to avoid the host /var to /private/var path alias in the existing scratch-directory check.
  • crates/cargo-gamma-lib/docs/design/system-tests.md designates the existing tests/session.rs cases as real-toolchain acceptance tests. The two new session cases intentionally exercise Cargo's target-selector acceptance and feature unification; scripted command responses cannot establish those properties.

This PR contains only the binary-only selection fix and a mixed-workspace regression test. It does not include #240.

Copilot AI balanced review requested due to automatic review settings October 10, 2026 20:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The rollback regression test does not verify that installation reaches the intended second-package failure.

1 open finding
What changed in this PR

Fixes schema convergence for binary-only and mixed Cargo workspaces.

Changes:

  • Selects convergence targets based on library availability.
  • Adds and restores temporary library targets for mixed workspaces.
  • Adds regression tests and updates design documentation.
File Description
crates/​cargo-gamma/​README.md Documents binary-only workspace support.
crates/​cargo-gamma/​docs/​DESIGN.md Describes mixed-workspace convergence.
crates/​cargo-gamma-lib/​tests/​session.rs Adds end-to-end workspace tests.
crates/​cargo-gamma-lib/​src/​exec/​measure.rs Passes library metadata to convergence.
crates/​cargo-gamma-lib/​src/​exec/​build/​tests.rs Tests temporary-library behavior.
crates/​cargo-gamma-lib/​src/​exec/​build/​temporary_libraries.rs Implements temporary targets and restoration.
crates/​cargo-gamma-lib/​src/​exec/​build.rs Selects commands and temporary targets.
crates/​cargo-gamma-lib/​src/​discover/​survey.rs Records packages with libraries.
crates/​cargo-gamma-lib/​docs/​IMPLEMENTATION.md Documents implementation details.
crates/​cargo-gamma-lib/​docs/​DESIGN.md Updates the convergence contract.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/cargo-gamma-lib/src/exec/build/tests.rs Outdated
Copilot AI balanced review requested due to automatic review settings October 10, 2026 20:29
@chinayangxiaowei
chinayangxiaowei force-pushed the fix/cargo-gamma-binary-mixed-workspaces branch from a47f1e8 to 2ffd814 Compare October 10, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Synthetic libraries can fail valid workspaces that deny unused dependency warnings.

2 open findings
1 resolved since last review

🧠 Review effort: Balanced

Comment thread crates/cargo-gamma-lib/src/exec/build/temporary_libraries.rs Outdated
Comment thread crates/cargo-gamma-lib/tests/session.rs
Copilot AI balanced review requested due to automatic review settings October 10, 2026 20:38
@chinayangxiaowei
chinayangxiaowei force-pushed the fix/cargo-gamma-binary-mixed-workspaces branch from 2ffd814 to 8072038 Compare October 10, 2026 20:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The selector logic, failure-safe restoration, metadata plumbing, documentation, and regression coverage are consistent and complete.

2 open findings

🧠 Review effort: Balanced

Comment thread crates/cargo-gamma-lib/src/exec/build.rs Outdated
Copilot AI balanced review requested due to automatic review settings October 10, 2026 20:46
@chinayangxiaowei
chinayangxiaowei force-pushed the fix/cargo-gamma-binary-mixed-workspaces branch from 8072038 to 2ba4e63 Compare October 10, 2026 20:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The selector logic matches the documented contract and is covered by focused unit and real-toolchain acceptance tests.

2 open findings

🧠 Review effort: Balanced

@chinayangxiaowei chinayangxiaowei changed the title Fix cargo-gamma convergence for binary-only and mixed workspaces fix(cargo-gamma): support binary-only package selections Oct 10, 2026
@chinayangxiaowei
chinayangxiaowei force-pushed the fix/cargo-gamma-binary-mixed-workspaces branch from 2ba4e63 to 648e9cc Compare October 10, 2026 21:01
@chinayangxiaowei
chinayangxiaowei requested a balanced review from Copilot October 10, 2026 21:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The selector logic matches the documented contract and is covered across binary-only and mixed-package scenarios.

0 open findings

2 resolved since last review

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 10, 2026 21:44
@chinayangxiaowei
chinayangxiaowei force-pushed the fix/cargo-gamma-binary-mixed-workspaces branch from 648e9cc to 5758b27 Compare October 10, 2026 21:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The selector logic, metadata propagation, documentation, and regression coverage consistently address binary-only and mixed selections.

0 open findings

🧠 Review effort: Balanced

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No additional findings in the current selector-only fix. Library presence comes from Cargo target metadata rather than test-harness availability, and the check examines the selected package set. All-binary selections omit --lib; mixed selections keep the existing combined selectors. The synthetic-library/manifests mechanism discussed earlier is gone.

The fixtures cover a binary-only crate, a mixed workspace with a test-enabled dependency feature, a library without a harness, and selecting only the binary member. These are appropriately documented as real-toolchain system acceptance tests rather than assumed unit tests.

All five passes covered metadata collection, preflight-to-converger wiring, target selection, tests, and contracts. Generated README output was excluded as an independent review surface. No builds, tests, or mutation runs were executed.

@codecov-commenter

Codecov Comments Bot (codecov-commenter) commented Oct 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.8%. Comparing base (0e9a995) to head (5758b27).

Additional details and impacted files
@@           Coverage Diff            @@
##            main    #241      +/-   ##
========================================
- Coverage   98.9%   97.8%    -1.1%     
========================================
  Files        304     118     -186     
  Lines      44469   18965   -25504     
========================================
- Hits       44008   18561   -25447     
+ Misses       461     404      -57     
Flag Coverage Δ
linux 97.8% <100.0%> (-1.1%) ⬇️
linux-arm 97.8% <100.0%> (-1.1%) ⬇️
scheduled ?
windows 97.6% <100.0%> (-1.3%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI balanced review requested due to automatic review settings October 13, 2026 07:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The selector logic matches the documented contract and is covered across binary-only, mixed, and library-without-harness cases.

0 open findings

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 13, 2026 16:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The selector logic matches Cargo package scope and is covered for binary-only, mixed, and no-harness library cases.

0 open findings

🧠 Review effort: Balanced

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.

5 participants