Skip to content

Commit d813739

Browse files
committed
test: make tests compatible when force using argfile
1 parent 7146111 commit d813739

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

crates/cargo-test-support/src/tools.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,17 @@ pub fn echo_wrapper() -> PathBuf {
2424
.file(
2525
"src/main.rs",
2626
r#"
27+
use std::fs::read_to_string;
28+
use std::path::PathBuf;
2729
fn main() {
28-
let args = std::env::args().collect::<Vec<_>>();
30+
// Handle args from `@path` argfile for rustc
31+
let args = std::env::args()
32+
.flat_map(|p| if let Some(p) = p.strip_prefix("@") {
33+
read_to_string(p).unwrap().lines().map(String::from).collect()
34+
} else {
35+
vec![p]
36+
})
37+
.collect::<Vec<_>>();
2938
eprintln!("WRAPPER CALLED: {}", args[1..].join(" "));
3039
let status = std::process::Command::new(&args[1])
3140
.args(&args[2..]).status().unwrap();

tests/testsuite/fix.rs

+13
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,14 @@ fn broken_fixes_backed_out() {
8989
9090
fn main() {
9191
// Ignore calls to things like --print=file-names and compiling build.rs.
92+
// Also compatible for rustc invocations with `@path` argfile.
9293
let is_lib_rs = env::args_os()
9394
.map(PathBuf::from)
95+
.flat_map(|p| if let Some(p) = p.to_str().unwrap_or_default().strip_prefix("@") {
96+
fs::read_to_string(p).unwrap().lines().map(PathBuf::from).collect()
97+
} else {
98+
vec![p]
99+
})
94100
.any(|l| l == Path::new("src/lib.rs"));
95101
if is_lib_rs {
96102
let path = PathBuf::from(env::var_os("OUT_DIR").unwrap());
@@ -1319,8 +1325,15 @@ fn fix_to_broken_code() {
13191325
use std::process::{self, Command};
13201326
13211327
fn main() {
1328+
// Ignore calls to things like --print=file-names and compiling build.rs.
1329+
// Also compatible for rustc invocations with `@path` argfile.
13221330
let is_lib_rs = env::args_os()
13231331
.map(PathBuf::from)
1332+
.flat_map(|p| if let Some(p) = p.to_str().unwrap_or_default().strip_prefix("@") {
1333+
fs::read_to_string(p).unwrap().lines().map(PathBuf::from).collect()
1334+
} else {
1335+
vec![p]
1336+
})
13241337
.any(|l| l == Path::new("src/lib.rs"));
13251338
if is_lib_rs {
13261339
let path = PathBuf::from(env::var_os("OUT_DIR").unwrap());

tests/testsuite/rustdocflags.rs

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ fn whitespace() {
112112

113113
const SPACED_VERSION: &str = "a\nb\tc\u{00a0}d";
114114
p.cargo("doc")
115+
.env_remove("__CARGO_TEST_FORCE_ARGFILE") // Not applicable for argfile.
115116
.env(
116117
"RUSTDOCFLAGS",
117118
format!("--crate-version {}", SPACED_VERSION),

0 commit comments

Comments
 (0)