cargo/tests/testsuite/timings.rs
Ed Page 1876326b6b feat(resolve): Tell the user the style of resovle done
This is to help with #9930

Example changes:
```diff
-[LOCKING] 4 packages
+[LOCKING] 4 packages to latest version
-[LOCKING] 2 packages
+[LOCKING] 2 packages to latest Rust 1.60.0 compatible versions
-[LOCKING] 2 packages
+[LOCKING] 2 packages to earliest versions
```

Benefits
- The package count is of "added" packages and this makes that more
  logically clear
- This gives users transparency into what is happening, especially with
  - what rust-version is use
  - the transition to this feature in the new edition
  - whether the planned config was applied or not (as I don't want it to
    require an MSRV bump)
- Will make it easier in tests to show what changed
- Provides more motiviation to show this message in `cargo update` and
  `cargo install` (that will be explored in a follow up PR)

This does come at the cost of more verbose output but hopefully not too
verbose.  This is why I left off other factors, like avoid-dev-deps.
2024-04-13 20:39:59 -05:00

56 lines
1.2 KiB
Rust

//! Tests for --timings.
use cargo_test_support::project;
use cargo_test_support::registry::Package;
#[cargo_test]
fn timings_works() {
Package::new("dep", "0.1.0").publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2015"
[dependencies]
dep = "0.1"
"#,
)
.file("src/lib.rs", "")
.file("src/main.rs", "fn main() {}")
.file("tests/t1.rs", "")
.file("examples/ex1.rs", "fn main() {}")
.build();
p.cargo("build --all-targets --timings")
.with_stderr_unordered(
"\
[UPDATING] [..]
[LOCKING] 2 packages to latest compatible versions
[DOWNLOADING] crates ...
[DOWNLOADED] dep v0.1.0 [..]
[COMPILING] dep v0.1.0
[COMPILING] foo v0.1.0 [..]
[FINISHED] [..]
Timing report saved to [..]/foo/target/cargo-timings/cargo-timing-[..].html
",
)
.run();
p.cargo("clean").run();
p.cargo("test --timings").run();
p.cargo("clean").run();
p.cargo("check --timings").run();
p.cargo("clean").run();
p.cargo("doc --timings").run();
}