about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustdoc/lib.rs11
-rw-r--r--src/librustdoc/theme.rs21
2 files changed, 24 insertions, 8 deletions
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 1bdcebcee98..c08cff98892 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -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;
diff --git a/src/librustdoc/theme.rs b/src/librustdoc/theme.rs
index b64d61184e0..fe753878041 100644
--- a/src/librustdoc/theme.rs
+++ b/src/librustdoc/theme.rs
@@ -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)]
@@ -322,6 +322,19 @@ rule j end {}
     }
 
     #[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#"
 a {