rust-lang / rust-lang/cargo

Add an option to skip building binaries when there are integration tests

Open
#12,980 8 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-cargo-targets C-feature-request Command-bench Command-test S-needs-design
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

Problem

https://doc.rust-lang.org/cargo/reference/cargo-targets.html#integration-tests

Binary targets are automatically built if there is an integration test. This allows an integration test to execute the binary

https://github.com/rust-lang/cargo/issues/7958

There is not currently a way to skip building the binaries.

We want to skip it because we don't use this feature, and our project is very slow to compile.

Here we wasted a lot of time to build the unnecessary bins.

image

Some other users may have other reasons e.g., https://github.com/rust-lang/cargo/issues/7958#issuecomment-1603273755.

Proposed Solution

I feel this is kind of similar to disable auto-discovery https://doc.rust-lang.org/cargo/reference/cargo-targets.html#target-auto-discovery

[package]
# ...
autobins = false
autoexamples = false
autotests = false
autobenches = false

So maybe we can add an option like build-bins-for-integration-tests (Can't come up with a good name, sorry)

Notes

No response

Contributor guide

Open the contributing guide

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

Start with the Cargo targets documentation and issue #7958 to understand why integration tests currently build binary targets and which use cases must remain supported. Define the configuration behavior and its interaction with integration tests, then verify that the selected option skips unnecessary binaries while preserving tests that execute them.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.