Skip to content

Commit dfcfa44

Browse files
authored
test(rustflags): Verify -Cmetadata directly, not through -Cextra-filename (#14846)
### What does this PR try to resolve? This unblocks experimenting with having these diverge for #8716 ### How should we test and review this PR? ### Additional information
2 parents 5dbda8b + 0b10d6f commit dfcfa44

14 files changed

+80
-73
lines changed

crates/cargo-test-support/src/lib.rs

+17-21
Original file line numberDiff line numberDiff line change
@@ -623,12 +623,10 @@ pub fn cargo_exe() -> PathBuf {
623623
/// does not have access to the raw `ExitStatus` because `ProcessError` needs
624624
/// to be serializable (for the Rustc cache), and `ExitStatus` does not
625625
/// provide a constructor.
626-
struct RawOutput {
627-
#[allow(dead_code)]
628-
code: Option<i32>,
629-
stdout: Vec<u8>,
630-
#[allow(dead_code)]
631-
stderr: Vec<u8>,
626+
pub struct RawOutput {
627+
pub code: Option<i32>,
628+
pub stdout: Vec<u8>,
629+
pub stderr: Vec<u8>,
632630
}
633631

634632
/// Run and verify a [`ProcessBuilder`]
@@ -1042,34 +1040,32 @@ impl Execs {
10421040
}
10431041

10441042
#[track_caller]
1045-
pub fn run(&mut self) {
1043+
pub fn run(&mut self) -> RawOutput {
10461044
self.ran = true;
10471045
let mut p = (&self.process_builder).clone().unwrap();
10481046
if let Some(stdin) = self.expect_stdin.take() {
10491047
p.stdin(stdin);
10501048
}
1051-
if let Err(e) = self.match_process(&p) {
1052-
panic_error(&format!("test failed running {}", p), e);
1049+
1050+
match self.match_process(&p) {
1051+
Err(e) => panic_error(&format!("test failed running {}", p), e),
1052+
Ok(output) => output,
10531053
}
10541054
}
10551055

10561056
/// Runs the process, checks the expected output, and returns the first
10571057
/// JSON object on stdout.
10581058
#[track_caller]
10591059
pub fn run_json(&mut self) -> serde_json::Value {
1060-
self.ran = true;
1061-
let p = (&self.process_builder).clone().unwrap();
1062-
match self.match_process(&p) {
1063-
Err(e) => panic_error(&format!("test failed running {}", p), e),
1064-
Ok(output) => serde_json::from_slice(&output.stdout).unwrap_or_else(|e| {
1065-
panic!(
1066-
"\nfailed to parse JSON: {}\n\
1060+
let output = self.run();
1061+
serde_json::from_slice(&output.stdout).unwrap_or_else(|e| {
1062+
panic!(
1063+
"\nfailed to parse JSON: {}\n\
10671064
output was:\n{}\n",
1068-
e,
1069-
String::from_utf8_lossy(&output.stdout)
1070-
);
1071-
}),
1072-
}
1065+
e,
1066+
String::from_utf8_lossy(&output.stdout)
1067+
);
1068+
})
10731069
}
10741070

10751071
#[track_caller]

tests/testsuite/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn build_with_symlink_to_path_dependency_with_build_script_in_git() {
8282
// It is necessary to have a sub-repository and to add files so there is an index.
8383
let repo = git::init(&root.join("original"));
8484
git::add(&repo);
85-
cargo_process("build").run()
85+
cargo_process("build").run();
8686
}
8787

8888
#[cargo_test]

tests/testsuite/build_script.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5234,7 +5234,7 @@ fn dev_dep_with_links() {
52345234
.file("bar/build.rs", "fn main() {}")
52355235
.file("bar/src/lib.rs", "")
52365236
.build();
5237-
p.cargo("check --tests").run()
5237+
p.cargo("check --tests").run();
52385238
}
52395239

52405240
#[cargo_test]

tests/testsuite/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,7 @@ fn cargo_target_empty_env() {
16401640
16411641
"#]])
16421642
.with_status(101)
1643-
.run()
1643+
.run();
16441644
}
16451645

16461646
#[cargo_test]

tests/testsuite/future_incompat_report.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -453,5 +453,5 @@ big_update v1.0.0 has the following newer versions available: 2.0.0
453453
with_updates v1.0.0 has the following newer versions available: 1.0.1, 1.0.2, 3.0.1
454454
...
455455
"#]])
456-
.run()
456+
.run();
457457
}

tests/testsuite/metadata.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3401,7 +3401,7 @@ fn metadata_links() {
34013401
"#]]
34023402
.is_json(),
34033403
)
3404-
.run()
3404+
.run();
34053405
}
34063406

34073407
#[cargo_test]

tests/testsuite/open_namespaces.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Caused by:
3131
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#open-namespaces for more information about the status of this feature.
3232
3333
"#]])
34-
.run()
34+
.run();
3535
}
3636

3737
#[cargo_test]
@@ -100,7 +100,7 @@ fn implicit_lib_within_namespace() {
100100
.is_json(),
101101
)
102102
.with_stderr_data("")
103-
.run()
103+
.run();
104104
}
105105

106106
#[cargo_test]
@@ -169,7 +169,7 @@ fn implicit_bin_within_namespace() {
169169
.is_json(),
170170
)
171171
.with_stderr_data("")
172-
.run()
172+
.run();
173173
}
174174

