Improve output a bit in case of error
This commit is contained in:
parent
9ee69818f7
commit
63ee1cd846
|
@ -330,11 +330,13 @@ pub fn main_args(args: &[String]) -> isize {
|
|||
println!("rustdoc: [theme-checker] Starting tests!");
|
||||
for theme_file in to_check.iter() {
|
||||
print!(" - Checking \"{}\"...", theme_file);
|
||||
let differences = theme::test_theme_against(theme_file, &pathes);
|
||||
if !differences.is_empty() {
|
||||
let (success, differences) = theme::test_theme_against(theme_file, &pathes);
|
||||
if !differences.is_empty() || !success {
|
||||
eprintln!(" FAILED");
|
||||
errors += 1;
|
||||
eprintln!("{}", differences.join("\n"));
|
||||
if !differences.is_empty() {
|
||||
eprintln!("{}", differences.join("\n"));
|
||||
}
|
||||
} else {
|
||||
println!(" OK");
|
||||
}
|
||||
|
@ -408,7 +410,8 @@ pub fn main_args(args: &[String]) -> isize {
|
|||
eprintln!("rustdoc: option --themes arguments must all be files");
|
||||
return 1;
|
||||
}
|
||||
if !theme::test_theme_against(&theme_file, &pathes).is_empty() {
|
||||
let (success, ret) = theme::test_theme_against(&theme_file, &pathes);
|
||||
if !success || !ret.is_empty() {
|
||||
eprintln!("rustdoc: invalid theme: \"{}\"", theme_s);
|
||||
eprintln!(" Check what's wrong with the \"theme-checker\" option");
|
||||
return 1;
|
||||
|
|
|
@ -259,15 +259,15 @@ pub fn get_differences(against: &CssPath, other: &CssPath, v: &mut Vec<String>)
|
|||
}
|
||||
}
|
||||
|
||||
pub fn test_theme_against<P: AsRef<Path>>(f: &P, against: &CssPath) -> Vec<String> {
|
||||
let mut file = try_something!(File::open(f), Vec::new());
|
||||
pub fn test_theme_against<P: AsRef<Path>>(f: &P, against: &CssPath) -> (bool, Vec<String>) {
|
||||
let mut file = try_something!(File::open(f), (false, Vec::new()));
|
||||
let mut data = Vec::with_capacity(1000);
|
||||
|
||||
try_something!(file.read_to_end(&mut data), Vec::new());
|
||||
try_something!(file.read_to_end(&mut data), (false, Vec::new()));
|
||||
let pathes = load_css_pathes(&data);
|
||||
let mut ret = Vec::new();
|
||||
get_differences(against, &pathes, &mut ret);
|
||||
ret
|
||||
(true, ret)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -321,6 +321,19 @@ rule j end {}
|
|||
&load_css_pathes(text.as_bytes())).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_text() {
|
||||
let text = r#"
|
||||
a
|
||||
/* sdfs
|
||||
*/ b
|
||||
c // sdf
|
||||
d {}
|
||||
"#;
|
||||
let pathes = load_css_pathes(text.as_bytes());
|
||||
assert!(pathes.children.get("a b c d").is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_comparison() {
|
||||
let x = r#"
|
||||
|
|
Loading…
Reference in New Issue