rust/tests/ui/backtrace/line-tables-only.rs
Jubilee Young d89500843c Move 100 entries from tests/ui into subdirs
- 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
2024-05-20 19:55:59 -07:00

50 lines
2.0 KiB
Rust

// Test that when debug info only includes line tables that backtrace is still generated
// successfully.
// Original test:
// <https://github.com/rust-lang/backtrace-rs/tree/6fa4b85b9962c3e1be8c2e5cc605cd078134152b/crates/line-tables-only>.
// Part of <https://github.com/rust-lang/rust/issues/122899> porting some backtrace tests to rustc.
// This test diverges from the original test in that it now uses a Rust library auxiliary because
// rustc now has `-Cdebuginfo=line-tables-only`.
// ignore-tidy-linelength
//@ run-pass
//@ compile-flags: -Cstrip=none -Cdebuginfo=line-tables-only
//@ ignore-android FIXME #17520
//@ ignore-fuchsia Backtraces not symbolized
//@ needs-unwind
//@ aux-build: line-tables-only-helper.rs
#![feature(backtrace_frames)]
extern crate line_tables_only_helper;
use std::backtrace::Backtrace;
fn assert_contains(
backtrace: &Backtrace,
expected_name: &str,
expected_file: &str,
expected_line: u32,
) {
// FIXME(jieyouxu): fix this ugly fragile test when `BacktraceFrame` has accessors like...
// `symbols()`.
let backtrace = format!("{:#?}", backtrace);
eprintln!("{}", backtrace);
assert!(backtrace.contains(expected_name), "backtrace does not contain expected name {}", expected_name);
assert!(backtrace.contains(expected_file), "backtrace does not contain expected file {}", expected_file);
assert!(backtrace.contains(&expected_line.to_string()), "backtrace does not contain expected line {}", expected_line);
}
fn main() {
std::env::set_var("RUST_BACKTRACE", "1");
let backtrace = line_tables_only_helper::capture_backtrace();
// FIXME(jieyouxu): for some forsaken reason on i686-msvc `foo` doesn't have an entry in the
// line tables?
#[cfg(not(all(target_pointer_width = "32", target_env = "msvc")))]
{
assert_contains(&backtrace, "foo", "line-tables-only-helper.rs", 5);
}
assert_contains(&backtrace, "bar", "line-tables-only-helper.rs", 10);
assert_contains(&backtrace, "baz", "line-tables-only-helper.rs", 15);
}