@@ -22,6 +22,7 @@ use util::logv;
22
22
23
23
use std:: io;
24
24
use std:: os;
25
+ use std:: str;
25
26
use std:: uint;
26
27
use std:: vec;
27
28
@@ -355,6 +356,30 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
355
356
fmt ! ( "%s:%u:" , testfile. to_str( ) , ee. line)
356
357
} ) . collect :: < ~[ ~str ] > ( ) ;
357
358
359
+ fn to_lower( s : & str ) -> ~str {
360
+ let i = s. iter( ) ;
361
+ let c : ~[ char] = i. transform( |c| {
362
+ if c. is_ascii ( ) {
363
+ c. to_ascii( ) . to_lower( ) . to_char( )
364
+ } else {
365
+ c
366
+ }
367
+ } ) . collect( ) ;
368
+ str:: from_chars( c )
369
+ }
370
+
371
+ #[ cfg( target_os = "win32" ) ]
372
+ fn prefix_matches( line : & str, prefix : & str ) -> bool {
373
+ to_lower( line) . starts_with( to_lower( prefix) )
374
+ }
375
+
376
+ #[ cfg( target_os = "linux" ) ]
377
+ #[ cfg( target_os = "macos" ) ]
378
+ #[ cfg( target_os = "freebsd" ) ]
379
+ fn prefix_matches( line : & str, prefix : & str ) -> bool {
380
+ line. starts_with( prefix )
381
+ }
382
+
358
383
// Scan and extract our error/warning messages,
359
384
// which look like:
360
385
// filename:line1:col1: line2:col2: *error:* msg
@@ -367,7 +392,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
367
392
if !found_flags[ i] {
368
393
debug ! ( "prefix=%s ee.kind=%s ee.msg=%s line=%s" ,
369
394
prefixes[ i] , ee. kind, ee. msg, line) ;
370
- if ( line . starts_with ( prefixes[ i] ) &&
395
+ if ( prefix_matches ( line , prefixes[ i] ) &&
371
396
line. contains( ee. kind) &&
372
397
line. contains( ee. msg) ) {
373
398
found_flags[ i] = true ;
0 commit comments