Skip to content

Commit

Permalink
test(freshness::changing_bin_features_caches_targets): Revert snapbox…
Browse files Browse the repository at this point in the history
  • Loading branch information
choznerol committed Jul 1, 2024
1 parent 14cbe9e commit c826531
Showing 1 changed file with 36 additions and 59 deletions.
95 changes: 36 additions & 59 deletions tests/testsuite/freshness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ ftest on
.run();
}

#[allow(deprecated)]
#[cargo_test]
fn changing_bin_features_caches_targets() {
let p = project()
Expand Down Expand Up @@ -516,86 +517,62 @@ fn changing_bin_features_caches_targets() {
.build();

p.cargo("build")
.with_stderr_data(str![[r#"
[COMPILING] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
"#]])
.run();
p.rename_run("foo", "off1")
.with_stdout_data(str![[r#"
feature off
"#]])
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([..])
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
",
)
.run();
p.rename_run("foo", "off1").with_stdout("feature off").run();

p.cargo("build --features foo")
.with_stderr_data(str![[r#"
[COMPILING] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
"#]])
.run();
p.rename_run("foo", "on1")
.with_stdout_data(str![[r#"
feature on
"#]])
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([..])
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
",
)
.run();
p.rename_run("foo", "on1").with_stdout("feature on").run();

/* Targets should be cached from the first build */

let mut e = p.cargo("build -v");

// MSVC does not include hash in binary filename, so it gets recompiled.
if cfg!(target_env = "msvc") {
e.with_stderr_data(str![[r#"
[DIRTY] foo v0.0.1 ([ROOT]/foo): the list of features changed
[COMPILING] foo v0.0.1 ([ROOT]/foo)
[RUNNING] `rustc --crate-name [..]
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
"#]])
.run();
e.with_stderr(
"\
[DIRTY] foo v0.0.1 ([..]): the list of features changed
[COMPILING] foo[..]
[RUNNING] `rustc [..]
[FINISHED] `dev`[..]",
);
} else {
e.with_stderr_data(str![[r#"
[FRESH] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
"#]]);
e.with_stderr("[FRESH] foo v0.0.1 ([..])\n[FINISHED] `dev`[..]");
}
e.run();
p.rename_run("foo", "off2")
.with_stdout_data(str![[r#"
feature off
"#]])
.run();
p.rename_run("foo", "off2").with_stdout("feature off").run();

let mut e = p.cargo("build --features foo -v");
if cfg!(target_env = "msvc") {
e.with_stderr_data(str![[r#"
[DIRTY] foo v0.0.1 ([ROOT]/foo): the list of features changed
[COMPILING] foo v0.0.1 ([ROOT]/foo)
e.with_stderr(
"\
[DIRTY] foo v0.0.1 ([..]): the list of features changed
[COMPILING] foo[..]
[RUNNING] `rustc [..]
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
"#]])
.run();
[FINISHED] `dev`[..]",
);
} else {
e.with_stderr_data(str![[r#"
[FRESH] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
"#]]);
e.with_stderr(
"\
[FRESH] foo v0.0.1 ([..])
[FINISHED] `dev`[..]",
);
}
e.run();
p.rename_run("foo", "on2")
.with_stdout_data(str![[r#"
feature on
"#]])
.run();
p.rename_run("foo", "on2").with_stdout("feature on").run();
}

#[cargo_test]
Expand Down

0 comments on commit c826531

Please sign in to comment.