rust/tests/run-make/invalid-tmpdir-env-var/rmake.rs
Chris Denton b5c473e414
Avoid using env::temp when linking a binary
This keeps all build artefacts (even temporary ones) within the build directory.
2025-12-24 06:41:42 +00:00

22 lines
770 B
Rust

//@ needs-target-std
//
// When the TMP (on Windows) or TMPDIR (on Unix) variable is set to an invalid
// or non-existing directory, this used to cause an internal compiler error (ICE).
// See https://github.com/rust-lang/rust/issues/14698
use run_make_support::{is_windows, rustc};
// NOTE: This is not a UI test despite its simplicity, as the error message contains a path
// with some variability that is difficult to normalize
fn main() {
let mut rustc = rustc();
if is_windows() {
rustc.env("TMP", "fake");
} else {
rustc.env("TMPDIR", "fake");
}
let result = rustc.input("foo.rs").run_unchecked();
// Ensure that rustc doesn't ICE by checking the exit code isn't 101.
assert_ne!(result.status().code(), Some(101));
}