Skip to content

Commit 8ab2c69

Browse files
committed
update tests relying on dev and build-deps reuse
1 parent b160046 commit 8ab2c69

File tree

6 files changed

+49
-0
lines changed

6 files changed

+49
-0
lines changed

tests/testsuite/build_script.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4379,6 +4379,10 @@ fn optional_build_script_dep() {
43794379

43804380
#[cargo_test]
43814381
fn optional_build_dep_and_required_normal_dep() {
4382+
// Note: `dev` and `dev.build-override` have different defaults. `bar` would
4383+
// be built twice in the general case: once without debuginfo and once with
4384+
// debuginfo = 2. Setting `debug = 2` in `dev.build-override` ensures it's
4385+
// only built once in this test.
43824386
let p = project()
43834387
.file(
43844388
"Cargo.toml",
@@ -4393,6 +4397,9 @@ fn optional_build_dep_and_required_normal_dep() {
43934397
43944398
[build-dependencies]
43954399
bar = { path = "./bar" }
4400+
4401+
[profile.dev.build-override]
4402+
debug = 2 # see note above
43964403
"#,
43974404
)
43984405
.file("build.rs", "extern crate bar; fn main() { bar::bar(); }")

tests/testsuite/dep_info.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ fn relative_depinfo_paths_ws() {
238238

239239
// Test relative dep-info paths in a workspace with --target with
240240
// proc-macros and other dependency kinds.
241+
//
242+
// Note: `dev` and `dev.build-override` have different defaults. `pmdep`
243+
// would be built twice in the general case: once without debuginfo and once
244+
// with debuginfo = 2. Setting `debug = 2` in `dev.build-override` ensures
245+
// it will only create a single dep-info file.
241246
Package::new("regdep", "0.1.0")
242247
.file("src/lib.rs", "pub fn f() {}")
243248
.publish();
@@ -255,6 +260,9 @@ fn relative_depinfo_paths_ws() {
255260
r#"
256261
[workspace]
257262
members = ["foo"]
263+
264+
[profile.dev.build-override]
265+
debug = 2 # see note above
258266
"#,
259267
)
260268
/*********** Main Project ***********/

tests/testsuite/features2.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,13 +1050,21 @@ fn decouple_proc_macro() {
10501050
#[cargo_test]
10511051
fn proc_macro_ws() {
10521052
// Checks for bug with proc-macro in a workspace with dependency (shouldn't panic).
1053+
//
1054+
// Note, `dev` and `dev.build-override` have different defaults. `pm` would
1055+
// be built twice in the general case: once without debuginfo and once with
1056+
// debuginfo = 2. Setting `debug = 2` in `dev.build-override` ensures it's
1057+
// only built once and `foo` remains fresh during the second check build.
10531058
let p = project()
10541059
.file(
10551060
"Cargo.toml",
10561061
r#"
10571062
[workspace]
10581063
members = ["foo", "pm"]
10591064
resolver = "2"
1065+
1066+
[profile.dev.build-override]
1067+
debug = 2 # see note above
10601068
"#,
10611069
)
10621070
.file(
@@ -2161,13 +2169,21 @@ fn pm_with_int_shared() {
21612169
// with `--workspace`, see https://github.com/rust-lang/cargo/issues/8312.
21622170
//
21632171
// This uses a const-eval hack to do compile-time feature checking.
2172+
//
2173+
// Note, `dev` and `dev.build-override` have different defaults. `pm` would
2174+
// be built twice in the general case: once without debuginfo and once with
2175+
// debuginfo = 2. Setting `debug = 2` in `dev.build-override` ensures it's
2176+
// only built once in this test.
21642177
let p = project()
21652178
.file(
21662179
"Cargo.toml",
21672180
r#"
21682181
[workspace]
21692182
members = ["foo", "pm", "shared"]
21702183
resolver = "2"
2184+
2185+
[profile.dev.build-override]
2186+
debug = 2 # see note above
21712187
"#,
21722188
)
21732189
.file(

tests/testsuite/freshness.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,10 @@ fn fingerprint_cleaner_does_not_rebuild() {
13441344

13451345
#[cargo_test]
13461346
fn reuse_panic_build_dep_test() {
1347+
// Note: `dev` and `dev.build-override` have different defaults. `bar` would
1348+
// be built twice in the general case: once without debuginfo and once with
1349+
// debuginfo = 2. Setting `debug = 2` in `dev.build-override` ensures it's
1350+
// only built once in this test.
13471351
let p = project()
13481352
.file(
13491353
"Cargo.toml",
@@ -1360,6 +1364,9 @@ fn reuse_panic_build_dep_test() {
13601364
13611365
[profile.dev]
13621366
panic = "abort"
1367+
1368+
[profile.dev.build-override]
1369+
debug = 2 # see note above
13631370
"#,
13641371
)
13651372
.file("src/lib.rs", "")

tests/testsuite/proc_macro.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,13 +498,20 @@ fn proc_macro_extern_prelude() {
498498

499499
#[cargo_test]
500500
fn proc_macro_built_once() {
501+
// Note: `dev` and `dev.build-override` have different defaults. `the-macro`
502+
// would be built twice in the general case: once without debuginfo and once
503+
// with debuginfo = 2. Setting `debug = 2` in `dev.build-override` ensures
504+
// it's only built once in this test.
501505
let p = project()
502506
.file(
503507
"Cargo.toml",
504508
r#"
505509
[workspace]
506510
members = ['a', 'b']
507511
resolver = "2"
512+
513+
[profile.dev.build-override]
514+
debug = 2 # see note above
508515
"#,
509516
)
510517
.file(

tests/testsuite/profile_overrides.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ fn profile_override_bad_settings() {
135135
#[cargo_test]
136136
fn profile_override_hierarchy() {
137137
// Test that the precedence rules are correct for different types.
138+
// Note, `dev` and `dev.build-override` have different defaults. `dep` would be built twice in
139+
// the general case: once without debuginfo and once with debuginfo = 2. Setting `debug = 2` in
140+
// `dev.build-override` ensures it's only built once in this test.
138141
let p = project()
139142
.file(
140143
"Cargo.toml",
@@ -153,6 +156,7 @@ fn profile_override_hierarchy() {
153156
154157
[profile.dev.build-override]
155158
codegen-units = 4
159+
debug = 2 # see note above
156160
"#,
157161
)
158162
// m1

0 commit comments

Comments
 (0)