Skip to content

Commit f5705b2

Browse files
committed
rewrite inaccessible-temp-dir to rmake format
1 parent d833b5b commit f5705b2

File tree

3 files changed

+44
-33
lines changed

3 files changed

+44
-33
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ run-make/foreign-double-unwind/Makefile
6666
run-make/foreign-exceptions/Makefile
6767
run-make/foreign-rust-exceptions/Makefile
6868
run-make/glibc-staticlib-args/Makefile
69-
run-make/inaccessible-temp-dir/Makefile
7069
run-make/include_bytes_deps/Makefile
7170
run-make/incr-add-rust-src-component/Makefile
7271
run-make/incr-foreign-head-span/Makefile

tests/run-make/inaccessible-temp-dir/Makefile

-32
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Issue #66530: We would ICE if someone compiled with `-o /dev/null`,
2+
// because we would try to generate auxiliary files in `/dev/` (which
3+
// at least the OS X file system rejects).
4+
//
5+
// An attempt to `-Ztemps-dir` into a directory we cannot write into should
6+
// indeed be an error; but not an ICE.
7+
//
8+
// However, some folks run tests as root, which can write `/dev/` and end
9+
// up clobbering `/dev/null`. Instead we'll use an inaccessible path, which
10+
// also used to ICE, but even root can't magically write there.
11+
//
12+
// Note that `-Ztemps-dir` uses `create_dir_all` so it is not sufficient to
13+
// use a directory with non-existing parent like `/does-not-exist/output`.
14+
// See https://github.com/rust-lang/rust/issues/66530
15+
16+
//@ only-linux
17+
// Reason: set_mode is only available on Unix
18+
19+
//@ ignore-arm
20+
// Reason: linker error on `armhf-gnu`
21+
22+
use run_make_support::{fs_wrapper, rustc};
23+
24+
fn main() {
25+
// Create an inaccessible directory.
26+
fs_wrapper::create_dir("inaccessible");
27+
let meta = fs_wrapper::metadata("inaccessible");
28+
let mut perms = meta.permissions();
29+
perms.set_mode(0o000); // Lock down the directory.
30+
fs_wrapper::set_permissions("inaccessible", perms);
31+
32+
// Run rustc with `-Z temps-dir` set to a directory *inside* the inaccessible one,
33+
// so that it can't create `tmp`.
34+
rustc()
35+
.input("program.rs")
36+
.arg("-Ztemps-dir=inaccessible/tmp")
37+
.run_fail()
38+
.assert_stderr_contains(
39+
"failed to find or create the directory specified by `--temps-dir`",
40+
);
41+
42+
perms.set_mode(0o666); // Unlock the directory, so that compiletest can delete it.
43+
fs_wrapper::set_permissions("inaccessible", perms);
44+
}

0 commit comments

Comments
 (0)