diff --git a/tests/run-make/compiler-builtins/rmake.rs b/tests/run-make/compiler-builtins/rmake.rs index daa12d2986eb9..bdef0e9d70260 100644 --- a/tests/run-make/compiler-builtins/rmake.rs +++ b/tests/run-make/compiler-builtins/rmake.rs @@ -15,46 +15,38 @@ #![deny(warnings)] use std::collections::HashSet; -use std::path::PathBuf; use run_make_support::object::read::Object; use run_make_support::object::read::archive::ArchiveFile; use run_make_support::object::{ObjectSection, ObjectSymbol, RelocationTarget}; use run_make_support::rfs::{read, read_dir}; -use run_make_support::{cmd, env_var, object}; +use run_make_support::{cargo, env_var, object, path, target}; fn main() { - let target_dir = PathBuf::from("target"); - let target = env_var("TARGET"); - - println!("Testing compiler_builtins for {}", target); - - let manifest_path = PathBuf::from("Cargo.toml"); - - let path = env_var("PATH"); - let rustc = env_var("RUSTC"); - let cargo = env_var("CARGO"); - let mut cmd = cmd(cargo); - cmd.args(&[ - "build", - "--manifest-path", - manifest_path.to_str().unwrap(), - "-Zbuild-std=core", - "--target", - &target, - ]) - .env("PATH", path) - .env("RUSTC", rustc) - .env("RUSTFLAGS", "-Copt-level=0 -Cdebug-assertions=yes") - .env("CARGO_TARGET_DIR", &target_dir) - .env("RUSTC_BOOTSTRAP", "1") - // Visual Studio 2022 requires that the LIB env var be set so it can - // find the Windows SDK. - .env("LIB", std::env::var("LIB").unwrap_or_default()); - - cmd.run(); - - let rlibs_path = target_dir.join(target).join("debug").join("deps"); + let target_dir = path("target"); + + println!("Testing compiler_builtins for {}", target()); + + cargo() + .args(&[ + "build", + "--manifest-path", + "Cargo.toml", + "-Zbuild-std=core", + "--target", + &target(), + ]) + .env("PATH", env_var("PATH")) + .env("RUSTC", env_var("RUSTC")) + .env("RUSTFLAGS", "-Copt-level=0 -Cdebug-assertions=yes") + .env("CARGO_TARGET_DIR", &target_dir) + .env("RUSTC_BOOTSTRAP", "1") + // Visual Studio 2022 requires that the LIB env var be set so it can + // find the Windows SDK. + .env("LIB", std::env::var("LIB").unwrap_or_default()) + .run(); + + let rlibs_path = target_dir.join(target()).join("debug").join("deps"); let compiler_builtins_rlib = read_dir(rlibs_path) .find_map(|e| { let path = e.unwrap().path(); diff --git a/tests/run-make/thumb-none-cortex-m/rmake.rs b/tests/run-make/thumb-none-cortex-m/rmake.rs index 9112646290f20..77bd3b38982d7 100644 --- a/tests/run-make/thumb-none-cortex-m/rmake.rs +++ b/tests/run-make/thumb-none-cortex-m/rmake.rs @@ -14,10 +14,7 @@ //@ only-thumb -use std::path::PathBuf; - -use run_make_support::rfs::create_dir; -use run_make_support::{cmd, env_var, target}; +use run_make_support::{cargo, cmd, env, env_var, target}; const CRATE: &str = "cortex-m"; const CRATE_URL: &str = "https://github.com/rust-embedded/cortex-m"; @@ -28,32 +25,25 @@ fn main() { // See below link for git usage: // https://stackoverflow.com/questions/3489173#14091182 cmd("git").args(["clone", CRATE_URL, CRATE]).run(); - std::env::set_current_dir(CRATE).unwrap(); + env::set_current_dir(CRATE); cmd("git").args(["reset", "--hard", CRATE_SHA1]).run(); - let target_dir = PathBuf::from("target"); - let manifest_path = PathBuf::from("Cargo.toml"); - - let path = env_var("PATH"); - let rustc = env_var("RUSTC"); - let cargo = env_var("CARGO"); // FIXME: extract cargo invocations to a proper command // https://github.com/rust-lang/rust/issues/128734 - let mut cmd = cmd(cargo); - cmd.args(&[ - "build", - "--manifest-path", - manifest_path.to_str().unwrap(), - "-Zbuild-std=core", - "--target", - &target(), - ]) - .env("PATH", path) - .env("RUSTC", rustc) - .env("CARGO_TARGET_DIR", &target_dir) - // Don't make lints fatal, but they need to at least warn - // or they break Cargo's target info parsing. - .env("RUSTFLAGS", "-Copt-level=0 -Cdebug-assertions=yes --cap-lints=warn"); - - cmd.run(); + cargo + .args(&[ + "build", + "--manifest-path", + "Cargo.toml", + "-Zbuild-std=core", + "--target", + &target(), + ]) + .env("PATH", env_var("PATH")) + .env("RUSTC", env_var("RUSTC")) + .env("CARGO_TARGET_DIR", "target") + // Don't make lints fatal, but they need to at least warn + // or they break Cargo's target info parsing. + .env("RUSTFLAGS", "-Copt-level=0 -Cdebug-assertions=yes --cap-lints=warn") + .run(); }