@@ -1598,7 +1598,15 @@ impl<'test> TestCx<'test> {
15981598 }
15991599
16001600 fn exec_compiled_test ( & self ) -> ProcRes {
1601- let env = & self . props . exec_env ;
1601+ let prepare_env = |cmd : & mut Command | {
1602+ for key in & self . props . unset_exec_env {
1603+ cmd. env_remove ( key) ;
1604+ }
1605+
1606+ for ( key, val) in & self . props . exec_env {
1607+ cmd. env ( key, val) ;
1608+ }
1609+ } ;
16021610
16031611 let proc_res = match & * self . config . target {
16041612 // This is pretty similar to below, we're transforming:
@@ -1635,10 +1643,7 @@ impl<'test> TestCx<'test> {
16351643 . args ( support_libs)
16361644 . args ( args) ;
16371645
1638- for key in & self . props . unset_exec_env {
1639- test_client. env_remove ( key) ;
1640- }
1641- test_client. envs ( env. clone ( ) ) ;
1646+ prepare_env ( & mut test_client) ;
16421647
16431648 self . compose_and_run (
16441649 test_client,
@@ -1653,10 +1658,7 @@ impl<'test> TestCx<'test> {
16531658 let mut wr_run = Command :: new ( "wr-run" ) ;
16541659 wr_run. args ( & [ & prog] ) . args ( args) ;
16551660
1656- for key in & self . props . unset_exec_env {
1657- wr_run. env_remove ( key) ;
1658- }
1659- wr_run. envs ( env. clone ( ) ) ;
1661+ prepare_env ( & mut wr_run) ;
16601662
16611663 self . compose_and_run (
16621664 wr_run,
@@ -1671,10 +1673,7 @@ impl<'test> TestCx<'test> {
16711673 let mut program = Command :: new ( & prog) ;
16721674 program. args ( args) . current_dir ( & self . output_base_dir ( ) ) ;
16731675
1674- for key in & self . props . unset_exec_env {
1675- program. env_remove ( key) ;
1676- }
1677- program. envs ( env. clone ( ) ) ;
1676+ prepare_env ( & mut program) ;
16781677
16791678 self . compose_and_run (
16801679 program,
0 commit comments