about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-06-11 11:57:07 -0400
committerOneirical <manchot@videotron.ca>2024-06-12 10:12:51 -0400
commit03982dae0173f7358dd779aa2a92dd0a2ab0fe59 (patch)
tree453bd6afa08068fdabc07c48f24d58eed16d31bd
parentd2268902f7db32c03520f160f2d0e750d4d8d0b1 (diff)
downloadrust-03982dae0173f7358dd779aa2a92dd0a2ab0fe59.tar.gz
rust-03982dae0173f7358dd779aa2a92dd0a2ab0fe59.zip
rewrite inaccessible-temp-dir to rmake format
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/inaccessible-temp-dir/Makefile32
-rw-r--r--tests/run-make/inaccessible-temp-dir/rmake.rs44
3 files changed, 44 insertions, 33 deletions
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index 59c836862c5..dd6e64057b4 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -66,7 +66,6 @@ run-make/foreign-double-unwind/Makefile
 run-make/foreign-exceptions/Makefile
 run-make/foreign-rust-exceptions/Makefile
 run-make/glibc-staticlib-args/Makefile
-run-make/inaccessible-temp-dir/Makefile
 run-make/include_bytes_deps/Makefile
 run-make/incr-add-rust-src-component/Makefile
 run-make/incr-foreign-head-span/Makefile
diff --git a/tests/run-make/inaccessible-temp-dir/Makefile b/tests/run-make/inaccessible-temp-dir/Makefile
deleted file mode 100644
index abdba4eb861..00000000000
--- a/tests/run-make/inaccessible-temp-dir/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-# only-linux
-# ignore-arm - linker error on `armhf-gnu`
-
-include ../tools.mk
-
-# Issue #66530: We would ICE if someone compiled with `-o /dev/null`,
-# because we would try to generate auxiliary files in `/dev/` (which
-# at least the OS X file system rejects).
-#
-# An attempt to `-Ztemps-dir` into a directory we cannot write into should
-# indeed be an error; but not an ICE.
-#
-# However, some folks run tests as root, which can write `/dev/` and end
-# up clobbering `/dev/null`. Instead we'll use an inaccessible path, which
-# also used to ICE, but even root can't magically write there.
-#
-# Note that `-Ztemps-dir` uses `create_dir_all` so it is not sufficient to
-# use a directory with non-existing parent like `/does-not-exist/output`.
-
-all:
-	# Create an inaccessible directory
-	mkdir $(TMPDIR)/inaccessible
-	chmod 000 $(TMPDIR)/inaccessible
-
-	# Run rustc with `-Ztemps-dir` set to a directory 
-	# *inside* the inaccessible one, so that it can't create it
-	$(RUSTC) program.rs -Ztemps-dir=$(TMPDIR)/inaccessible/tmp 2>&1 \
-		| $(CGREP) 'failed to find or create the directory specified by `--temps-dir`'
-
-	# Make the inaccessible directory accessible,
-	# so that compiletest can delete the temp dir
-	chmod +rw $(TMPDIR)/inaccessible
diff --git a/tests/run-make/inaccessible-temp-dir/rmake.rs b/tests/run-make/inaccessible-temp-dir/rmake.rs
new file mode 100644
index 00000000000..25c9d363820
--- /dev/null
+++ b/tests/run-make/inaccessible-temp-dir/rmake.rs
@@ -0,0 +1,44 @@
+// Issue #66530: We would ICE if someone compiled with `-o /dev/null`,
+// because we would try to generate auxiliary files in `/dev/` (which
+// at least the OS X file system rejects).
+//
+// An attempt to `-Ztemps-dir` into a directory we cannot write into should
+// indeed be an error; but not an ICE.
+//
+// However, some folks run tests as root, which can write `/dev/` and end
+// up clobbering `/dev/null`. Instead we'll use an inaccessible path, which
+// also used to ICE, but even root can't magically write there.
+//
+// Note that `-Ztemps-dir` uses `create_dir_all` so it is not sufficient to
+// use a directory with non-existing parent like `/does-not-exist/output`.
+// See https://github.com/rust-lang/rust/issues/66530
+
+//@ only-linux
+// Reason: set_mode is only available on Unix
+
+//@ ignore-arm
+// Reason: linker error on `armhf-gnu`
+
+use run_make_support::{fs_wrapper, rustc};
+
+fn main() {
+    // Create an inaccessible directory.
+    fs_wrapper::create_dir("inaccessible");
+    let meta = fs_wrapper::metadata("inaccessible");
+    let mut perms = meta.permissions();
+    perms.set_mode(0o000); // Lock down the directory.
+    fs_wrapper::set_permissions("inaccessible", perms);
+
+    // Run rustc with `-Z temps-dir` set to a directory *inside* the inaccessible one,
+    // so that it can't create `tmp`.
+    rustc()
+        .input("program.rs")
+        .arg("-Ztemps-dir=inaccessible/tmp")
+        .run_fail()
+        .assert_stderr_contains(
+            "failed to find or create the directory specified by `--temps-dir`",
+        );
+
+    perms.set_mode(0o666); // Unlock the directory, so that compiletest can delete it.
+    fs_wrapper::set_permissions("inaccessible", perms);
+}