File tree 1 file changed +28
-0
lines changed
src/tools/compiletest/src
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,8 @@ pub fn matches_os(triple: &str, name: &str) -> bool {
86
86
}
87
87
panic ! ( "Cannot determine OS from triple" ) ;
88
88
}
89
+
90
+ /// Determine the architecture from `triple`
89
91
pub fn get_arch ( triple : & str ) -> & ' static str {
90
92
let triple: Vec < _ > = triple. split ( '-' ) . collect ( ) ;
91
93
for & ( triple_arch, arch) in ARCH_TABLE {
@@ -151,3 +153,29 @@ impl PathBufExt for PathBuf {
151
153
}
152
154
}
153
155
}
156
+
157
+ #[ test]
158
+ #[ should_panic( expected = "Cannot determine Architecture from triple" ) ]
159
+ fn test_get_arch_failure ( ) {
160
+ get_arch ( "abc" ) ;
161
+ }
162
+
163
+ #[ test]
164
+ fn test_get_arch ( ) {
165
+ assert_eq ! ( "x86_64" , get_arch( "x86_64-unknown-linux-gnu" ) ) ;
166
+ assert_eq ! ( "x86_64" , get_arch( "amd64" ) ) ;
167
+ }
168
+
169
+ #[ test]
170
+ #[ should_panic( expected = "Cannot determine OS from triple" ) ]
171
+ fn test_matches_os_failure ( ) {
172
+ matches_os ( "abc" , "abc" ) ;
173
+ }
174
+
175
+ #[ test]
176
+ fn test_matches_os ( ) {
177
+ assert ! ( matches_os( "x86_64-unknown-linux-gnu" , "linux" ) ) ;
178
+ assert ! ( matches_os( "wasm32-unknown-unknown" , "emscripten" ) ) ;
179
+ assert ! ( matches_os( "wasm32-unknown-unknown" , "wasm32-bare" ) ) ;
180
+ assert ! ( !matches_os( "wasm32-unknown-unknown" , "windows" ) ) ;
181
+ }
You can’t perform that action at this time.
0 commit comments