Skip to content

Commit 6b73dbc

Browse files
committed
migrate tests/run-make/llvm-outputs to use rmake.rs
part of #121876
1 parent 503dfcf commit 6b73dbc

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

src/tools/run-make-support/src/rustc.rs

+7
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ impl Rustc {
107107
self
108108
}
109109

110+
/// Specify path to the output directory. Equivalent to `--out-dir`` in rustc.
111+
pub fn out_dir<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
112+
self.cmd.arg("--out-dir");
113+
self.cmd.arg(path.as_ref());
114+
self
115+
}
116+
110117
/// This flag defers LTO optimizations to the linker.
111118
pub fn linker_plugin_lto(&mut self, option: &str) -> &mut Self {
112119
self.cmd.arg(format!("-Clinker-plugin-lto={option}"));

tests/run-make/llvm-outputs/Makefile

-5
This file was deleted.

tests/run-make/llvm-outputs/rmake.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// test that directories get created when emitting llvm bitcode and IR
2+
3+
use run_make_support::{rustc, run_in_tmpdir, cwd};
4+
use std::path::PathBuf;
5+
6+
fn main() {
7+
let mut path_bc = PathBuf::new();
8+
let mut path_ir = PathBuf::new();
9+
run_in_tmpdir(|| {
10+
let p = cwd();
11+
path_bc = p.join("nonexistant_dir_bc");
12+
path_ir = p.join("nonexistant_dir_ir");
13+
rustc().input("-").stdin("fn main() {}")
14+
.out_dir(&path_bc).arg("--emit=llvm-bc").run();
15+
rustc().input("-").stdin("fn main() {}")
16+
.out_dir(&path_ir).arg("--emit=llvm-ir").run();
17+
assert!(path_bc.exists());
18+
assert!(path_ir.exists());
19+
});
20+
assert!(!path_bc.exists());
21+
assert!(!path_ir.exists());
22+
}

0 commit comments

Comments
 (0)