Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 27e6741

Browse files
committedMay 5, 2024
Add new output method to Rustc and Rustdoc types
1 parent c04d09a commit 27e6741

File tree

6 files changed

+29
-14
lines changed

6 files changed

+29
-14
lines changed
 

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

+7
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ impl Rustc {
9191
self
9292
}
9393

94+
/// Specify path to the output file.
95+
pub fn output<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
96+
self.cmd.arg("-o");
97+
self.cmd.arg(path.as_ref());
98+
self
99+
}
100+
94101
/// This flag defers LTO optimizations to the linker.
95102
pub fn linker_plugin_lto(&mut self, option: &str) -> &mut Self {
96103
self.cmd.arg(format!("-Clinker-plugin-lto={option}"));

‎src/tools/run-make-support/src/rustdoc.rs

+7
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ impl Rustdoc {
5151
self
5252
}
5353

54+
/// Specify path to the output folder.
55+
pub fn output<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
56+
self.cmd.arg("-o");
57+
self.cmd.arg(path.as_ref());
58+
self
59+
}
60+
5461
/// Specify output directory.
5562
pub fn out_dir<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
5663
self.cmd.arg("--out-dir").arg(path.as_ref());

‎tests/run-make/doctests-runtool/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919
let run_tool_binary = run_tool.join("runtool");
2020

2121
rustc().input("t.rs").crate_type("rlib").run();
22-
rustc().input("runtool.rs").arg("-o").arg(&run_tool_binary).run();
22+
rustc().input("runtool.rs").output(&run_tool_binary).run();
2323

2424
rustdoc()
2525
.input(current_dir().unwrap().join("t.rs"))

‎tests/run-make/exit-code/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() {
1515
.arg("compile-error.rs")
1616
.run_fail_assert_exit_code(101);
1717

18-
rustdoc().arg("success.rs").arg("-o").arg(tmp_dir().join("exit-code")).run();
18+
rustdoc().arg("success.rs").output(tmp_dir().join("exit-code")).run();
1919

2020
rustdoc().arg("--invalid-arg-foo").run_fail_assert_exit_code(1);
2121

‎tests/run-make/repr128-dwarf/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::rc::Rc;
1010

1111
fn main() {
1212
let output = tmp_dir().join("repr128");
13-
rustc().input("main.rs").arg("-o").arg(&output).arg("-Cdebuginfo=2").run();
13+
rustc().input("main.rs").output(&output).arg("-Cdebuginfo=2").run();
1414
// Mach-O uses packed debug info
1515
let dsym_location = output
1616
.with_extension("dSYM")
+12-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
use run_make_support::{diff, rustc, rustdoc, tmp_dir};
1+
// Assert that the search index is generated deterministically, regardless of the
2+
// order that crates are documented in.
3+
4+
use run_make_support::{diff, rustdoc, tmp_dir};
25

3-
/// Assert that the search index is generated deterministically, regardless of the
4-
/// order that crates are documented in.
56
fn main() {
6-
let dir_first = tmp_dir().join("first");
7-
rustdoc().out_dir(&dir_first).input("foo.rs").run();
8-
rustdoc().out_dir(&dir_first).input("bar.rs").run();
7+
let foo_first = tmp_dir().join("foo_first");
8+
rustdoc().input("foo.rs").output(&foo_first).run();
9+
rustdoc().input("bar.rs").output(&foo_first).run();
910

10-
let dir_second = tmp_dir().join("second");
11-
rustdoc().out_dir(&dir_second).input("bar.rs").run();
12-
rustdoc().out_dir(&dir_second).input("foo.rs").run();
11+
let bar_first = tmp_dir().join("bar_first");
12+
rustdoc().input("bar.rs").output(&bar_first).run();
13+
rustdoc().input("foo.rs").output(&bar_first).run();
1314

1415
diff()
15-
.expected_file(dir_first.join("search-index.js"))
16-
.actual_file(dir_second.join("search-index.js"))
16+
.expected_file(foo_first.join("search-index.js"))
17+
.actual_file(bar_first.join("search-index.js"))
1718
.run();
1819
}

0 commit comments

Comments
 (0)
Failed to load comments.