about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbinarycat <binarycat@envs.net>2024-06-09 22:37:05 -0400
committerbinarycat <binarycat@envs.net>2024-06-10 05:30:58 -0400
commit91f5530b2db1ea992d4e5c3ef214609d6e9145c1 (patch)
tree28876f0a71f8de6f1850a420a346776476db2a31
parent503dfcf4e03089cf0c06d10fc69b5477a2f766ef (diff)
downloadrust-91f5530b2db1ea992d4e5c3ef214609d6e9145c1.tar.gz
rust-91f5530b2db1ea992d4e5c3ef214609d6e9145c1.zip
migrate tests/run-make/llvm-outputs to use rmake.rs
part of #121876
-rw-r--r--src/tools/run-make-support/src/rustc.rs7
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/llvm-outputs/Makefile5
-rw-r--r--tests/run-make/llvm-outputs/rmake.rs20
4 files changed, 27 insertions, 6 deletions
diff --git a/src/tools/run-make-support/src/rustc.rs b/src/tools/run-make-support/src/rustc.rs
index d4c00d23b8b..5ea231442bc 100644
--- a/src/tools/run-make-support/src/rustc.rs
+++ b/src/tools/run-make-support/src/rustc.rs
@@ -107,6 +107,13 @@ impl Rustc {
         self
     }
 
+    /// Specify path to the output directory. Equivalent to `--out-dir`` in rustc.
+    pub fn out_dir<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
+        self.cmd.arg("--out-dir");
+        self.cmd.arg(path.as_ref());
+        self
+    }
+
     /// This flag defers LTO optimizations to the linker.
     pub fn linker_plugin_lto(&mut self, option: &str) -> &mut Self {
         self.cmd.arg(format!("-Clinker-plugin-lto={option}"));
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index a015f96ae51..babf1abbe64 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -122,7 +122,6 @@ run-make/link-framework/Makefile
 run-make/link-path-order/Makefile
 run-make/linkage-attr-on-static/Makefile
 run-make/llvm-ident/Makefile
-run-make/llvm-outputs/Makefile
 run-make/long-linker-command-lines-cmd-exe/Makefile
 run-make/long-linker-command-lines/Makefile
 run-make/longjmp-across-rust/Makefile
diff --git a/tests/run-make/llvm-outputs/Makefile b/tests/run-make/llvm-outputs/Makefile
deleted file mode 100644
index cccf1dd66fb..00000000000
--- a/tests/run-make/llvm-outputs/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-include ../tools.mk
-
-all:
-	echo 'fn main() {}' | $(BARE_RUSTC) - --out-dir=$(TMPDIR)/random_directory_that_does_not_exist_ir/ --emit=llvm-ir
-	echo 'fn main() {}' | $(BARE_RUSTC) - --out-dir=$(TMPDIR)/random_directory_that_does_not_exist_bc/ --emit=llvm-bc
diff --git a/tests/run-make/llvm-outputs/rmake.rs b/tests/run-make/llvm-outputs/rmake.rs
new file mode 100644
index 00000000000..2dc3030ca91
--- /dev/null
+++ b/tests/run-make/llvm-outputs/rmake.rs
@@ -0,0 +1,20 @@
+// test that directories get created when emitting llvm bitcode and IR
+
+use run_make_support::{cwd, run_in_tmpdir, rustc};
+use std::path::PathBuf;
+
+fn main() {
+    let mut path_bc = PathBuf::new();
+    let mut path_ir = PathBuf::new();
+    run_in_tmpdir(|| {
+        let p = cwd();
+        path_bc = p.join("nonexistant_dir_bc");
+        path_ir = p.join("nonexistant_dir_ir");
+        rustc().input("-").stdin("fn main() {}").out_dir(&path_bc).emit("llvm-bc").run();
+        rustc().input("-").stdin("fn main() {}").out_dir(&path_ir).emit("llvm-ir").run();
+        assert!(path_bc.exists());
+        assert!(path_ir.exists());
+    });
+    assert!(!path_bc.exists());
+    assert!(!path_ir.exists());
+}