@@ -146,6 +146,27 @@ mod sealed {
146146
147147pub const ERROR_EXIT_CODE : i32 = 101 ;
148148
149+ fn expand_args (
150+ args : impl IntoIterator < Item = impl Into < std:: ffi:: OsString > > ,
151+ ) -> std:: io:: Result < Vec < std:: ffi:: OsString > > {
152+ let mut expanded = Vec :: new ( ) ;
153+ for arg in args {
154+ let arg = arg. into ( ) ;
155+ if let Some ( argfile) = arg. to_str ( ) . and_then ( |s| s. strip_prefix ( "@" ) ) {
156+ expanded. extend ( parse_argfile ( std:: path:: Path :: new ( argfile) ) ?) ;
157+ } else {
158+ expanded. push ( arg) ;
159+ }
160+ }
161+ Ok ( expanded)
162+ }
163+
164+ fn parse_argfile ( path : & std:: path:: Path ) -> std:: io:: Result < Vec < std:: ffi:: OsString > > {
165+ // Logic taken from rust-lang/rust's `compiler/rustc_driver_impl/src/args.rs`
166+ let content = std:: fs:: read_to_string ( path) ?;
167+ Ok ( content. lines ( ) . map ( |s| s. into ( ) ) . collect ( ) )
168+ }
169+
149170fn parse < ' p > ( parser : & mut cli:: Parser < ' p > ) -> Result < libtest_lexarg:: TestOpts , cli:: LexError < ' p > > {
150171 let mut test_opts = libtest_lexarg:: TestOptsBuilder :: new ( ) ;
151172
@@ -204,27 +225,6 @@ fn parse<'p>(parser: &mut cli::Parser<'p>) -> Result<libtest_lexarg::TestOpts, c
204225 Ok ( opts)
205226}
206227
207- fn expand_args (
208- args : impl IntoIterator < Item = impl Into < std:: ffi:: OsString > > ,
209- ) -> std:: io:: Result < Vec < std:: ffi:: OsString > > {
210- let mut expanded = Vec :: new ( ) ;
211- for arg in args {
212- let arg = arg. into ( ) ;
213- if let Some ( argfile) = arg. to_str ( ) . and_then ( |s| s. strip_prefix ( "@" ) ) {
214- expanded. extend ( parse_argfile ( std:: path:: Path :: new ( argfile) ) ?) ;
215- } else {
216- expanded. push ( arg) ;
217- }
218- }
219- Ok ( expanded)
220- }
221-
222- fn parse_argfile ( path : & std:: path:: Path ) -> std:: io:: Result < Vec < std:: ffi:: OsString > > {
223- // Logic taken from rust-lang/rust's `compiler/rustc_driver_impl/src/args.rs`
224- let content = std:: fs:: read_to_string ( path) ?;
225- Ok ( content. lines ( ) . map ( |s| s. into ( ) ) . collect ( ) )
226- }
227-
228228fn notifier ( opts : & libtest_lexarg:: TestOpts ) -> Box < dyn notify:: Notifier > {
229229 #[ cfg( feature = "color" ) ]
230230 let stdout = anstream:: stdout ( ) ;
0 commit comments