From 823b423d4c789a2282dc6d25fd8182e845e351ff Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 5 May 2024 16:26:35 +0200 Subject: [PATCH] Add new `output` method to `Rustc` and `Rustdoc` types --- src/tools/run-make-support/src/rustc.rs | 7 +++++++ src/tools/run-make-support/src/rustdoc.rs | 7 +++++++ tests/run-make/doctests-runtool/rmake.rs | 2 +- tests/run-make/exit-code/rmake.rs | 2 +- tests/run-make/repr128-dwarf/rmake.rs | 2 +- tests/run-make/rustdoc-determinism/rmake.rs | 23 +++++++++++---------- tests/run-make/wasm-abi/rmake.rs | 2 +- 7 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/tools/run-make-support/src/rustc.rs b/src/tools/run-make-support/src/rustc.rs index dcd184ac5a458..de773d688ef00 100644 --- a/src/tools/run-make-support/src/rustc.rs +++ b/src/tools/run-make-support/src/rustc.rs @@ -91,6 +91,13 @@ impl Rustc { self } + /// Specify path to the output file. + pub fn output>(&mut self, path: P) -> &mut Self { + self.cmd.arg("-o"); + 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/run-make-support/src/rustdoc.rs b/src/tools/run-make-support/src/rustdoc.rs index ba8668a3b4c6f..aa3c7dcf0e356 100644 --- a/src/tools/run-make-support/src/rustdoc.rs +++ b/src/tools/run-make-support/src/rustdoc.rs @@ -51,6 +51,13 @@ impl Rustdoc { self } + /// Specify path to the output folder. + pub fn output>(&mut self, path: P) -> &mut Self { + self.cmd.arg("-o"); + self.cmd.arg(path.as_ref()); + self + } + /// Specify output directory. pub fn out_dir>(&mut self, path: P) -> &mut Self { self.cmd.arg("--out-dir").arg(path.as_ref()); diff --git a/tests/run-make/doctests-runtool/rmake.rs b/tests/run-make/doctests-runtool/rmake.rs index 164514095289e..6f89bf23b47c4 100644 --- a/tests/run-make/doctests-runtool/rmake.rs +++ b/tests/run-make/doctests-runtool/rmake.rs @@ -19,7 +19,7 @@ fn main() { let run_tool_binary = run_tool.join("runtool"); rustc().input("t.rs").crate_type("rlib").run(); - rustc().input("runtool.rs").arg("-o").arg(&run_tool_binary).run(); + rustc().input("runtool.rs").output(&run_tool_binary).run(); rustdoc() .input(current_dir().unwrap().join("t.rs")) diff --git a/tests/run-make/exit-code/rmake.rs b/tests/run-make/exit-code/rmake.rs index b1143153d0af0..76d7777581b5e 100644 --- a/tests/run-make/exit-code/rmake.rs +++ b/tests/run-make/exit-code/rmake.rs @@ -15,7 +15,7 @@ fn main() { .arg("compile-error.rs") .run_fail_assert_exit_code(101); - rustdoc().arg("success.rs").arg("-o").arg(tmp_dir().join("exit-code")).run(); + rustdoc().arg("success.rs").output(tmp_dir().join("exit-code")).run(); rustdoc().arg("--invalid-arg-foo").run_fail_assert_exit_code(1); diff --git a/tests/run-make/repr128-dwarf/rmake.rs b/tests/run-make/repr128-dwarf/rmake.rs index d734b2add79a2..fd5dd81044419 100644 --- a/tests/run-make/repr128-dwarf/rmake.rs +++ b/tests/run-make/repr128-dwarf/rmake.rs @@ -10,7 +10,7 @@ use std::rc::Rc; fn main() { let output = tmp_dir().join("repr128"); - rustc().input("main.rs").arg("-o").arg(&output).arg("-Cdebuginfo=2").run(); + rustc().input("main.rs").output(&output).arg("-Cdebuginfo=2").run(); // Mach-O uses packed debug info let dsym_location = output .with_extension("dSYM") diff --git a/tests/run-make/rustdoc-determinism/rmake.rs b/tests/run-make/rustdoc-determinism/rmake.rs index 38ae75199fd83..09097d4507daf 100644 --- a/tests/run-make/rustdoc-determinism/rmake.rs +++ b/tests/run-make/rustdoc-determinism/rmake.rs @@ -1,18 +1,19 @@ -use run_make_support::{diff, rustc, rustdoc, tmp_dir}; +// Assert that the search index is generated deterministically, regardless of the +// order that crates are documented in. + +use run_make_support::{diff, rustdoc, tmp_dir}; -/// Assert that the search index is generated deterministically, regardless of the -/// order that crates are documented in. fn main() { - let dir_first = tmp_dir().join("first"); - rustdoc().out_dir(&dir_first).input("foo.rs").run(); - rustdoc().out_dir(&dir_first).input("bar.rs").run(); + let foo_first = tmp_dir().join("foo_first"); + rustdoc().input("foo.rs").output(&foo_first).run(); + rustdoc().input("bar.rs").output(&foo_first).run(); - let dir_second = tmp_dir().join("second"); - rustdoc().out_dir(&dir_second).input("bar.rs").run(); - rustdoc().out_dir(&dir_second).input("foo.rs").run(); + let bar_first = tmp_dir().join("bar_first"); + rustdoc().input("bar.rs").output(&bar_first).run(); + rustdoc().input("foo.rs").output(&bar_first).run(); diff() - .expected_file(dir_first.join("search-index.js")) - .actual_file(dir_second.join("search-index.js")) + .expected_file(foo_first.join("search-index.js")) + .actual_file(bar_first.join("search-index.js")) .run(); } diff --git a/tests/run-make/wasm-abi/rmake.rs b/tests/run-make/wasm-abi/rmake.rs index 01f2b274423f4..a2dcafbbe0f14 100644 --- a/tests/run-make/wasm-abi/rmake.rs +++ b/tests/run-make/wasm-abi/rmake.rs @@ -25,7 +25,7 @@ fn run(file: &Path, method: &str, expected_output: &str) { .arg("--invoke") .arg(method) .arg(file) - .command_output() + .output() .unwrap(); assert!(output.status.success()); assert_eq!(expected_output, String::from_utf8_lossy(&output.stdout));