File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -1177,7 +1177,8 @@ fn cargo(
1177
1177
}
1178
1178
1179
1179
let cargo_target_dir = format ! ( "{}" , platform:: binary_cache_path( ) ?. display( ) , ) ;
1180
- cmd. env ( "CARGO_TARGET_DIR" , cargo_target_dir) ;
1180
+ cmd. arg ( "--target-dir" ) ;
1181
+ cmd. arg ( cargo_target_dir) ;
1181
1182
1182
1183
// Block `--release` on `bench`.
1183
1184
if !meta. debug && cmd_name != "bench" {
Original file line number Diff line number Diff line change
1
+ use std:: env;
2
+
3
+ pub fn main ( ) {
4
+ // Test that CARGO_TARGET_DIR is not set by rust-script to avoid
5
+ // interfering with cargo calls done by the script.
6
+ // See https://github.com/fornwall/rust-script/issues/27
7
+ let env_variable = env:: var ( "CARGO_TARGET_DIR" ) ;
8
+ println ! ( "--output--" ) ;
9
+ println ! (
10
+ "{:?}" ,
11
+ matches!( env_variable, Err ( env:: VarError :: NotPresent ) )
12
+ ) ;
13
+ }
Original file line number Diff line number Diff line change @@ -171,13 +171,22 @@ fn test_pub_fn_main() {
171
171
. unwrap ( )
172
172
}
173
173
174
+ #[ test]
175
+ fn test_cargo_target_dir_env ( ) {
176
+ let out = rust_script ! ( "tests/data/cargo-target-dir-env.rs" ) . unwrap ( ) ;
177
+ scan ! ( out. stdout_output( ) ;
178
+ ( "true" ) => ( )
179
+ )
180
+ . unwrap ( )
181
+ }
182
+
174
183
#[ test]
175
184
fn test_outer_line_doc ( ) {
176
185
let out = rust_script ! ( "tests/data/outer-line-doc.rs" ) . unwrap ( ) ;
177
186
scan ! ( out. stdout_output( ) ;
178
187
( "Some(1)" ) => ( )
179
188
)
180
- . unwrap ( )
189
+ . unwrap ( )
181
190
}
182
191
183
192
#[ test]
You can’t perform that action at this time.
0 commit comments