@@ -273,6 +273,41 @@ mod tests {
273
273
274
274
use super :: * ;
275
275
276
+ /// Validate the version and return out with the first line (version) removed
277
+ fn validate_and_remove_version < ' a > ( out : & ' a [ u8 ] , expected : Option < & str > ) -> & ' a [ u8 ] {
278
+ let mut split = out. splitn ( 2 , |& b| b == b'\n' ) ;
279
+ let version = split. next ( ) . unwrap ( ) ;
280
+ let out = split. next ( ) . unwrap ( ) ;
281
+
282
+ assert ! ( version. starts_with( b"rustc " ) ) ;
283
+
284
+ if let Some ( expectation) = expected {
285
+ assert ! ( String :: from_utf8_lossy( version) . contains( expectation) ) ;
286
+ }
287
+
288
+ out
289
+ }
290
+
291
+ #[ test]
292
+ fn versions ( ) {
293
+ fn check ( chan : ReleaseChannel , expectation : Option < & str > ) {
294
+ let cache = Cache :: new ( ) ;
295
+ let input = r#"fn main() {}"# ;
296
+
297
+ let ( status, out) = cache. exec ( chan, "/usr/local/bin/evaluate.sh" ,
298
+ vec ! [ ] , vec ! [ ] , input. into ( ) ) . unwrap ( ) ;
299
+
300
+ assert ! ( status. success( ) ) ;
301
+ validate_and_remove_version ( & out. as_ref ( ) , expectation) ;
302
+ }
303
+
304
+ drop ( env_logger:: init ( ) ) ;
305
+
306
+ check ( ReleaseChannel :: Stable , None ) ;
307
+ check ( ReleaseChannel :: Beta , Some ( "-beta" ) ) ;
308
+ check ( ReleaseChannel :: Nightly , Some ( "-nightly" ) ) ;
309
+ }
310
+
276
311
#[ test]
277
312
fn eval ( ) {
278
313
drop ( env_logger:: init ( ) ) ;
@@ -285,6 +320,7 @@ mod tests {
285
320
Vec :: new ( ) ,
286
321
input. to_string ( ) ) . unwrap ( ) ;
287
322
assert ! ( status. success( ) ) ;
323
+ let out = validate_and_remove_version ( & out. as_ref ( ) , None ) ;
288
324
assert_eq ! ( out, & [ 0xff , b'H' , b'e' , b'l' , b'l' , b'o' , b'\n' ] ) ;
289
325
}
290
326
@@ -320,6 +356,7 @@ mod tests {
320
356
input. to_string ( ) ) . unwrap ( ) ;
321
357
322
358
assert ! ( status. success( ) ) ;
359
+ let out = validate_and_remove_version ( & out, None ) ;
323
360
let mut split = out. splitn ( 2 , |b| * b == b'\xff' ) ;
324
361
let empty: & [ u8 ] = & [ ] ;
325
362
assert_eq ! ( split. next( ) . unwrap( ) , empty) ;
0 commit comments