Skip to content

Commit 715362b

Browse files
committed
tests: Don't check for self-printed output in std-backtrace.rs test
The `Display` implementation for `Backtrace` used to print stack backtrace: but that print was later removed. To make the existing test pass, the print was added to the existing test. But it doesn't make sense to check for something that the test itself does since that will not detect any regressions in the implementation of `Backtrace`. What the test _should_ check is that "stack backtrace:" is _not_ printed in `Display` of `Backtrace`. So do that instead.
1 parent 6268d0a commit 715362b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tests/ui/backtrace/std-backtrace.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ use std::str;
1313
fn main() {
1414
let args: Vec<String> = env::args().collect();
1515
if args.len() >= 2 && args[1] == "force" {
16-
println!("stack backtrace:\n{}", std::backtrace::Backtrace::force_capture());
16+
println!("{}", std::backtrace::Backtrace::force_capture());
1717
} else if args.len() >= 2 {
18-
println!("stack backtrace:\n{}", std::backtrace::Backtrace::capture());
18+
println!("{}", std::backtrace::Backtrace::capture());
1919
} else {
2020
runtest(&args[0]);
2121
println!("test ok");
@@ -28,7 +28,9 @@ fn runtest(me: &str) {
2828

2929
let p = Command::new(me).arg("a").env("RUST_BACKTRACE", "1").output().unwrap();
3030
assert!(p.status.success());
31-
assert!(String::from_utf8_lossy(&p.stdout).contains("stack backtrace:\n"));
31+
// Make sure there is no header. The header to use (if any) is up the user.
32+
// See https://github.com/rust-lang/rust/pull/69042.
33+
assert!(!String::from_utf8_lossy(&p.stdout).contains("stack backtrace:"));
3234
assert!(String::from_utf8_lossy(&p.stdout).contains("backtrace::main"));
3335

3436
let p = Command::new(me).arg("a").env("RUST_BACKTRACE", "0").output().unwrap();
@@ -46,7 +48,7 @@ fn runtest(me: &str) {
4648
.output()
4749
.unwrap();
4850
assert!(p.status.success());
49-
assert!(String::from_utf8_lossy(&p.stdout).contains("stack backtrace:\n"));
51+
assert!(!String::from_utf8_lossy(&p.stdout).contains("stack backtrace:"));
5052

5153
let p = Command::new(me)
5254
.arg("a")
@@ -64,9 +66,9 @@ fn runtest(me: &str) {
6466
.output()
6567
.unwrap();
6668
assert!(p.status.success());
67-
assert!(String::from_utf8_lossy(&p.stdout).contains("stack backtrace:\n"));
69+
assert!(!String::from_utf8_lossy(&p.stdout).contains("stack backtrace:"));
6870

6971
let p = Command::new(me).arg("force").output().unwrap();
7072
assert!(p.status.success());
71-
assert!(String::from_utf8_lossy(&p.stdout).contains("stack backtrace:\n"));
73+
assert!(!String::from_utf8_lossy(&p.stdout).contains("stack backtrace:"));
7274
}

0 commit comments

Comments
 (0)