mirror of
https://github.com/rust-lang/cargo
synced 2024-10-03 22:43:59 +00:00
test: make tests compatible when force using argfile
This commit is contained in:
parent
7146111afe
commit
d813739c76
|
@ -24,8 +24,17 @@ pub fn echo_wrapper() -> PathBuf {
|
|||
.file(
|
||||
"src/main.rs",
|
||||
r#"
|
||||
use std::fs::read_to_string;
|
||||
use std::path::PathBuf;
|
||||
fn main() {
|
||||
let args = std::env::args().collect::<Vec<_>>();
|
||||
// Handle args from `@path` argfile for rustc
|
||||
let args = std::env::args()
|
||||
.flat_map(|p| if let Some(p) = p.strip_prefix("@") {
|
||||
read_to_string(p).unwrap().lines().map(String::from).collect()
|
||||
} else {
|
||||
vec![p]
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
eprintln!("WRAPPER CALLED: {}", args[1..].join(" "));
|
||||
let status = std::process::Command::new(&args[1])
|
||||
.args(&args[2..]).status().unwrap();
|
||||
|
|
|
@ -89,8 +89,14 @@ fn broken_fixes_backed_out() {
|
|||
|
||||
fn main() {
|
||||
// Ignore calls to things like --print=file-names and compiling build.rs.
|
||||
// Also compatible for rustc invocations with `@path` argfile.
|
||||
let is_lib_rs = env::args_os()
|
||||
.map(PathBuf::from)
|
||||
.flat_map(|p| if let Some(p) = p.to_str().unwrap_or_default().strip_prefix("@") {
|
||||
fs::read_to_string(p).unwrap().lines().map(PathBuf::from).collect()
|
||||
} else {
|
||||
vec![p]
|
||||
})
|
||||
.any(|l| l == Path::new("src/lib.rs"));
|
||||
if is_lib_rs {
|
||||
let path = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||
|
@ -1319,8 +1325,15 @@ fn fix_to_broken_code() {
|
|||
use std::process::{self, Command};
|
||||
|
||||
fn main() {
|
||||
// Ignore calls to things like --print=file-names and compiling build.rs.
|
||||
// Also compatible for rustc invocations with `@path` argfile.
|
||||
let is_lib_rs = env::args_os()
|
||||
.map(PathBuf::from)
|
||||
.flat_map(|p| if let Some(p) = p.to_str().unwrap_or_default().strip_prefix("@") {
|
||||
fs::read_to_string(p).unwrap().lines().map(PathBuf::from).collect()
|
||||
} else {
|
||||
vec![p]
|
||||
})
|
||||
.any(|l| l == Path::new("src/lib.rs"));
|
||||
if is_lib_rs {
|
||||
let path = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||
|
|
|
@ -112,6 +112,7 @@ fn whitespace() {
|
|||
|
||||
const SPACED_VERSION: &str = "a\nb\tc\u{00a0}d";
|
||||
p.cargo("doc")
|
||||
.env_remove("__CARGO_TEST_FORCE_ARGFILE") // Not applicable for argfile.
|
||||
.env(
|
||||
"RUSTDOCFLAGS",
|
||||
format!("--crate-version {}", SPACED_VERSION),
|
||||
|
|
Loading…
Reference in a new issue