/// `test` is true, then it is also compiled with `--test` to check it like
/// a test.
Check { test: bool },
- /// A target being built for a benchmark.
+ /// Used to indicate benchmarks should be built. This is not used in
+ /// `Target` because it is essentially the same as `Test` (indicating
+ /// `--test` should be passed to rustc) and by using `Test` instead it
+ /// allows some de-duping of Units to occur.
Bench,
/// A target that will be documented with `rustdoc`.
/// If `deps` is true, then it will also document all dependencies.
target_mode,
release,
);
+ // Once the profile has been selected for benchmarks, we don't need to
+ // distinguish between benches and tests. Switching the mode allows
+ // de-duplication of units that are essentially identical. For
+ // example, `cargo build --all-targets --release` creates the units
+ // (lib profile:bench, mode:test) and (lib profile:bench, mode:bench)
+ // and since these are the same, we want them to be de-duped in
+ // `unit_dependencies`.
+ let target_mode = match target_mode {
+ CompileMode::Bench => CompileMode::Test,
+ _ => target_mode,
+ };
Unit {
pkg,
target,
// lib dev+panic build (a normal lib target)
// lib dev-panic build (used by tests/benches)
// lib test test
- // lib bench bench
+ // lib bench test(bench)
// test test test
- // bench bench bench
+ // bench bench test(bench)
// bin test test
- // bin bench bench
+ // bin bench test(bench)
// bin dev build
// example dev build
assert_that(p.cargo("build --all-targets -vv"),
// ------ ------- ----
// lib release+panic build (a normal lib target)
// lib release-panic build (used by tests/benches)
- // lib bench test
- // lib bench bench
+ // lib bench test (bench/test de-duped)
// test bench test
- // bench bench bench
- // bin bench test
- // bin bench bench
+ // bench bench test
+ // bin bench test (bench/test de-duped)
// bin release build
// example release build
assert_that(p.cargo("build --all-targets --release -vv"),
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]`
[RUNNING] `rustc --crate-name foo src[/]lib.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]`
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]`
-[RUNNING] `rustc --crate-name foo src[/]lib.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]`
-[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]`
[RUNNING] `rustc --crate-name test1 tests[/]test1.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]`
[RUNNING] `rustc --crate-name bench1 benches[/]bench1.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]`
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]`
// Target Profile Mode
// ------ ------- ----
// lib release-panic build
- // lib bench bench
- // bench bench bench
- // bin bench bench
+ // lib bench test(bench)
+ // bench bench test(bench)
+ // bin bench test(bench)
// bin release-panic build
//
assert_that(p.cargo("bench -vv"), execs().with_status(0).with_stderr_unordered("\