@@ -244,10 +244,12 @@ mod tests {
244
244
fn eval ( ) {
245
245
drop ( env_logger:: init ( ) ) ;
246
246
247
- let ( status, out) = exec ( ReleaseChannel :: Stable ,
248
- "/usr/local/bin/evaluate.sh" ,
249
- Vec :: new ( ) ,
250
- String :: from ( r#"fn main() { println!("Hello") }"# ) ) . unwrap ( ) ;
247
+ let cache = Cache :: new ( ) ;
248
+ let input = r#"fn main() { println!("Hello") }"# ;
249
+ let ( status, out) = cache. exec ( ReleaseChannel :: Stable ,
250
+ "/usr/local/bin/evaluate.sh" ,
251
+ Vec :: new ( ) ,
252
+ input. to_string ( ) ) . unwrap ( ) ;
251
253
assert ! ( status. success( ) ) ;
252
254
assert_eq ! ( out, & [ 0xff , b'H' , b'e' , b'l' , b'l' , b'o' , b'\n' ] ) ;
253
255
}
@@ -256,12 +258,16 @@ mod tests {
256
258
fn timeout ( ) {
257
259
drop ( env_logger:: init ( ) ) ;
258
260
259
- let ( status, out) = exec ( ReleaseChannel :: Stable ,
260
- "/usr/local/bin/evaluate.sh" ,
261
- Vec :: new ( ) ,
262
- String :: from ( r#"fn main() {
263
- std::thread::sleep_ms(10_000);
264
- }"# ) ) . unwrap ( ) ;
261
+ let cache = Cache :: new ( ) ;
262
+ let input = r#"
263
+ fn main() {
264
+ std::thread::sleep_ms(10_000);
265
+ }
266
+ "# ;
267
+ let ( status, out) = cache. exec ( ReleaseChannel :: Stable ,
268
+ "/usr/local/bin/evaluate.sh" ,
269
+ Vec :: new ( ) ,
270
+ input. to_string ( ) ) . unwrap ( ) ;
265
271
assert ! ( !status. success( ) ) ;
266
272
assert ! ( String :: from_utf8_lossy( & out) . contains( "timeout triggered" ) ) ;
267
273
}
@@ -270,10 +276,13 @@ mod tests {
270
276
fn compile ( ) {
271
277
drop ( env_logger:: init ( ) ) ;
272
278
273
- let ( status, out) = exec ( ReleaseChannel :: Stable ,
274
- "/usr/local/bin/compile.sh" ,
275
- vec ! [ String :: from( "--emit=llvm-ir" ) ] ,
276
- String :: from ( r#"fn main() { println!("Hello") }"# ) ) . unwrap ( ) ;
279
+ let cache = Cache :: new ( ) ;
280
+ let input = r#"fn main() { println!("Hello") }"# ;
281
+ let ( status, out) = cache. exec ( ReleaseChannel :: Stable ,
282
+ "/usr/local/bin/compile.sh" ,
283
+ vec ! [ String :: from( "--emit=llvm-ir" ) ] ,
284
+ input. to_string ( ) ) . unwrap ( ) ;
285
+
277
286
assert ! ( status. success( ) ) ;
278
287
let mut split = out. splitn ( 2 , |b| * b == b'\xff' ) ;
279
288
let empty: & [ u8 ] = & [ ] ;
@@ -286,10 +295,12 @@ mod tests {
286
295
fn fmt ( ) {
287
296
drop ( env_logger:: init ( ) ) ;
288
297
289
- let ( status, out) = exec ( ReleaseChannel :: Stable ,
290
- "rustfmt" ,
291
- Vec :: new ( ) ,
292
- String :: from ( r#"fn main() { println!("Hello") }"# ) ) . unwrap ( ) ;
298
+ let cache = Cache :: new ( ) ;
299
+ let input = r#"fn main() { println!("Hello") }"# ;
300
+ let ( status, out) = cache. exec ( ReleaseChannel :: Stable ,
301
+ "rustfmt" ,
302
+ Vec :: new ( ) ,
303
+ input. to_string ( ) ) . unwrap ( ) ;
293
304
assert ! ( status. success( ) ) ;
294
305
assert ! ( String :: from_utf8( out) . unwrap( ) . contains( r#""Hello""# ) )
295
306
}
0 commit comments