mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 02:33:55 +00:00
d89500843c
- Move super-fast-paren-parsing test into ui/parser - Move stmt_expr_attrs test into ui/feature-gates - Move macro tests into ui/macros - Move global_asm tests into ui/asm - Move env tests into ui/process - Move xcrate tests into ui/cross-crate - Move unop tests into ui/unop - Move backtrace tests into ui/backtrace - Move check-static tests into ui/statics - Move expr tests into ui/expr - Move optimization fuel tests into ui/fuel - Move ffi attribute tests into ui/ffi-attrs - Move suggestion tests into ui/suggestions - Move main tests into ui/fn-main - Move lint tests into ui/lint - Move repr tests into ui/repr - Move intrinsics tests into ui/intrinsics - Move tool lint tests into ui/tool-attributes - Move return tests into ui/return - Move pattern tests into ui/patttern - Move range tests into ui/range - Move foreign-fn tests into ui/foreign - Move orphan-check tests into ui/coherence - Move inference tests into ui/inference - Reduce ROOT_ENTRY_LIMIT
75 lines
2.5 KiB
Rust
75 lines
2.5 KiB
Rust
//@ run-pass
|
|
//@ ignore-android FIXME #17520
|
|
//@ ignore-wasm32 spawning processes is not supported
|
|
//@ ignore-openbsd no support for libbacktrace without filename
|
|
//@ ignore-sgx no processes
|
|
//@ ignore-msvc see #62897 and `backtrace-debuginfo.rs` test
|
|
//@ ignore-fuchsia Backtraces not symbolized
|
|
//@ compile-flags:-g
|
|
//@ compile-flags:-Cstrip=none
|
|
|
|
use std::env;
|
|
use std::process::Command;
|
|
use std::str;
|
|
|
|
fn main() {
|
|
let args: Vec<String> = env::args().collect();
|
|
if args.len() >= 2 && args[1] == "force" {
|
|
println!("stack backtrace:\n{}", std::backtrace::Backtrace::force_capture());
|
|
} else if args.len() >= 2 {
|
|
println!("stack backtrace:\n{}", std::backtrace::Backtrace::capture());
|
|
} else {
|
|
runtest(&args[0]);
|
|
println!("test ok");
|
|
}
|
|
}
|
|
|
|
fn runtest(me: &str) {
|
|
env::remove_var("RUST_BACKTRACE");
|
|
env::remove_var("RUST_LIB_BACKTRACE");
|
|
|
|
let p = Command::new(me).arg("a").env("RUST_BACKTRACE", "1").output().unwrap();
|
|
assert!(p.status.success());
|
|
assert!(String::from_utf8_lossy(&p.stdout).contains("stack backtrace:\n"));
|
|
assert!(String::from_utf8_lossy(&p.stdout).contains("backtrace::main"));
|
|
|
|
let p = Command::new(me).arg("a").env("RUST_BACKTRACE", "0").output().unwrap();
|
|
assert!(p.status.success());
|
|
assert!(String::from_utf8_lossy(&p.stdout).contains("disabled backtrace\n"));
|
|
|
|
let p = Command::new(me).arg("a").output().unwrap();
|
|
assert!(p.status.success());
|
|
assert!(String::from_utf8_lossy(&p.stdout).contains("disabled backtrace\n"));
|
|
|
|
let p = Command::new(me)
|
|
.arg("a")
|
|
.env("RUST_LIB_BACKTRACE", "1")
|
|
.env("RUST_BACKTRACE", "1")
|
|
.output()
|
|
.unwrap();
|
|
assert!(p.status.success());
|
|
assert!(String::from_utf8_lossy(&p.stdout).contains("stack backtrace:\n"));
|
|
|
|
let p = Command::new(me)
|
|
.arg("a")
|
|
.env("RUST_LIB_BACKTRACE", "0")
|
|
.env("RUST_BACKTRACE", "1")
|
|
.output()
|
|
.unwrap();
|
|
assert!(p.status.success());
|
|
assert!(String::from_utf8_lossy(&p.stdout).contains("disabled backtrace\n"));
|
|
|
|
let p = Command::new(me)
|
|
.arg("force")
|
|
.env("RUST_LIB_BACKTRACE", "0")
|
|
.env("RUST_BACKTRACE", "0")
|
|
.output()
|
|
.unwrap();
|
|
assert!(p.status.success());
|
|
assert!(String::from_utf8_lossy(&p.stdout).contains("stack backtrace:\n"));
|
|
|
|
let p = Command::new(me).arg("force").output().unwrap();
|
|
assert!(p.status.success());
|
|
assert!(String::from_utf8_lossy(&p.stdout).contains("stack backtrace:\n"));
|
|
}
|