Skip to content

Commit

Permalink
migrate tests/run-make/llvm-outputs to use rmake.rs
Browse files Browse the repository at this point in the history
part of #121876
  • Loading branch information
lolbinarycat committed Jun 10, 2024
1 parent 503dfcf commit 6b73dbc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/tools/run-make-support/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"));
Expand Down
5 changes: 0 additions & 5 deletions tests/run-make/llvm-outputs/Makefile

This file was deleted.

22 changes: 22 additions & 0 deletions tests/run-make/llvm-outputs/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// test that directories get created when emitting llvm bitcode and IR

use run_make_support::{rustc, run_in_tmpdir, cwd};
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).arg("--emit=llvm-bc").run();
rustc().input("-").stdin("fn main() {}")
.out_dir(&path_ir).arg("--emit=llvm-ir").run();
assert!(path_bc.exists());
assert!(path_ir.exists());
});
assert!(!path_bc.exists());
assert!(!path_ir.exists());
}

0 comments on commit 6b73dbc

Please sign in to comment.