about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-07-04 16:45:48 -0400
committerOneirical <manchot@videotron.ca>2024-07-12 10:45:38 -0400
commitcef8a044ea73f8056d70d4d9f1f90fad47807786 (patch)
treee19a24d90c2cbb8ec11f175320784bd3e80a455c
parentb286722878e18db29a7fbe672be7c4d3b02e8e4d (diff)
downloadrust-cef8a044ea73f8056d70d4d9f1f90fad47807786.tar.gz
rust-cef8a044ea73f8056d70d4d9f1f90fad47807786.zip
rewrite extra-filename-with-temp-outputs to rmake
-rw-r--r--src/tools/run-make-support/src/lib.rs5
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/extra-filename-with-temp-outputs/Makefile7
-rw-r--r--tests/run-make/extra-filename-with-temp-outputs/rmake.rs23
4 files changed, 28 insertions, 8 deletions
diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs
index 5655318267a..04b6fd2d6c1 100644
--- a/src/tools/run-make-support/src/lib.rs
+++ b/src/tools/run-make-support/src/lib.rs
@@ -303,6 +303,11 @@ pub fn filename_not_in_denylist<P: AsRef<Path>, V: AsRef<[String]>>(path: P, exp
         .is_some_and(|name| !expected.contains(&name.to_str().unwrap().to_owned()))
 }
 
+/// Returns true if the filename at `path` ends with `suffix`.
+pub fn has_suffix<P: AsRef<Path>>(path: P, suffix: &str) -> bool {
+    path.as_ref().file_name().is_some_and(|name| name.to_str().unwrap().ends_with(suffix))
+}
+
 /// Gathers all files in the current working directory that have the extension `ext`, and counts
 /// the number of lines within that contain a match with the regex pattern `re`.
 pub fn count_regex_matches_in_files_with_extension(re: &regex::Regex, ext: &str) -> usize {
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index 33120cf93f9..1879d60e287 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -37,7 +37,6 @@ run-make/extern-fn-with-packed-struct/Makefile
 run-make/extern-fn-with-union/Makefile
 run-make/extern-multiple-copies/Makefile
 run-make/extern-multiple-copies2/Makefile
-run-make/extra-filename-with-temp-outputs/Makefile
 run-make/fmt-write-bloat/Makefile
 run-make/foreign-double-unwind/Makefile
 run-make/foreign-exceptions/Makefile
diff --git a/tests/run-make/extra-filename-with-temp-outputs/Makefile b/tests/run-make/extra-filename-with-temp-outputs/Makefile
deleted file mode 100644
index 64745bef5b8..00000000000
--- a/tests/run-make/extra-filename-with-temp-outputs/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# ignore-cross-compile
-include ../tools.mk
-
-all:
-	$(RUSTC) -C extra-filename=bar foo.rs -C save-temps
-	rm $(TMPDIR)/foobar.foo*0.rcgu.o
-	rm $(TMPDIR)/$(call BIN,foobar)
diff --git a/tests/run-make/extra-filename-with-temp-outputs/rmake.rs b/tests/run-make/extra-filename-with-temp-outputs/rmake.rs
new file mode 100644
index 00000000000..546e462499f
--- /dev/null
+++ b/tests/run-make/extra-filename-with-temp-outputs/rmake.rs
@@ -0,0 +1,23 @@
+// In order to prevent temporary files from overwriting each other in parallel
+// compilation, rustc was changed to mix an extra filename with temporary
+// outputs. However, as this is a similar behavior with the codegen flag
+// -C extra-filename, this test checks that the manually passed flag
+// is not overwritten by this feature, and that the output files
+// are named as expected.
+// See https://github.com/rust-lang/rust/pull/15686
+
+//FIXME(Oneirical): ignore-cross-compile
+
+use run_make_support::{
+    bin_name, cwd, fs_wrapper, has_prefix, has_suffix, rustc, shallow_find_files,
+};
+
+fn main() {
+    rustc().extra_filename("bar").input("foo.rs").arg("-Csave-temps").run();
+    let object_files = shallow_find_files(cwd(), |path| {
+        has_prefix(path, "foobar.foo") && has_suffix(path, "0.rcgu.o")
+    });
+    let object_file = object_files.get(0).unwrap();
+    fs_wrapper::remove_file(object_file);
+    fs_wrapper::remove_file(bin_name("foobar"));
+}