Use get_file_name in tests
This commit is contained in:
parent
437b441ff5
commit
ae4fe1d57d
3 changed files with 14 additions and 13 deletions
|
@ -2,7 +2,7 @@ use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::{self, Command};
|
use std::process::{self, Command};
|
||||||
|
|
||||||
use super::rustc_info::{get_file_name, get_rustc_version};
|
use super::rustc_info::{get_file_name, get_wrapper_file_name, get_rustc_version};
|
||||||
use super::utils::{spawn_and_wait, try_hard_link};
|
use super::utils::{spawn_and_wait, try_hard_link};
|
||||||
use super::SysrootKind;
|
use super::SysrootKind;
|
||||||
|
|
||||||
|
@ -37,10 +37,7 @@ pub(crate) fn build_sysroot(
|
||||||
|
|
||||||
// Build and copy rustc and cargo wrappers
|
// Build and copy rustc and cargo wrappers
|
||||||
for wrapper in ["rustc-clif", "cargo-clif"] {
|
for wrapper in ["rustc-clif", "cargo-clif"] {
|
||||||
let crate_name = wrapper.replace('-', "_");
|
let wrapper_name = get_wrapper_file_name(wrapper, "bin", target_triple);
|
||||||
let wrapper_name = get_file_name(&crate_name, "bin", target_triple);
|
|
||||||
let wrapper_name = wrapper_name.replace('_', "-");
|
|
||||||
|
|
||||||
|
|
||||||
let mut build_cargo_wrapper_cmd = Command::new("rustc");
|
let mut build_cargo_wrapper_cmd = Command::new("rustc");
|
||||||
build_cargo_wrapper_cmd
|
build_cargo_wrapper_cmd
|
||||||
|
|
|
@ -65,3 +65,12 @@ pub(crate) fn get_file_name(crate_name: &str, crate_type: &str, target: &str) ->
|
||||||
assert!(file_name.contains(crate_name));
|
assert!(file_name.contains(crate_name));
|
||||||
file_name
|
file_name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Similar to `get_file_name`, but converts any dashes (`-`) in the `crate_name` to
|
||||||
|
/// underscores (`_`). This is specially made for the the rustc and cargo wrappers
|
||||||
|
/// which have a dash in the name, and that is not allowed in a crate name.
|
||||||
|
pub(crate) fn get_wrapper_file_name(crate_name: &str, crate_type: &str, target: &str) -> String {
|
||||||
|
let crate_name = crate_name.replace('-', "_");
|
||||||
|
let wrapper_name = get_file_name(&crate_name, crate_type, target);
|
||||||
|
wrapper_name.replace('_', "-")
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use super::build_sysroot;
|
use super::build_sysroot;
|
||||||
use super::config;
|
use super::config;
|
||||||
|
use super::rustc_info::get_wrapper_file_name;
|
||||||
use super::utils::{spawn_and_wait, spawn_and_wait_with_input};
|
use super::utils::{spawn_and_wait, spawn_and_wait_with_input};
|
||||||
use build_system::SysrootKind;
|
use build_system::SysrootKind;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
@ -407,10 +408,7 @@ impl TestRunner {
|
||||||
{
|
{
|
||||||
let mut rustc_clif = self.root_dir.clone();
|
let mut rustc_clif = self.root_dir.clone();
|
||||||
rustc_clif.push("build");
|
rustc_clif.push("build");
|
||||||
rustc_clif.push("rustc-clif");
|
rustc_clif.push(get_wrapper_file_name("rustc-clif", "bin", &self.target_triple));
|
||||||
if cfg!(windows) {
|
|
||||||
rustc_clif.set_extension("exe");
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut cmd = Command::new(rustc_clif);
|
let mut cmd = Command::new(rustc_clif);
|
||||||
if !self.rust_flags.is_empty() {
|
if !self.rust_flags.is_empty() {
|
||||||
|
@ -471,10 +469,7 @@ impl TestRunner {
|
||||||
{
|
{
|
||||||
let mut cargo_clif = self.root_dir.clone();
|
let mut cargo_clif = self.root_dir.clone();
|
||||||
cargo_clif.push("build");
|
cargo_clif.push("build");
|
||||||
cargo_clif.push("cargo-clif");
|
cargo_clif.push(get_wrapper_file_name("cargo-clif", "bin", &self.target_triple));
|
||||||
if cfg!(windows) {
|
|
||||||
cargo_clif.set_extension("exe");
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut cmd = Command::new(cargo_clif);
|
let mut cmd = Command::new(cargo_clif);
|
||||||
cmd.args(args);
|
cmd.args(args);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue