mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00

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.
56 lines
1.2 KiB
Rust
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();
|
|
}
|