5
5
6
6
// FIXME(Oneirical): check if works without ignore-windows
7
7
8
- use run_make_support:: { invalid_utf8_contains, invalid_utf8_not_contains, is_darwin, rustc} ;
8
+ use run_make_support:: bstr:: ByteSlice ;
9
+ use run_make_support:: { bstr, fs_wrapper, is_darwin, rustc} ;
9
10
10
11
fn main ( ) {
11
12
let mut out_simple = rustc ( ) ;
@@ -34,8 +35,8 @@ fn main() {
34
35
. input ( "auxiliary/lib.rs" ) ;
35
36
36
37
out_simple. run ( ) ;
37
- invalid_utf8_contains ( "liblib.rmeta" , "/the/aux/lib.rs" ) ;
38
- invalid_utf8_not_contains ( "liblib.rmeta" , "auxiliary" ) ;
38
+ rmeta_contains ( "/the/aux/lib.rs" ) ;
39
+ rmeta_not_contains ( "auxiliary" ) ;
39
40
40
41
out_object. arg ( "-Zremap-path-scope=object" ) ;
41
42
out_macro. arg ( "-Zremap-path-scope=macro" ) ;
@@ -47,12 +48,42 @@ fn main() {
47
48
}
48
49
49
50
out_object. run ( ) ;
50
- invalid_utf8_contains ( "liblib.rmeta" , "/the/aux/lib.rs" ) ;
51
- invalid_utf8_not_contains ( "liblib.rmeta" , "auxiliary" ) ;
51
+ rmeta_contains ( "/the/aux/lib.rs" ) ;
52
+ rmeta_not_contains ( "auxiliary" ) ;
52
53
out_macro. run ( ) ;
53
- invalid_utf8_contains ( "liblib.rmeta" , "/the/aux/lib.rs" ) ;
54
- invalid_utf8_not_contains ( "liblib.rmeta" , "auxiliary" ) ;
54
+ rmeta_contains ( "/the/aux/lib.rs" ) ;
55
+ rmeta_not_contains ( "auxiliary" ) ;
55
56
out_diagobj. run ( ) ;
56
- invalid_utf8_contains ( "liblib.rmeta" , "/the/aux/lib.rs" ) ;
57
- invalid_utf8_not_contains ( "liblib.rmeta" , "auxiliary" ) ;
57
+ rmeta_contains ( "/the/aux/lib.rs" ) ;
58
+ rmeta_not_contains ( "auxiliary" ) ;
59
+ }
60
+
61
+ //FIXME(Oneirical): These could be generalized into run_make_support
62
+ // helper functions.
63
+ fn rmeta_contains ( expected : & str ) {
64
+ // Normalize to account for path differences in Windows.
65
+ if !bstr:: BString :: from ( fs_wrapper:: read ( "liblib.rmeta" ) )
66
+ . replace ( b"\\ " , b"/" )
67
+ . contains_str ( expected)
68
+ {
69
+ eprintln ! ( "=== FILE CONTENTS (LOSSY) ===" ) ;
70
+ eprintln ! ( "{}" , String :: from_utf8_lossy( & fs_wrapper:: read( "liblib.rmeta" ) ) ) ;
71
+ eprintln ! ( "=== SPECIFIED TEXT ===" ) ;
72
+ eprintln ! ( "{}" , expected) ;
73
+ panic ! ( "specified text was not found in file" ) ;
74
+ }
75
+ }
76
+
77
+ fn rmeta_not_contains ( expected : & str ) {
78
+ // Normalize to account for path differences in Windows.
79
+ if bstr:: BString :: from ( fs_wrapper:: read ( "liblib.rmeta" ) )
80
+ . replace ( b"\\ " , b"/" )
81
+ . contains_str ( expected)
82
+ {
83
+ eprintln ! ( "=== FILE CONTENTS (LOSSY) ===" ) ;
84
+ eprintln ! ( "{}" , String :: from_utf8_lossy( & fs_wrapper:: read( "liblib.rmeta" ) ) ) ;
85
+ eprintln ! ( "=== SPECIFIED TEXT ===" ) ;
86
+ eprintln ! ( "{}" , expected) ;
87
+ panic ! ( "specified text was not found in file" ) ;
88
+ }
58
89
}
0 commit comments