175175
#[cargo_test]
@@ -256,7 +256,7 @@ fn explicit_bin_within_namespace() {
256256
.is_json(),
257257
)
258258
.with_stderr_data("")
259-
.run()
259+
.run();
260260
}
261261

262262
#[cargo_test]
@@ -354,7 +354,7 @@ path+[ROOTURL]/foo#foo::[email protected]
354354
355355
"#]])
356356
.with_stderr_data("")
357-
.run()
357+
.run();
358358
}
359359

360360
#[cargo_test]
@@ -384,7 +384,7 @@ fn update_spec_accepts_namespaced_name() {
384384
[LOCKING] 0 packages to latest compatible versions
385385
386386
"#]])
387-
.run()
387+
.run();
388388
}
389389

390390
#[cargo_test]
@@ -414,7 +414,7 @@ fn update_spec_accepts_namespaced_pkgid() {
414414
[LOCKING] 0 packages to latest compatible versions
415415
416416
"#]])
417-
.run()
417+
.run();
418418
}
419419

420420
#[cargo_test]

tests/testsuite/package.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3923,7 +3923,7 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for
39233923
[PACKAGED] 6 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
39243924
39253925
"#]])
3926-
.run()
3926+
.run();
39273927
}
39283928

39293929
#[cargo_test]

tests/testsuite/pkgid.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -403,5 +403,5 @@ fn pkgid_json_message_metadata_consistency() {
403403
"#]]
404404
.is_json(),
405405
)
406-
.run()
406+
.run();
407407
}

tests/testsuite/precise_pre_release.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ if you are looking for the prerelease package it needs to be specified explicitl
3939
perhaps a crate was updated and forgotten to be re-vendored?
4040
4141
"#]])
42-
.run()
42+
.run();
4343
}
4444

4545
#[cargo_test]

tests/testsuite/pub_priv.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn exported_priv_warning() {
4242
src/lib.rs:3:13: [WARNING] type `FromPriv` from private dependency 'priv_dep' in public interface
4343
...
4444
"#]])
45-
.run()
45+
.run();
4646
}
4747

4848
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
@@ -87,7 +87,7 @@ fn exported_pub_dep() {
8787
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
8888
8989
"#]])
90-
.run()
90+
.run();
9191
}
9292

9393
#[cargo_test]
@@ -113,7 +113,7 @@ Caused by:
113113
See https://doc.rust-lang.org/[..]cargo/reference/unstable.html#public-dependency for more information about using this feature.
114114
115115
"#]])
116-
.run()
116+
.run();
117117
}
118118

119119
#[cargo_test]
@@ -151,7 +151,7 @@ fn requires_feature() {
151151
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
152152
153153
"#]])
154-
.run()
154+
.run();
155155
}
156156

157157
#[cargo_test]
@@ -194,7 +194,7 @@ Caused by:
194194
'public' specifier can only be used on regular dependencies, not dev-dependencies
195195
196196
"#]])
197-
.run()
197+
.run();
198198
}
199199

200200
#[cargo_test]
@@ -233,7 +233,7 @@ fn pub_dev_dependency_without_feature() {
233233
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
234234
235235
"#]])
236-
.run()
236+
.run();
237237
}
238238

239239
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
@@ -291,7 +291,7 @@ Caused by:
291291
foo2 is public, but workspace dependencies cannot be public
292292
293293
"#]])
294-
.run()
294+
.run();
295295
}
296296

297297
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
@@ -336,7 +336,7 @@ fn allow_priv_in_tests() {
336336
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
337337
338338
"#]])
339-
.run()
339+
.run();
340340
}
341341

342342
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
@@ -381,7 +381,7 @@ fn allow_priv_in_benchs() {
381381
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
382382
383383
"#]])
384-
.run()
384+
.run();
385385
}
386386

387387
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
@@ -427,7 +427,7 @@ fn allow_priv_in_bins() {
427427
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
428428
429429
"#]])
430-
.run()
430+
.run();
431431
}
432432

433433
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
@@ -473,7 +473,7 @@ fn allow_priv_in_examples() {
473473
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
474474
475475
"#]])
476-
.run()
476+
.run();
477477
}
478478

479479
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
@@ -520,7 +520,7 @@ fn allow_priv_in_custom_build() {
520520
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
521521
522522
"#]])
523-
.run()
523+
.run();
524524
}
525525

526526
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
@@ -576,7 +576,7 @@ fn publish_package_with_public_dependency() {
576576
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
577577
578578
"#]])
579-
.run()
579+
.run();
580580
}
581581

582582
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]

tests/testsuite/registry.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3242,7 +3242,7 @@ fn protocol() {
32423242
[ERROR] unsupported registry protocol `invalid` (defined in environment variable `CARGO_REGISTRIES_CRATES_IO_PROTOCOL`)
32433243
32443244
"#]])
3245-
.run()
3245+
.run();
32463246
}
32473247

32483248
#[cargo_test]
@@ -3253,7 +3253,7 @@ fn http_requires_trailing_slash() {
32533253
[ERROR] sparse registry url must end in a slash `/`: sparse+https://invalid.crates.io/test
32543254
32553255
"#]])
3256-
.run()
3256+
.run();
32573257
}
32583258

32593259
// Limit the test to debug builds so that `__CARGO_TEST_MAX_UNPACK_SIZE` will take affect.

0 commit comments

Comments
 (0)