diff options
| author | jyn <github@jyn.dev> | 2024-12-25 19:31:25 -0500 |
|---|---|---|
| committer | jyn <github@jyn.dev> | 2024-12-25 19:47:28 -0500 |
| commit | 801c1d8b907389eac18f3c4f0d66de6077795af7 (patch) | |
| tree | 8e639437d44601615482e90125459f6d4638aaf6 | |
| parent | c7a28d579b8209337fe959e2384d3884878d887c (diff) | |
| download | rust-801c1d8b907389eac18f3c4f0d66de6077795af7.tar.gz rust-801c1d8b907389eac18f3c4f0d66de6077795af7.zip | |
fix default-backtrace-ice test
when running `tests/ui/panics/default-backtrace-ice.rs locally it gave this error: ``` failures: ---- [ui] tests/ui/panics/default-backtrace-ice.rs stdout ---- Saved the actual stderr to "/home/jyn/src/rust3/build/x86_64-unknown-linux-gnu/test/ui/panics/default-backtrace-ice/default-backtrace-ice.stderr" diff of stderr: 7 8 aborting due to `-Z treat-err-as-bug=1` 9 stack backtrace: - (end_short_backtrace) - (begin_short_backtrace) - (end_short_backtrace) - (begin_short_backtrace) + [... omitted 22 frames ...] + ``` this is a regression from setting RUST_BACKTRACE=1 by default. we need to turn off the new behavior when running UI tests so that they reflect our dist compiler. normally that's done by checking `sess.unstable_opts.ui_testing`, but this happens extremely early in the compiler before we've expanded arg files. do an extremely simple hack that doesn't work in all cases - we don't need it to work in all cases, only when running UI tests.
| -rw-r--r-- | compiler/rustc_driver_impl/src/lib.rs | 4 | ||||
| -rw-r--r-- | tests/ui/panics/default-backtrace-ice.rs | 2 | ||||
| -rw-r--r-- | tests/ui/panics/default-backtrace-ice.stderr | 2 |
3 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index b13cc4d0b06..90f382e7226 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -1388,7 +1388,9 @@ pub fn install_ice_hook( // opt in to less-verbose backtraces by manually setting "RUST_BACKTRACE" // (e.g. `RUST_BACKTRACE=1`) if env::var_os("RUST_BACKTRACE").is_none() { - if env!("CFG_RELEASE_CHANNEL") == "dev" { + // HACK: this check is extremely dumb, but we don't really need it to be smarter since this should only happen in the test suite anyway. + let ui_testing = std::env::args().any(|arg| arg == "-Zui-testing"); + if env!("CFG_RELEASE_CHANNEL") == "dev" && !ui_testing { panic::set_backtrace_style(panic::BacktraceStyle::Short); } else { panic::set_backtrace_style(panic::BacktraceStyle::Full); diff --git a/tests/ui/panics/default-backtrace-ice.rs b/tests/ui/panics/default-backtrace-ice.rs index 718d1da5bb7..7953283f028 100644 --- a/tests/ui/panics/default-backtrace-ice.rs +++ b/tests/ui/panics/default-backtrace-ice.rs @@ -1,6 +1,8 @@ //@ unset-rustc-env:RUST_BACKTRACE //@ compile-flags:-Z treat-err-as-bug=1 //@ error-pattern:stack backtrace: +// Verify this is a full backtrace, not a short backtrace. +//@ error-pattern:__rust_begin_short_backtrace //@ failure-status:101 //@ ignore-msvc //@ normalize-stderr-test: "note: .*" -> "" diff --git a/tests/ui/panics/default-backtrace-ice.stderr b/tests/ui/panics/default-backtrace-ice.stderr index 23b863568bc..046b2cca7f9 100644 --- a/tests/ui/panics/default-backtrace-ice.stderr +++ b/tests/ui/panics/default-backtrace-ice.stderr @@ -1,5 +1,5 @@ error: internal compiler error[E0425]: cannot find value `missing_ident` in this scope - --> $DIR/default-backtrace-ice.rs:21:13 + --> $DIR/default-backtrace-ice.rs:23:13 | LL | fn main() { missing_ident; } | ^^^^^^^^^^^^^ not found in this scope |
