@@ -14,13 +14,13 @@ use std::hash::{Hash, Hasher};
14
14
use std:: io:: Read ;
15
15
use std:: path:: Path ;
16
16
17
- macro_rules! try_false {
18
- ( $e: expr) => ( {
17
+ macro_rules! try_something {
18
+ ( $e: expr, $out : expr ) => ( {
19
19
match $e {
20
20
Ok ( c) => c,
21
21
Err ( e) => {
22
22
eprintln!( "rustdoc: got an error: {}" , e) ;
23
- return false ;
23
+ return $out ;
24
24
}
25
25
}
26
26
} )
@@ -215,18 +215,49 @@ pub fn load_css_pathes(v: &[u8]) -> CssPath {
215
215
parent
216
216
}
217
217
218
- pub fn test_theme_against < P : AsRef < Path > > ( f : & P , against : & CssPath ) -> bool {
219
- let mut file = try_false ! ( File :: open( f) ) ;
218
+ fn get_differences ( against : & CssPath , other : & CssPath , v : & mut Vec < String > ) {
219
+ if against. name != other. name {
220
+ return
221
+ } else {
222
+ for child in & against. children {
223
+ let mut found = false ;
224
+ let mut found_working = false ;
225
+ let mut tmp = Vec :: new ( ) ;
226
+
227
+ for other_child in & other. children {
228
+ if child. name == other_child. name {
229
+ if child != other_child {
230
+ get_differences ( child, other_child, & mut tmp) ;
231
+ } else {
232
+ found_working = true ;
233
+ }
234
+ found = true ;
235
+ break
236
+ }
237
+ }
238
+ if found == false {
239
+ v. push ( format ! ( " Missing \" {}\" rule" , child. name) ) ;
240
+ } else if found_working == false {
241
+ v. extend ( tmp. iter ( ) . cloned ( ) ) ;
242
+ }
243
+ }
244
+ }
245
+ }
246
+
247
+ pub fn test_theme_against < P : AsRef < Path > > ( f : & P , against : & CssPath ) -> Vec < String > {
248
+ let mut file = try_something ! ( File :: open( f) , Vec :: new( ) ) ;
220
249
let mut data = Vec :: with_capacity ( 1000 ) ;
221
250
222
- try_false ! ( file. read_to_end( & mut data) ) ;
251
+ try_something ! ( file. read_to_end( & mut data) , Vec :: new ( ) ) ;
223
252
let pathes = load_css_pathes ( & data) ;
224
253
println ! ( "========= {:?}" , pathes) ;
225
254
println ! ( "========= {:?}" , against) ;
226
- pathes == * against
255
+ let mut ret = Vec :: new ( ) ;
256
+ get_differences ( against, & pathes, & mut ret) ;
257
+ ret
227
258
}
228
259
229
- #[ test]
260
+ /* #[test]
230
261
fn test_comments_in_rules() {
231
262
let text = r#"
232
263
rule a {}
@@ -255,4 +286,4 @@ you like things like "{}" in there? :)
255
286
*/
256
287
end {}
257
288
"#;
258
- }
289
+ }*/
0 commit comments