File tree 3 files changed +34
-9
lines changed
3 files changed +34
-9
lines changed Original file line number Diff line number Diff line change @@ -52,5 +52,5 @@ pub fn run(ws: &Workspace,
52
52
process. args ( args) . cwd ( config. cwd ( ) ) ;
53
53
54
54
try!( config. shell ( ) . status ( "Running" , process. to_string ( ) ) ) ;
55
- Ok ( process. exec ( ) . err ( ) )
55
+ Ok ( process. exec_replace ( ) . err ( ) )
56
56
}
Original file line number Diff line number Diff line change @@ -89,6 +89,22 @@ impl ProcessBuilder {
89
89
}
90
90
}
91
91
92
+ #[ cfg( unix) ]
93
+ pub fn exec_replace ( & self ) -> Result < ( ) , ProcessError > {
94
+ use std:: os:: unix:: process:: CommandExt ;
95
+
96
+ let mut command = self . build_command ( ) ;
97
+ let error = command. exec ( ) ;
98
+ Err ( process_error ( & format ! ( "could not execute process `{}`" ,
99
+ self . debug_string( ) ) ,
100
+ Some ( Box :: new ( error) ) , None , None ) )
101
+ }
102
+
103
+ #[ cfg( windows) ]
104
+ pub fn exec_replace ( & self ) -> Result < ( ) , ProcessError > {
105
+ self . exec ( )
106
+ }
107
+
92
108
pub fn exec_with_output ( & self ) -> Result < Output , ProcessError > {
93
109
let mut command = self . build_command ( ) ;
94
110
Original file line number Diff line number Diff line change @@ -126,14 +126,18 @@ fn exit_code() {
126
126
fn main() { std::process::exit(2); }
127
127
"# ) ;
128
128
129
- assert_that ( p. cargo_process ( "run" ) ,
130
- execs ( ) . with_status ( 2 )
131
- . with_stderr ( "\
129
+ let mut output = String :: from ( "\
132
130
[COMPILING] foo v0.0.1 (file[..])
133
131
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
134
132
[RUNNING] `target[..]`
133
+ " ) ;
134
+ if !cfg ! ( unix) {
135
+ output. push_str ( "\
135
136
[ERROR] process didn't exit successfully: `target[..]foo[..]` (exit code: 2)
136
- " ) ) ;
137
+ " ) ;
138
+ }
139
+ assert_that ( p. cargo_process ( "run" ) ,
140
+ execs ( ) . with_status ( 2 ) . with_stderr ( output) ) ;
137
141
}
138
142
139
143
#[ test]
@@ -149,15 +153,20 @@ fn exit_code_verbose() {
149
153
fn main() { std::process::exit(2); }
150
154
"# ) ;
151
155
152
- assert_that ( p. cargo_process ( "run" ) . arg ( "-v" ) ,
153
- execs ( ) . with_status ( 2 )
154
- . with_stderr ( "\
156
+ let mut output = String :: from ( "\
155
157
[COMPILING] foo v0.0.1 (file[..])
156
158
[RUNNING] `rustc [..]`
157
159
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
158
160
[RUNNING] `target[..]`
161
+ " ) ;
162
+ if !cfg ! ( unix) {
163
+ output. push_str ( "\
159
164
[ERROR] process didn't exit successfully: `target[..]foo[..]` (exit code: 2)
160
- " ) ) ;
165
+ " ) ;
166
+ }
167
+
168
+ assert_that ( p. cargo_process ( "run" ) . arg ( "-v" ) ,
169
+ execs ( ) . with_status ( 2 ) . with_stderr ( output) ) ;
161
170
}
162
171
163
172
#[ test]
You can’t perform that action at this time.
0 commit comments