Skip to content

Commit 983fe4f

Browse files
committed
Simplify configure_with_args
1 parent 5b50e0b commit 983fe4f

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/bootstrap/src/core/builder/tests.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ static TEST_TRIPLE_2: &str = "i686-unknown-hurd-gnu";
1515
static TEST_TRIPLE_3: &str = "i686-unknown-netbsd";
1616

1717
fn configure(cmd: &str, host: &[&str], target: &[&str]) -> Config {
18-
configure_with_args(&[cmd.to_owned()], host, target)
18+
configure_with_args(&[cmd], host, target)
1919
}
2020

21-
fn configure_with_args(cmd: &[String], host: &[&str], target: &[&str]) -> Config {
22-
let mut config = Config::parse(Flags::parse(cmd));
21+
fn configure_with_args(cmd: &[&str], host: &[&str], target: &[&str]) -> Config {
22+
let cmd = cmd.iter().copied().map(String::from).collect::<Vec<_>>();
23+
let mut config = Config::parse(Flags::parse(&cmd));
2324
// don't save toolstates
2425
config.save_toolstates = None;
2526
config.set_dry_run(DryRun::SelfCheck);
@@ -67,7 +68,7 @@ fn run_build(paths: &[PathBuf], config: Config) -> Cache {
6768
fn check_cli<const N: usize>(paths: [&str; N]) {
6869
run_build(
6970
&paths.map(PathBuf::from),
70-
configure_with_args(&paths.map(String::from), &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]),
71+
configure_with_args(&paths, &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]),
7172
);
7273
}
7374

@@ -1000,8 +1001,7 @@ mod sysroot_target_dirs {
10001001
/// cg_gcc tests instead.
10011002
#[test]
10021003
fn test_test_compiler() {
1003-
let cmd = &["test", "compiler"].map(str::to_owned);
1004-
let config = configure_with_args(cmd, &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]);
1004+
let config = configure_with_args(&["test", "compiler"], &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]);
10051005
let cache = run_build(&config.paths.clone(), config);
10061006

10071007
let compiler = cache.contains::<test::CrateLibrustc>();
@@ -1034,8 +1034,7 @@ fn test_test_coverage() {
10341034
// Print each test case so that if one fails, the most recently printed
10351035
// case is the one that failed.
10361036
println!("Testing case: {cmd:?}");
1037-
let cmd = cmd.iter().copied().map(str::to_owned).collect::<Vec<_>>();
1038-
let config = configure_with_args(&cmd, &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]);
1037+
let config = configure_with_args(cmd, &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]);
10391038
let mut cache = run_build(&config.paths.clone(), config);
10401039

10411040
let modes =
@@ -1207,8 +1206,7 @@ fn test_get_tool_rustc_compiler() {
12071206
/// of `Any { .. }`.
12081207
#[test]
12091208
fn step_cycle_debug() {
1210-
let cmd = ["run", "cyclic-step"].map(str::to_owned);
1211-
let config = configure_with_args(&cmd, &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]);
1209+
let config = configure_with_args(&["run", "cyclic-step"], &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]);
12121210

12131211
let err = panic::catch_unwind(|| run_build(&config.paths.clone(), config)).unwrap_err();
12141212
let err = err.downcast_ref::<String>().unwrap().as_str();

0 commit comments

Comments
 (0)