From e4e970d3094f6c61984d4a8f0e01f41cd6bf4053 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Fri, 27 Sep 2024 20:26:31 -0400 Subject: [PATCH 01/10] test(freshness): relax compiler panic assertions --- tests/testsuite/freshness.rs | 58 ++---------------------------------- 1 file changed, 3 insertions(+), 55 deletions(-) diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index 4bcd2800c6f..78c86f1e01e 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -1883,29 +1883,7 @@ fn dirty_both_lib_and_test() { // 2 != 1 p.cargo("test --lib") .with_status(101) - .with_stdout_data(str![[r#" - -running 1 test -test t1 ... FAILED - -failures: - ----- t1 stdout ---- -... -thread 't1' panicked at src/lib.rs:8:21: -assertion `left == right` failed: doit assert failure - left: 2 - right: 1 -[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace - - -failures: - t1 - -test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s - - -"#]]) + .with_stdout_data("...\n[..]doit assert failure[..]\n...") .run(); if is_coarse_mtime() { @@ -1949,42 +1927,12 @@ fn script_fails_stay_dirty() { } p.change_file("helper.rs", r#"pub fn doit() {panic!("Crash!");}"#); p.cargo("build") - .with_stderr_data(str![[r#" -[COMPILING] foo v0.0.1 ([ROOT]/foo) -[ERROR] failed to run custom build command for `foo v0.0.1 ([ROOT]/foo)` - -Caused by: - process didn't exit successfully: `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build` ([EXIT_STATUS]: 101) - --- stdout - cargo::rerun-if-changed=build.rs - - --- stderr -... - thread 'main' panicked at helper.rs:1:16: - Crash! - [NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace - -"#]]) + .with_stderr_data("...\n[..]Crash![..]\n...") .with_status(101) .run(); // There was a bug where this second call would be "fresh". p.cargo("build") - .with_stderr_data(str![[r#" -[COMPILING] foo v0.0.1 ([ROOT]/foo) -[ERROR] failed to run custom build command for `foo v0.0.1 ([ROOT]/foo)` - -Caused by: - process didn't exit successfully: `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build` ([EXIT_STATUS]: 101) - --- stdout - cargo::rerun-if-changed=build.rs - - --- stderr -... - thread 'main' panicked at helper.rs:1:16: - Crash! - [NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace - -"#]]) + .with_stderr_data("...\n[..]Crash![..]\n...") .with_status(101) .run(); } From b1f574a10d2e46cba64e0bc2f4c72424a7cf69c0 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Fri, 27 Sep 2024 20:38:18 -0400 Subject: [PATCH 02/10] test(jobserver): relax compiler panic assertions --- tests/testsuite/jobserver.rs | 60 +++--------------------------------- 1 file changed, 4 insertions(+), 56 deletions(-) diff --git a/tests/testsuite/jobserver.rs b/tests/testsuite/jobserver.rs index e6902c4b2be..360c894afda 100644 --- a/tests/testsuite/jobserver.rs +++ b/tests/testsuite/jobserver.rs @@ -233,9 +233,7 @@ this is a runner [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s [RUNNING] `target/debug/cargo-jobserver-check[EXE]` ... -thread 'main' panicked at src/main.rs:5:43: -no jobserver from env: NotPresent -[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace +[..]no jobserver from env[..] ... "#]]) @@ -250,40 +248,14 @@ no jobserver from env: NotPresent [RUNNING] `runner target/debug/cargo-jobserver-check[EXE]` this is a runner ... -thread 'main' panicked at src/main.rs:5:43: -no jobserver from env: NotPresent -[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace -... -thread 'main' panicked at src/main.rs:6:17: -assertion failed: status.success() -[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace +[..]no jobserver from env[..] ... "#]]) .run(); p.cargo("test -j2") .with_status(101) - .with_stdout_data(str![[r#" - -running 1 test -test test ... FAILED - -failures: - ----- test stdout ---- -... -thread 'test' panicked at src/lib.rs:4:42: -no jobserver from env: NotPresent -[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace - - -failures: - test - -test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s - - -"#]]) + .with_stdout_data("...\n[..]no jobserver from env[..]\n...") .run(); p.cargo("test -j2") .env("PATH", path) @@ -295,33 +267,9 @@ test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; [RUNNING] unittests src/lib.rs (target/debug/deps/cargo_jobserver_check-[HASH][EXE]) this is a runner ... -thread 'main' panicked at src/main.rs:6:17: -assertion failed: status.success() -[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace -[ERROR] test failed, to rerun pass `--lib` - -"#]]) - .with_stdout_data(str![[r#" - -running 1 test -test test ... FAILED - -failures: - ----- test stdout ---- -... -thread 'test' panicked at src/lib.rs:4:42: -no jobserver from env: NotPresent -[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace - - -failures: - test - -test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s - "#]]) + .with_stdout_data("...\n[..]no jobserver from env[..]\n...") .run(); } From 8534276f0dbcf35e9cd7619f2405da3bb711ed90 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Fri, 27 Sep 2024 20:40:20 -0400 Subject: [PATCH 03/10] test(build-std): relax compiler panic assertions --- tests/build-std/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/build-std/main.rs b/tests/build-std/main.rs index aec951a9578..41bbbb47193 100644 --- a/tests/build-std/main.rs +++ b/tests/build-std/main.rs @@ -290,10 +290,10 @@ fn remap_path_scope() { [FINISHED] `release` profile [optimized + debuginfo] target(s) in [ELAPSED]s [RUNNING] `target/[HOST_TARGET]/release/foo` [..]thread '[..]' panicked at [..]src/main.rs:3:[..]: -remap to /rustc/ - at /rustc/[..]/library/std/src/[..] - at ./src/main.rs:3:[..] - at /rustc/[..]/library/core/src/[..] +[..]remap to /rustc/[..] +[..]at /rustc/[..]/library/std/src/[..] +[..]at ./src/main.rs:3:[..] +[..]at /rustc/[..]/library/core/src/[..] ... "#]] .unordered(), From 3f1b82893ac6225da6ffba157191142bf4afd818 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Fri, 27 Sep 2024 20:47:44 -0400 Subject: [PATCH 04/10] test(artifact_dep): relax compiler panic assertions --- tests/testsuite/artifact_dep.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/testsuite/artifact_dep.rs b/tests/testsuite/artifact_dep.rs index adaad2a11f8..c4d1f9ce15d 100644 --- a/tests/testsuite/artifact_dep.rs +++ b/tests/testsuite/artifact_dep.rs @@ -151,7 +151,7 @@ fn check_with_invalid_target_triple() { Caused by: process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --target unknown-target-triple [..]` ([EXIT_STATUS]: 1) --- stderr - [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 +... "#]]) @@ -1571,13 +1571,11 @@ fn artifact_dep_target_specified() { // TODO: This command currently fails due to a bug in cargo but it should be fixed so that it succeeds in the future. p.cargo("tree -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stdout_data(str![[""]]) - .with_stderr_data(str![[r#" -thread 'main' panicked at src/cargo/[..]: -activated_features for invalid package: features did not find PackageId { name: "bindep", version: "0.0.0", source: "[..]" } NormalOrDev -[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace - -"#]]) + .with_stdout_data("") + .with_stderr_data(r#"... +[..]activated_features for invalid package: features did not find PackageId { name: "bindep", version: "0.0.0", source: "[..]" } NormalOrDev[..] +... +"#) .with_status(101) .run(); } @@ -3246,7 +3244,7 @@ Caused by: Caused by: process didn't exit successfully: `rustc [..] ([EXIT_STATUS]: 1) --- stderr - [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 +... "#]]) From 7cb5be34c0e7a1e8d7693482eed9967812a0339b Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Mon, 30 Sep 2024 12:31:33 -0400 Subject: [PATCH 05/10] test(bench): relax compiler panic assertions --- tests/testsuite/bench.rs | 80 +++++++--------------------------------- 1 file changed, 13 insertions(+), 67 deletions(-) diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index e9ba49176ad..258af709fea 100644 --- a/tests/testsuite/bench.rs +++ b/tests/testsuite/bench.rs @@ -364,7 +364,7 @@ fn cargo_bench_failing_test() { #[bench] fn bench_hello(_b: &mut test::Bencher) { - assert_eq!(hello(), "nope") + assert_eq!(hello(), "nope", "NOPE!") } "#, ) @@ -389,28 +389,7 @@ hello [ERROR] bench failed, to rerun pass `--bin foo` "#]]) - .with_stdout_data(str![[r#" - -running 1 test -test bench_hello ... FAILED - -failures: - ----- bench_hello stdout ---- -thread 'main' panicked at src/main.rs:15:17: -assertion `left == right` failed - left: "hello" - right: "nope" -[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace - - -failures: - bench_hello - -test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s - - -"#]]) + .with_stdout_data("...\n[..]NOPE![..]\n...") .with_status(101) .run(); } @@ -1439,7 +1418,7 @@ fn test_bench_no_fail_fast() { #[bench] fn bench_nope(_b: &mut test::Bencher) { - assert_eq!("nope", hello()) + assert_eq!("nope", hello(), "NOPE!") } "#, ) @@ -1449,7 +1428,7 @@ fn test_bench_no_fail_fast() { #![feature(test)] extern crate test; #[bench] - fn b1_fail(_b: &mut test::Bencher) { assert_eq!(1, 2); } + fn b1_fail(_b: &mut test::Bencher) { assert_eq!(1, 2, "ONE=TWO"); } "#, ) .build(); @@ -1468,48 +1447,15 @@ fn test_bench_no_fail_fast() { `--bench b1` "#]]) - .with_stdout_data(str![[r#" - -running 2 tests -test bench_hello ... bench: [AVG_ELAPSED] ns/iter (+/- [JITTER]) -test bench_nope ... FAILED - -failures: - ----- bench_nope stdout ---- -thread 'main' panicked at src/main.rs:20:17: -assertion `left == right` failed - left: "nope" - right: "hello" -[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace - - -failures: - bench_nope - -test result: FAILED. 0 passed; 1 failed; 0 ignored; 1 measured; 0 filtered out; finished in [ELAPSED]s - - -running 1 test -test b1_fail ... FAILED - -failures: - ----- b1_fail stdout ---- -thread 'main' panicked at benches/b1.rs:5:54: -assertion `left == right` failed - left: 1 - right: 2 -[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace - - -failures: - b1_fail - -test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s - - -"#]]) + .with_stdout_data( + r#" +... +[..]NOPE![..] +... +[..]ONE=TWO[..] +... +"#, + ) .run(); } From d6ebb14227072f4e6db8f21481e03a4614422e60 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Mon, 30 Sep 2024 13:09:38 -0400 Subject: [PATCH 06/10] test(features2): relax compiler panic assertions --- tests/testsuite/features2.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/testsuite/features2.rs b/tests/testsuite/features2.rs index 5bcd1e2cc54..8f469e2b110 100644 --- a/tests/testsuite/features2.rs +++ b/tests/testsuite/features2.rs @@ -1120,11 +1120,7 @@ it is true // Make sure the test is fallible. p.cargo("test --doc") .with_status(101) - .with_stdout_data(str![[r#" -... -assertion `left == right` failed: common is wrong -... -"#]]) + .with_stdout_data("...\n[..]common is wrong[..]\n...") .run(); p.cargo("test --doc").env("TEST_EXPECTS_ENABLED", "1").run(); p.cargo("doc").run(); From e2946ab9fbe558d791eca14246d0789d8c4901bd Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Mon, 30 Sep 2024 13:09:58 -0400 Subject: [PATCH 07/10] test(install): relax compiler panic assertions --- tests/testsuite/install.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index 95656cc834d..5f6132ff4bf 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -1314,7 +1314,7 @@ fn do_not_rebuilds_on_local_install() { #[cargo_test] fn reports_unsuccessful_subcommand_result() { Package::new("cargo-fail", "1.0.0") - .file("src/main.rs", "fn main() { panic!(); }") + .file("src/main.rs", r#"fn main() { panic!("EXPLICIT PANIC!"); }"#) .publish(); cargo_process("install cargo-fail").run(); cargo_process("--list") @@ -1326,13 +1326,7 @@ fn reports_unsuccessful_subcommand_result() { .run(); cargo_process("fail") .with_status(101) - .with_stderr_data(str![[r#" -... -thread 'main' panicked at [ROOT]/home/.cargo/registry/src/-[HASH]/cargo-fail-1.0.0/src/main.rs:1:13: -explicit panic -[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace - -"#]]) + .with_stderr_data("...\n[..]EXPLICIT PANIC![..]\n...") .run(); } From c3a74f5c36da941f606251bacdcc0b26bdfca2ad Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Mon, 30 Sep 2024 13:10:18 -0400 Subject: [PATCH 08/10] test(rustflags): relax compiler panic assertions --- tests/testsuite/rustflags.rs | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/tests/testsuite/rustflags.rs b/tests/testsuite/rustflags.rs index 7855439e647..582439d04d4 100644 --- a/tests/testsuite/rustflags.rs +++ b/tests/testsuite/rustflags.rs @@ -967,7 +967,7 @@ fn build_rustflags_for_build_scripts() { .file( "build.rs", r#" - fn main() { assert!(cfg!(foo)); } + fn main() { assert!(cfg!(foo), "CFG FOO!"); } "#, ) .file( @@ -986,12 +986,7 @@ fn build_rustflags_for_build_scripts() { p.cargo("check --target") .arg(host) .with_status(101) - .with_stderr_data(str![[r#" -... - assertion failed: cfg!(foo) - [NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace - -"#]]) + .with_stderr_data("...\n[..]CFG FOO![..]\n...") .run(); // Enabling -Ztarget-applies-to-host should not make a difference without the config setting @@ -1004,12 +999,7 @@ fn build_rustflags_for_build_scripts() { .masquerade_as_nightly_cargo(&["target-applies-to-host"]) .arg("-Ztarget-applies-to-host") .with_status(101) - .with_stderr_data(str![[r#" -... - assertion failed: cfg!(foo) - [NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace - -"#]]) + .with_stderr_data("...\n[..]CFG FOO![..]\n...") .run(); // When set to false though, the "proper" behavior where host artifacts _only_ pick up on @@ -1027,24 +1017,14 @@ fn build_rustflags_for_build_scripts() { .masquerade_as_nightly_cargo(&["target-applies-to-host"]) .arg("-Ztarget-applies-to-host") .with_status(101) - .with_stderr_data(str![[r#" -... - assertion failed: cfg!(foo) - [NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace - -"#]]) + .with_stderr_data("...\n[..]CFG FOO![..]\n...") .run(); p.cargo("check --target") .arg(host) .masquerade_as_nightly_cargo(&["target-applies-to-host"]) .arg("-Ztarget-applies-to-host") .with_status(101) - .with_stderr_data(str![[r#" -... - assertion failed: cfg!(foo) - [NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace - -"#]]) + .with_stderr_data("...\n[..]CFG FOO![..]\n...") .run(); } From e965b41fa0bc447653cee0784b3c345a9ccd91bd Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Mon, 30 Sep 2024 13:01:23 -0400 Subject: [PATCH 09/10] test(test): relax compiler panic assertions --- tests/testsuite/test.rs | 52 +++++++++++------------------------------ 1 file changed, 13 insertions(+), 39 deletions(-) diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 4c209e819c5..e1770cd0065 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -396,7 +396,7 @@ fn cargo_test_failing_test_in_bin() { #[test] fn test_hello() { - assert_eq!(hello(), "nope") + assert_eq!(hello(), "nope", "NOPE!") } "#, ) @@ -420,24 +420,7 @@ hello [ERROR] test failed, to rerun pass `--bin foo` "#]]) - .with_stdout_data( - str![[r#" -running 1 test -test test_hello ... FAILED - -failures: - ----- test_hello stdout ---- -thread 'test_hello' panicked at src/main.rs:12:17: -assertion `left == right` failed - left: "hello" - right: "nope" -failures: - test_hello -... -"#]] - .unordered(), - ) + .with_stdout_data("...\n[..]NOPE![..]\n...") .with_status(101) .run(); } @@ -449,7 +432,7 @@ fn cargo_test_failing_test_in_test() { .file("src/main.rs", r#"pub fn main() { println!("hello"); }"#) .file( "tests/footest.rs", - "#[test] fn test_hello() { assert!(false) }", + r#"#[test] fn test_hello() { assert!(false, "FALSE!") }"#, ) .build(); @@ -476,17 +459,13 @@ hello str![[r#" ... running 0 tests +... running 1 test test test_hello ... FAILED - -failures: - ----- test_hello stdout ---- -thread 'test_hello' panicked at tests/footest.rs:1:27: -assertion failed: false -failures: - test_hello ... +[..]FALSE![..] +... + "#]] .unordered(), ) @@ -498,7 +477,10 @@ failures: fn cargo_test_failing_test_in_lib() { let p = project() .file("Cargo.toml", &basic_lib_manifest("foo")) - .file("src/lib.rs", "#[test] fn test_hello() { assert!(false) }") + .file( + "src/lib.rs", + r#"#[test] fn test_hello() { assert!(false, "FALSE!") }"#, + ) .build(); p.cargo("test") @@ -512,16 +494,8 @@ fn cargo_test_failing_test_in_lib() { .with_stdout_data(str![[r#" ... test test_hello ... FAILED - -failures: - ----- test_hello stdout ---- -... -thread 'test_hello' panicked at src/lib.rs:1:27: -assertion failed: false ... -failures: - test_hello +[..]FALSE![..] ... "#]]) .with_status(101) @@ -5528,7 +5502,7 @@ Caused by: "test exited abnormally; to see the full output pass --nocapture to the harness.", ) .with_stderr_data(str![[r#" -thread 't' panicked at tests/t1.rs:3:26: +[..]thread [..]panicked [..] tests/t1.rs[..] [NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace Caused by: process didn't exit successfully: `[ROOT]/foo/target/debug/deps/t2-[HASH][EXE] --nocapture` ([EXIT_STATUS]: 4) From dfa8f26ddc0f41aed6d00d959ad01da8b87615e0 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Mon, 30 Sep 2024 13:08:39 -0400 Subject: [PATCH 10/10] test(test): unnecessay env_remove("RUST_BACKTRACE") This is done for all tests in f3c7525a61d61b347ed9e2e278dd84cc8c943531 --- tests/testsuite/test.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index e1770cd0065..ce4825e7989 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -5497,7 +5497,6 @@ Caused by: .run(); p.cargo("test --no-fail-fast -- --nocapture") - .env_remove("RUST_BACKTRACE") .with_stderr_does_not_contain( "test exited abnormally; to see the full output pass --nocapture to the harness.", )