Skip to content

Commit fe50f67

Browse files
committed
Auto merge of #14618 - weihanglo:relax-more, r=epage
test: relax compiler panic assertions ### What does this PR try to resolve? Minimize the panic output assertion per request from <#14602 (comment)>. Instead of snapshotting the entire panic message, here we only check the precense of our custom messaage. ### How should we test and review this PR? Test suite passes.
2 parents 5e2878f + dfa8f26 commit fe50f67

File tree

9 files changed

+52
-269
lines changed

9 files changed

+52
-269
lines changed

tests/build-std/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,10 @@ fn remap_path_scope() {
290290
[FINISHED] `release` profile [optimized + debuginfo] target(s) in [ELAPSED]s
291291
[RUNNING] `target/[HOST_TARGET]/release/foo`
292292
[..]thread '[..]' panicked at [..]src/main.rs:3:[..]:
293-
remap to /rustc/<hash>
294-
at /rustc/[..]/library/std/src/[..]
295-
at ./src/main.rs:3:[..]
296-
at /rustc/[..]/library/core/src/[..]
293+
[..]remap to /rustc/<hash>[..]
294+
[..]at /rustc/[..]/library/std/src/[..]
295+
[..]at ./src/main.rs:3:[..]
296+
[..]at /rustc/[..]/library/core/src/[..]
297297
...
298298
"#]]
299299
.unordered(),

tests/testsuite/artifact_dep.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fn check_with_invalid_target_triple() {
151151
Caused by:
152152
process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --target unknown-target-triple [..]` ([EXIT_STATUS]: 1)
153153
--- stderr
154-
[ERROR] Error loading target specification: Could not find specification for target "unknown-target-triple". Run `rustc --print target-list` for a list of built-in targets
154+
...
155155
156156
157157
"#]])
@@ -1571,13 +1571,11 @@ fn artifact_dep_target_specified() {
15711571
// TODO: This command currently fails due to a bug in cargo but it should be fixed so that it succeeds in the future.
15721572
p.cargo("tree -Z bindeps")
15731573
.masquerade_as_nightly_cargo(&["bindeps"])
1574-
.with_stdout_data(str![[""]])
1575-
.with_stderr_data(str![[r#"
1576-
thread 'main' panicked at src/cargo/[..]:
1577-
activated_features for invalid package: features did not find PackageId { name: "bindep", version: "0.0.0", source: "[..]" } NormalOrDev
1578-
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1579-
1580-
"#]])
1574+
.with_stdout_data("")
1575+
.with_stderr_data(r#"...
1576+
[..]activated_features for invalid package: features did not find PackageId { name: "bindep", version: "0.0.0", source: "[..]" } NormalOrDev[..]
1577+
...
1578+
"#)
15811579
.with_status(101)
15821580
.run();
15831581
}
@@ -3246,7 +3244,7 @@ Caused by:
32463244
Caused by:
32473245
process didn't exit successfully: `rustc [..] ([EXIT_STATUS]: 1)
32483246
--- stderr
3249-
[ERROR] Error loading target specification: Could not find specification for target "custom-target". Run `rustc --print target-list` for a list of built-in targets
3247+
...
32503248
32513249
32523250
"#]])

tests/testsuite/bench.rs

Lines changed: 13 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ fn cargo_bench_failing_test() {
364364
365365
#[bench]
366366
fn bench_hello(_b: &mut test::Bencher) {
367-
assert_eq!(hello(), "nope")
367+
assert_eq!(hello(), "nope", "NOPE!")
368368
}
369369
"#,
370370
)
@@ -389,28 +389,7 @@ hello
389389
[ERROR] bench failed, to rerun pass `--bin foo`
390390
391391
"#]])
392-
.with_stdout_data(str![[r#"
393-
394-
running 1 test
395-
test bench_hello ... FAILED
396-
397-
failures:
398-
399-
---- bench_hello stdout ----
400-
thread 'main' panicked at src/main.rs:15:17:
401-
assertion `left == right` failed
402-
left: "hello"
403-
right: "nope"
404-
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
405-
406-
407-
failures:
408-
bench_hello
409-
410-
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
411-
412-
413-
"#]])
392+
.with_stdout_data("...\n[..]NOPE![..]\n...")
414393
.with_status(101)
415394
.run();
416395
}
@@ -1439,7 +1418,7 @@ fn test_bench_no_fail_fast() {
14391418
14401419
#[bench]
14411420
fn bench_nope(_b: &mut test::Bencher) {
1442-
assert_eq!("nope", hello())
1421+
assert_eq!("nope", hello(), "NOPE!")
14431422
}
14441423
"#,
14451424
)
@@ -1449,7 +1428,7 @@ fn test_bench_no_fail_fast() {
14491428
#![feature(test)]
14501429
extern crate test;
14511430
#[bench]
1452-
fn b1_fail(_b: &mut test::Bencher) { assert_eq!(1, 2); }
1431+
fn b1_fail(_b: &mut test::Bencher) { assert_eq!(1, 2, "ONE=TWO"); }
14531432
"#,
14541433
)
14551434
.build();
@@ -1468,48 +1447,15 @@ fn test_bench_no_fail_fast() {
14681447
`--bench b1`
14691448
14701449
"#]])
1471-
.with_stdout_data(str![[r#"
1472-
1473-
running 2 tests
1474-
test bench_hello ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER])
1475-
test bench_nope ... FAILED
1476-
1477-
failures:
1478-
1479-
---- bench_nope stdout ----
1480-
thread 'main' panicked at src/main.rs:20:17:
1481-
assertion `left == right` failed
1482-
left: "nope"
1483-
right: "hello"
1484-
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1485-
1486-
1487-
failures:
1488-
bench_nope
1489-
1490-
test result: FAILED. 0 passed; 1 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s
1491-
1492-
1493-
running 1 test
1494-
test b1_fail ... FAILED
1495-
1496-
failures:
1497-
1498-
---- b1_fail stdout ----
1499-
thread 'main' panicked at benches/b1.rs:5:54:
1500-
assertion `left == right` failed
1501-
left: 1
1502-
right: 2
1503-
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1504-
1505-
1506-
failures:
1507-
b1_fail
1508-
1509-
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
1510-
1511-
1512-
"#]])
1450+
.with_stdout_data(
1451+
r#"
1452+
...
1453+
[..]NOPE![..]
1454+
...
1455+
[..]ONE=TWO[..]
1456+
...
1457+
"#,
1458+
)
15131459
.run();
15141460
}
15151461

tests/testsuite/features2.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,11 +1120,7 @@ it is true
11201120
// Make sure the test is fallible.
11211121
p.cargo("test --doc")
11221122
.with_status(101)
1123-
.with_stdout_data(str![[r#"
1124-
...
1125-
assertion `left == right` failed: common is wrong
1126-
...
1127-
"#]])
1123+
.with_stdout_data("...\n[..]common is wrong[..]\n...")
11281124
.run();
11291125
p.cargo("test --doc").env("TEST_EXPECTS_ENABLED", "1").run();
11301126
p.cargo("doc").run();

tests/testsuite/freshness.rs

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,29 +1883,7 @@ fn dirty_both_lib_and_test() {
18831883
// 2 != 1
18841884
p.cargo("test --lib")
18851885
.with_status(101)
1886-
.with_stdout_data(str![[r#"
1887-
1888-
running 1 test
1889-
test t1 ... FAILED
1890-
1891-
failures:
1892-
1893-
---- t1 stdout ----
1894-
...
1895-
thread 't1' panicked at src/lib.rs:8:21:
1896-
assertion `left == right` failed: doit assert failure
1897-
left: 2
1898-
right: 1
1899-
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1900-
1901-
1902-
failures:
1903-
t1
1904-
1905-
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
1906-
1907-
1908-
"#]])
1886+
.with_stdout_data("...\n[..]doit assert failure[..]\n...")
19091887
.run();
19101888

19111889
if is_coarse_mtime() {
@@ -1949,42 +1927,12 @@ fn script_fails_stay_dirty() {
19491927
}
19501928
p.change_file("helper.rs", r#"pub fn doit() {panic!("Crash!");}"#);
19511929
p.cargo("build")
1952-
.with_stderr_data(str![[r#"
1953-
[COMPILING] foo v0.0.1 ([ROOT]/foo)
1954-
[ERROR] failed to run custom build command for `foo v0.0.1 ([ROOT]/foo)`
1955-
1956-
Caused by:
1957-
process didn't exit successfully: `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build` ([EXIT_STATUS]: 101)
1958-
--- stdout
1959-
cargo::rerun-if-changed=build.rs
1960-
1961-
--- stderr
1962-
...
1963-
thread 'main' panicked at helper.rs:1:16:
1964-
Crash!
1965-
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1966-
1967-
"#]])
1930+
.with_stderr_data("...\n[..]Crash![..]\n...")
19681931
.with_status(101)
19691932
.run();
19701933
// There was a bug where this second call would be "fresh".
19711934
p.cargo("build")
1972-
.with_stderr_data(str![[r#"
1973-
[COMPILING] foo v0.0.1 ([ROOT]/foo)
1974-
[ERROR] failed to run custom build command for `foo v0.0.1 ([ROOT]/foo)`
1975-
1976-
Caused by:
1977-
process didn't exit successfully: `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build` ([EXIT_STATUS]: 101)
1978-
--- stdout
1979-
cargo::rerun-if-changed=build.rs
1980-
1981-
--- stderr
1982-
...
1983-
thread 'main' panicked at helper.rs:1:16:
1984-
Crash!
1985-
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1986-
1987-
"#]])
1935+
.with_stderr_data("...\n[..]Crash![..]\n...")
19881936
.with_status(101)
19891937
.run();
19901938
}

tests/testsuite/install.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ fn do_not_rebuilds_on_local_install() {
13141314
#[cargo_test]
13151315
fn reports_unsuccessful_subcommand_result() {
13161316
Package::new("cargo-fail", "1.0.0")
1317-
.file("src/main.rs", "fn main() { panic!(); }")
1317+
.file("src/main.rs", r#"fn main() { panic!("EXPLICIT PANIC!"); }"#)
13181318
.publish();
13191319
cargo_process("install cargo-fail").run();
13201320
cargo_process("--list")
@@ -1326,13 +1326,7 @@ fn reports_unsuccessful_subcommand_result() {
13261326
.run();
13271327
cargo_process("fail")
13281328
.with_status(101)
1329-
.with_stderr_data(str![[r#"
1330-
...
1331-
thread 'main' panicked at [ROOT]/home/.cargo/registry/src/-[HASH]/cargo-fail-1.0.0/src/main.rs:1:13:
1332-
explicit panic
1333-
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1334-
1335-
"#]])
1329+
.with_stderr_data("...\n[..]EXPLICIT PANIC![..]\n...")
13361330
.run();
13371331
}
13381332

tests/testsuite/jobserver.rs

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,7 @@ this is a runner
233233
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
234234
[RUNNING] `target/debug/cargo-jobserver-check[EXE]`
235235
...
236-
thread 'main' panicked at src/main.rs:5:43:
237-
no jobserver from env: NotPresent
238-
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
236+
[..]no jobserver from env[..]
239237
...
240238
241239
"#]])
@@ -250,40 +248,14 @@ no jobserver from env: NotPresent
250248
[RUNNING] `runner target/debug/cargo-jobserver-check[EXE]`
251249
this is a runner
252250
...
253-
thread 'main' panicked at src/main.rs:5:43:
254-
no jobserver from env: NotPresent
255-
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
256-
...
257-
thread 'main' panicked at src/main.rs:6:17:
258-
assertion failed: status.success()
259-
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
251+
[..]no jobserver from env[..]
260252
...
261253
262254
"#]])
263255
.run();
264256
p.cargo("test -j2")
265257
.with_status(101)
266-
.with_stdout_data(str![[r#"
267-
268-
running 1 test
269-
test test ... FAILED
270-
271-
failures:
272-
273-
---- test stdout ----
274-
...
275-
thread 'test' panicked at src/lib.rs:4:42:
276-
no jobserver from env: NotPresent
277-
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
278-
279-
280-
failures:
281-
test
282-
283-
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
284-
285-
286-
"#]])
258+
.with_stdout_data("...\n[..]no jobserver from env[..]\n...")
287259
.run();
288260
p.cargo("test -j2")
289261
.env("PATH", path)
@@ -295,33 +267,9 @@ test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out;
295267
[RUNNING] unittests src/lib.rs (target/debug/deps/cargo_jobserver_check-[HASH][EXE])
296268
this is a runner
297269
...
298-
thread 'main' panicked at src/main.rs:6:17:
299-
assertion failed: status.success()
300-
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
301-
[ERROR] test failed, to rerun pass `--lib`
302-
303-
"#]])
304-
.with_stdout_data(str![[r#"
305-
306-
running 1 test
307-
test test ... FAILED
308-
309-
failures:
310-
311-
---- test stdout ----
312-
...
313-
thread 'test' panicked at src/lib.rs:4:42:
314-
no jobserver from env: NotPresent
315-
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
316-
317-
318-
failures:
319-
test
320-
321-
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
322-
323270
324271
"#]])
272+
.with_stdout_data("...\n[..]no jobserver from env[..]\n...")
325273
.run();
326274
}
327275

0 commit comments

Comments
 (0)