2
2
3
3
use bstr:: ByteSlice ;
4
4
use spanned:: Spanned ;
5
- use std:: process :: { Command , Output } ;
5
+ use std:: { path :: Path , process :: Output } ;
6
6
7
7
use crate :: {
8
8
build_manager:: BuildManager , display, per_test_config:: TestConfig ,
9
- status_emitter:: RevisionStyle , Error , Errored , TestOk , TestRun ,
9
+ status_emitter:: RevisionStyle , CommandBuilder , Error , Errored , TestOk , TestRun ,
10
10
} ;
11
11
12
12
use super :: Flag ;
@@ -35,7 +35,7 @@ impl Flag for Run {
35
35
let mut cmd = config. build_command ( build_manager) ?;
36
36
let exit_code = self . exit_code ;
37
37
let revision = config. extension ( "run" ) ;
38
- let config = TestConfig {
38
+ let mut config = TestConfig {
39
39
config : config. config . clone ( ) ,
40
40
comments : config. comments . clone ( ) ,
41
41
aux_dir : config. aux_dir . clone ( ) ,
@@ -57,18 +57,25 @@ impl Flag for Run {
57
57
let file = files. next ( ) . unwrap ( ) ;
58
58
assert_eq ! ( files. next( ) , None ) ;
59
59
let file = std:: str:: from_utf8 ( file) . unwrap ( ) ;
60
- let exe_file = config. config . out_dir . join ( file) ;
61
- let mut exe = Command :: new ( & exe_file) ;
60
+ let mut envs = std:: mem:: take ( & mut config. config . program . envs ) ;
61
+ config. config . program = CommandBuilder :: cmd ( config. config . out_dir . join ( file) ) ;
62
+ envs. extend ( config. envs ( ) . map ( |( k, v) | ( k. into ( ) , Some ( v. into ( ) ) ) ) ) ;
63
+ config. config . program . envs = envs;
64
+
65
+ let mut exe = config. config . program . build ( Path :: new ( "" ) ) ;
62
66
let stdin = config
63
67
. status
64
68
. path ( )
65
69
. with_extension ( format ! ( "{revision}.stdin" ) ) ;
66
70
if stdin. exists ( ) {
67
71
exe. stdin ( std:: fs:: File :: open ( stdin) . unwrap ( ) ) ;
68
72
}
69
- let output = exe
70
- . output ( )
71
- . unwrap_or_else ( |err| panic ! ( "exe file: {}: {err}" , display( & exe_file) ) ) ;
73
+ let output = exe. output ( ) . unwrap_or_else ( |err| {
74
+ panic ! (
75
+ "exe file: {}: {err}" ,
76
+ display( & config. config. program. program)
77
+ )
78
+ } ) ;
72
79
73
80
if config. aborted ( ) {
74
81
return TestRun {
0 commit comments