File tree 3 files changed +24
-1
lines changed
crates/cargo-test-support/src
3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,17 @@ pub fn echo_wrapper() -> PathBuf {
24
24
. file (
25
25
"src/main.rs" ,
26
26
r#"
27
+ use std::fs::read_to_string;
28
+ use std::path::PathBuf;
27
29
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<_>>();
29
38
eprintln!("WRAPPER CALLED: {}", args[1..].join(" "));
30
39
let status = std::process::Command::new(&args[1])
31
40
.args(&args[2..]).status().unwrap();
Original file line number Diff line number Diff line change @@ -89,8 +89,14 @@ fn broken_fixes_backed_out() {
89
89
90
90
fn main() {
91
91
// Ignore calls to things like --print=file-names and compiling build.rs.
92
+ // Also compatible for rustc invocations with `@path` argfile.
92
93
let is_lib_rs = env::args_os()
93
94
.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
+ })
94
100
.any(|l| l == Path::new("src/lib.rs"));
95
101
if is_lib_rs {
96
102
let path = PathBuf::from(env::var_os("OUT_DIR").unwrap());
@@ -1319,8 +1325,15 @@ fn fix_to_broken_code() {
1319
1325
use std::process::{self, Command};
1320
1326
1321
1327
fn main() {
1328
+ // Ignore calls to things like --print=file-names and compiling build.rs.
1329
+ // Also compatible for rustc invocations with `@path` argfile.
1322
1330
let is_lib_rs = env::args_os()
1323
1331
.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
+ })
1324
1337
.any(|l| l == Path::new("src/lib.rs"));
1325
1338
if is_lib_rs {
1326
1339
let path = PathBuf::from(env::var_os("OUT_DIR").unwrap());
Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ fn whitespace() {
112
112
113
113
const SPACED_VERSION : & str = "a\n b\t c\u{00a0} d" ;
114
114
p. cargo ( "doc" )
115
+ . env_remove ( "__CARGO_TEST_FORCE_ARGFILE" ) // Not applicable for argfile.
115
116
. env (
116
117
"RUSTDOCFLAGS" ,
117
118
format ! ( "--crate-version {}" , SPACED_VERSION ) ,
You can’t perform that action at this time.
0 commit comments