@@ -276,3 +276,92 @@ MAIN ENV_TEST:from-env
276
276
"# ] ] )
277
277
. run ( ) ;
278
278
}
279
+
280
+ #[ cargo_test]
281
+ fn env_changed_defined_in_config_toml ( ) {
282
+ let p = project ( )
283
+ . file ( "Cargo.toml" , & basic_bin_manifest ( "foo" ) )
284
+ . file (
285
+ "src/main.rs" ,
286
+ r#"
287
+ use std::env;
288
+ fn main() {
289
+ println!( "{}", env!("ENV_TEST") );
290
+ }
291
+ "# ,
292
+ )
293
+ . file (
294
+ ".cargo/config.toml" ,
295
+ r#"
296
+ [env]
297
+ ENV_TEST = "from-config"
298
+ "# ,
299
+ )
300
+ . build ( ) ;
301
+
302
+ p. cargo ( "run" )
303
+ . with_stdout_data ( str![ [ r#"
304
+ from-config
305
+
306
+ "# ] ] )
307
+ . with_stderr_data ( str![ [ r#"
308
+ [COMPILING] foo v0.5.0 ([ROOT]/foo)
309
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
310
+ [RUNNING] `target/debug/foo[EXE]`
311
+
312
+ "# ] ] )
313
+ . run ( ) ;
314
+
315
+ p. cargo ( "run" )
316
+ . env ( "ENV_TEST" , "from-env" )
317
+ . with_stdout_data ( str![ [ r#"
318
+ from-config
319
+
320
+ "# ] ] )
321
+ . with_stderr_data ( str![ [ r#"
322
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
323
+ [RUNNING] `target/debug/foo[EXE]`
324
+
325
+ "# ] ] )
326
+ . run ( ) ;
327
+ }
328
+
329
+ #[ cargo_test]
330
+ fn env_changed_defined_in_config_args ( ) {
331
+ let p = project ( )
332
+ . file ( "Cargo.toml" , & basic_bin_manifest ( "foo" ) )
333
+ . file (
334
+ "src/main.rs" ,
335
+ r#"
336
+ use std::env;
337
+ fn main() {
338
+ println!( "{}", env!("ENV_TEST") );
339
+ }
340
+ "# ,
341
+ )
342
+ . build ( ) ;
343
+ p. cargo ( r#"run --config 'env.ENV_TEST="one"'"# )
344
+ . with_stdout_data ( str![ [ r#"
345
+ one
346
+
347
+ "# ] ] )
348
+ . with_stderr_data ( str![ [ r#"
349
+ [COMPILING] foo v0.5.0 ([ROOT]/foo)
350
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
351
+ [RUNNING] `target/debug/foo[EXE]`
352
+
353
+ "# ] ] )
354
+ . run ( ) ;
355
+
356
+ p. cargo ( r#"run --config 'env.ENV_TEST="two"'"# )
357
+ . with_stdout_data ( str![ [ r#"
358
+ one
359
+
360
+ "# ] ] )
361
+ . with_stderr_data ( str![ [ r#"
362
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
363
+ [RUNNING] `target/debug/foo[EXE]`
364
+
365
+ "# ] ] )
366
+ . run ( ) ;
367
+ }
0 commit comments