Skip to content

Commit 11676be

Browse files
committed
new helper functions + arg_path generic
1 parent e473b04 commit 11676be

File tree

2 files changed

+23
-10
lines changed
  • src/tools/run-make-support/src
  • tests/run-make/core-no-fp-fmt-parse

2 files changed

+23
-10
lines changed

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

+19-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,25 @@ impl Rustc {
106106
}
107107

108108
/// Generic file path provider.
109-
pub fn arg_path(&mut self, path: &[&str]) -> &mut Self {
110-
let path_buf = path.iter().collect::<PathBuf>();
111-
self.cmd.arg(path_buf.to_str().unwrap());
109+
pub fn arg_path<P>(&mut self, path: P) -> &mut Self
110+
where
111+
P: AsRef<Path>,
112+
{
113+
self.cmd.arg(path.as_ref());
114+
self
115+
}
116+
117+
/// Specify the crate type.
118+
pub fn crate_type(&mut self, crate_type: &str) -> &mut Self {
119+
self.cmd.arg("--crate-type");
120+
self.cmd.arg(crate_type);
121+
self
122+
}
123+
124+
/// Specify the edition year.
125+
pub fn edition(&mut self, edition: &str) -> &mut Self {
126+
self.cmd.arg("--edition");
127+
self.cmd.arg(edition);
112128
self
113129
}
114130

tests/run-make/core-no-fp-fmt-parse/rmake.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ use std::path::PathBuf;
88

99
fn main() {
1010
rustc()
11-
.arg("--edition")
12-
.arg("2021")
11+
.edition("2021")
1312
.arg("-Dwarnings")
14-
.arg("--crate-type")
15-
.arg("rlib")
16-
.arg_path(&["..", "..", "..", "library", "core", "src", "lib.rs"])
17-
.arg("--cfg")
18-
.arg("no_fp_fmt_parse")
13+
.crate_type("rlib")
14+
.arg_path("../../../library/core/src/lib.rs")
15+
.cfg("no_fp_fmt_parse")
1916
.run();
2017
}

0 commit comments

Comments
 (0)