]> git.lizzy.rs Git - rust.git/commitdiff
Rename rustdoc js test suites
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 23 Feb 2019 23:08:43 +0000 (00:08 +0100)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Mon, 25 Feb 2019 16:46:06 +0000 (17:46 +0100)
48 files changed:
src/bootstrap/builder.rs
src/bootstrap/test.rs
src/test/rustdoc-js-not-std/basic.js [deleted file]
src/test/rustdoc-js-not-std/basic.rs [deleted file]
src/test/rustdoc-js-std/alias-1.js [new file with mode: 0644]
src/test/rustdoc-js-std/alias-2.js [new file with mode: 0644]
src/test/rustdoc-js-std/alias-3.js [new file with mode: 0644]
src/test/rustdoc-js-std/alias.js [new file with mode: 0644]
src/test/rustdoc-js-std/basic.js [new file with mode: 0644]
src/test/rustdoc-js-std/deduplication.js [new file with mode: 0644]
src/test/rustdoc-js-std/enum-option.js [new file with mode: 0644]
src/test/rustdoc-js-std/filter-crate.js [new file with mode: 0644]
src/test/rustdoc-js-std/fn-forget.js [new file with mode: 0644]
src/test/rustdoc-js-std/from_u.js [new file with mode: 0644]
src/test/rustdoc-js-std/keyword.js [new file with mode: 0644]
src/test/rustdoc-js-std/macro-check.js [new file with mode: 0644]
src/test/rustdoc-js-std/macro-print.js [new file with mode: 0644]
src/test/rustdoc-js-std/multi-query.js [new file with mode: 0644]
src/test/rustdoc-js-std/never.js [new file with mode: 0644]
src/test/rustdoc-js-std/quoted.js [new file with mode: 0644]
src/test/rustdoc-js-std/should-fail.js [new file with mode: 0644]
src/test/rustdoc-js-std/string-from_ut.js [new file with mode: 0644]
src/test/rustdoc-js-std/struct-vec.js [new file with mode: 0644]
src/test/rustdoc-js-std/vec-new.js [new file with mode: 0644]
src/test/rustdoc-js/alias-1.js [deleted file]
src/test/rustdoc-js/alias-2.js [deleted file]
src/test/rustdoc-js/alias-3.js [deleted file]
src/test/rustdoc-js/alias.js [deleted file]
src/test/rustdoc-js/basic.js
src/test/rustdoc-js/basic.rs [new file with mode: 0644]
src/test/rustdoc-js/deduplication.js [deleted file]
src/test/rustdoc-js/enum-option.js [deleted file]
src/test/rustdoc-js/filter-crate.js [deleted file]
src/test/rustdoc-js/fn-forget.js [deleted file]
src/test/rustdoc-js/from_u.js [deleted file]
src/test/rustdoc-js/keyword.js [deleted file]
src/test/rustdoc-js/macro-check.js [deleted file]
src/test/rustdoc-js/macro-print.js [deleted file]
src/test/rustdoc-js/multi-query.js [deleted file]
src/test/rustdoc-js/never.js [deleted file]
src/test/rustdoc-js/quoted.js [deleted file]
src/test/rustdoc-js/should-fail.js [deleted file]
src/test/rustdoc-js/string-from_ut.js [deleted file]
src/test/rustdoc-js/struct-vec.js [deleted file]
src/test/rustdoc-js/vec-new.js [deleted file]
src/tools/rustdoc-js-not-std/tester.js [deleted file]
src/tools/rustdoc-js-std/tester.js [new file with mode: 0644]
src/tools/rustdoc-js/tester.js

index 71b9cd6f9fba4df7cb540c36160d538089a8e682..a471af257665f099b263e68365b7e300de578268 100644 (file)
@@ -405,7 +405,7 @@ macro_rules! describe {
                 test::Miri,
                 test::Clippy,
                 test::CompiletestTest,
-                test::RustdocJS,
+                test::RustdocJSStd,
                 test::RustdocJSNotStd,
                 test::RustdocTheme,
                 // Run bootstrap close to the end as it's unlikely to fail
index 7dcc10e8a091887b4a735817a78a50048e45c82c..c724d75c2dc0651b114c0b4fd1f941fb2f78f6a4 100644 (file)
@@ -574,22 +574,22 @@ fn run(self, builder: &Builder<'_>) {
 }
 
 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
-pub struct RustdocJS {
+pub struct RustdocJSStd {
     pub host: Interned<String>,
     pub target: Interned<String>,
 }
 
-impl Step for RustdocJS {
+impl Step for RustdocJSStd {
     type Output = ();
     const DEFAULT: bool = true;
     const ONLY_HOSTS: bool = true;
 
     fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
-        run.path("src/test/rustdoc-js")
+        run.path("src/test/rustdoc-js-std")
     }
 
     fn make_run(run: RunConfig<'_>) {
-        run.builder.ensure(RustdocJS {
+        run.builder.ensure(RustdocJSStd {
             host: run.host,
             target: run.target,
         });
@@ -598,7 +598,7 @@ fn make_run(run: RunConfig<'_>) {
     fn run(self, builder: &Builder<'_>) {
         if let Some(ref nodejs) = builder.config.nodejs {
             let mut command = Command::new(nodejs);
-            command.args(&["src/tools/rustdoc-js/tester.js", &*self.host]);
+            command.args(&["src/tools/rustdoc-js-std/tester.js", &*self.host]);
             builder.ensure(crate::doc::Std {
                 target: self.target,
                 stage: builder.top_stage,
@@ -606,7 +606,7 @@ fn run(self, builder: &Builder<'_>) {
             builder.run(&mut command);
         } else {
             builder.info(
-                "No nodejs found, skipping \"src/test/rustdoc-js\" tests"
+                "No nodejs found, skipping \"src/test/rustdoc-js-std\" tests"
             );
         }
     }
@@ -625,7 +625,7 @@ impl Step for RustdocJSNotStd {
     const ONLY_HOSTS: bool = true;
 
     fn should_run(run: ShouldRun) -> ShouldRun {
-        run.path("src/test/rustdoc-js-not-std")
+        run.path("src/test/rustdoc-js")
     }
 
     fn make_run(run: RunConfig) {
@@ -640,7 +640,7 @@ fn make_run(run: RunConfig) {
     fn run(self, builder: &Builder) {
         if let Some(ref nodejs) = builder.config.nodejs {
             let mut command = Command::new(nodejs);
-            command.args(&["src/tools/rustdoc-js-not-std/tester.js",
+            command.args(&["src/tools/rustdoc-js/tester.js",
                            &*self.host,
                            builder.top_stage.to_string().as_str()]);
             builder.ensure(crate::doc::Std {
@@ -650,7 +650,7 @@ fn run(self, builder: &Builder) {
             builder.run(&mut command);
         } else {
             builder.info(
-                "No nodejs found, skipping \"src/test/rustdoc-js-not-std\" tests"
+                "No nodejs found, skipping \"src/test/rustdoc-js\" tests"
             );
         }
     }
diff --git a/src/test/rustdoc-js-not-std/basic.js b/src/test/rustdoc-js-not-std/basic.js
deleted file mode 100644 (file)
index d99b234..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-const QUERY = 'Fo';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'basic', 'name': 'Foo' },
-    ],
-};
diff --git a/src/test/rustdoc-js-not-std/basic.rs b/src/test/rustdoc-js-not-std/basic.rs
deleted file mode 100644 (file)
index 4a83567..0000000
+++ /dev/null
@@ -1 +0,0 @@
-pub struct Foo;
diff --git a/src/test/rustdoc-js-std/alias-1.js b/src/test/rustdoc-js-std/alias-1.js
new file mode 100644 (file)
index 0000000..7c6327f
--- /dev/null
@@ -0,0 +1,7 @@
+const QUERY = '&';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std', 'name': 'reference' },
+    ],
+};
diff --git a/src/test/rustdoc-js-std/alias-2.js b/src/test/rustdoc-js-std/alias-2.js
new file mode 100644 (file)
index 0000000..f3c6713
--- /dev/null
@@ -0,0 +1,10 @@
+// ignore-order
+
+const QUERY = '+';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std::ops', 'name': 'AddAssign' },
+        { 'path': 'std::ops', 'name': 'Add' },
+    ],
+};
diff --git a/src/test/rustdoc-js-std/alias-3.js b/src/test/rustdoc-js-std/alias-3.js
new file mode 100644 (file)
index 0000000..392b1e8
--- /dev/null
@@ -0,0 +1,7 @@
+const QUERY = '!';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std', 'name': 'never' },
+    ],
+};
diff --git a/src/test/rustdoc-js-std/alias.js b/src/test/rustdoc-js-std/alias.js
new file mode 100644 (file)
index 0000000..2b709c9
--- /dev/null
@@ -0,0 +1,11 @@
+// ignore-order
+
+const QUERY = '[';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std', 'name': 'slice' },
+        { 'path': 'std::ops', 'name': 'IndexMut' },
+        { 'path': 'std::ops', 'name': 'Index' },
+    ],
+};
diff --git a/src/test/rustdoc-js-std/basic.js b/src/test/rustdoc-js-std/basic.js
new file mode 100644 (file)
index 0000000..824cac7
--- /dev/null
@@ -0,0 +1,15 @@
+const QUERY = 'String';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std::string', 'name': 'String' },
+        { 'path': 'std::ffi', 'name': 'CString' },
+        { 'path': 'std::ffi', 'name': 'OsString' },
+    ],
+    'in_args': [
+        { 'path': 'std::str', 'name': 'eq' },
+    ],
+    'returned': [
+        { 'path': 'std::string::String', 'name': 'add' },
+    ],
+};
diff --git a/src/test/rustdoc-js-std/deduplication.js b/src/test/rustdoc-js-std/deduplication.js
new file mode 100644 (file)
index 0000000..f02f6cf
--- /dev/null
@@ -0,0 +1,11 @@
+// ignore-order
+
+const QUERY = 'is_nan';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std::f32', 'name': 'is_nan' },
+        { 'path': 'std::f64', 'name': 'is_nan' },
+        { 'path': 'std::option::Option', 'name': 'is_none' },
+    ],
+};
diff --git a/src/test/rustdoc-js-std/enum-option.js b/src/test/rustdoc-js-std/enum-option.js
new file mode 100644 (file)
index 0000000..902e090
--- /dev/null
@@ -0,0 +1,7 @@
+const QUERY = 'enum:Option';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std::option', 'name': 'Option' },
+    ],
+};
diff --git a/src/test/rustdoc-js-std/filter-crate.js b/src/test/rustdoc-js-std/filter-crate.js
new file mode 100644 (file)
index 0000000..2e0330c
--- /dev/null
@@ -0,0 +1,9 @@
+// exact-check
+
+const QUERY = 'hashmap';
+const FILTER_CRATE = 'core';
+
+const EXPECTED = {
+    'others': [
+    ],
+};
diff --git a/src/test/rustdoc-js-std/fn-forget.js b/src/test/rustdoc-js-std/fn-forget.js
new file mode 100644 (file)
index 0000000..66a5fca
--- /dev/null
@@ -0,0 +1,8 @@
+const QUERY = 'fn:forget';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std::mem', 'name': 'forget' },
+        { 'path': 'std::fmt', 'name': 'format' },
+    ],
+};
diff --git a/src/test/rustdoc-js-std/from_u.js b/src/test/rustdoc-js-std/from_u.js
new file mode 100644 (file)
index 0000000..e3f3cd4
--- /dev/null
@@ -0,0 +1,9 @@
+const QUERY = 'from_u';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std::char', 'name': 'from_u32' },
+        { 'path': 'std::str', 'name': 'from_utf8' },
+        { 'path': 'std::string::String', 'name': 'from_utf8' },
+    ],
+};
diff --git a/src/test/rustdoc-js-std/keyword.js b/src/test/rustdoc-js-std/keyword.js
new file mode 100644 (file)
index 0000000..868ddd7
--- /dev/null
@@ -0,0 +1,10 @@
+// ignore-order
+
+const QUERY = 'fn';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std', 'name': 'fn', ty: 15 }, // 15 is for primitive types
+        { 'path': 'std', 'name': 'fn', ty: 21 }, // 21 is for keywords
+    ],
+};
diff --git a/src/test/rustdoc-js-std/macro-check.js b/src/test/rustdoc-js-std/macro-check.js
new file mode 100644 (file)
index 0000000..242e0cb
--- /dev/null
@@ -0,0 +1,10 @@
+// ignore-order
+
+const QUERY = 'panic';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std', 'name': 'panic', ty: 14 }, // 15 is for macros
+        { 'path': 'std', 'name': 'panic', ty: 0 }, // 0 is for modules
+    ],
+};
diff --git a/src/test/rustdoc-js-std/macro-print.js b/src/test/rustdoc-js-std/macro-print.js
new file mode 100644 (file)
index 0000000..858046e
--- /dev/null
@@ -0,0 +1,10 @@
+const QUERY = 'macro:print';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std', 'name': 'print' },
+        { 'path': 'std', 'name': 'eprint' },
+        { 'path': 'std', 'name': 'println' },
+        { 'path': 'std', 'name': 'eprintln' },
+    ],
+};
diff --git a/src/test/rustdoc-js-std/multi-query.js b/src/test/rustdoc-js-std/multi-query.js
new file mode 100644 (file)
index 0000000..01e5406
--- /dev/null
@@ -0,0 +1,9 @@
+const QUERY = 'str,u8';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std', 'name': 'str' },
+        { 'path': 'std', 'name': 'u8' },
+        { 'path': 'std::ffi', 'name': 'CStr' },
+    ],
+};
diff --git a/src/test/rustdoc-js-std/never.js b/src/test/rustdoc-js-std/never.js
new file mode 100644 (file)
index 0000000..392b1e8
--- /dev/null
@@ -0,0 +1,7 @@
+const QUERY = '!';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std', 'name': 'never' },
+    ],
+};
diff --git a/src/test/rustdoc-js-std/quoted.js b/src/test/rustdoc-js-std/quoted.js
new file mode 100644 (file)
index 0000000..924129f
--- /dev/null
@@ -0,0 +1,13 @@
+const QUERY = '"error"';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std', 'name': 'error' },
+        { 'path': 'std::fmt', 'name': 'Error' },
+        { 'path': 'std::io', 'name': 'Error' },
+    ],
+    'in_args': [],
+    'returned': [
+        { 'path': 'std::fmt::LowerExp', 'name': 'fmt' },
+    ],
+};
diff --git a/src/test/rustdoc-js-std/should-fail.js b/src/test/rustdoc-js-std/should-fail.js
new file mode 100644 (file)
index 0000000..b85a47d
--- /dev/null
@@ -0,0 +1,9 @@
+// should-fail
+
+const QUERY = 'fn';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std', 'name': 'fn', ty: 14 },
+    ],
+};
diff --git a/src/test/rustdoc-js-std/string-from_ut.js b/src/test/rustdoc-js-std/string-from_ut.js
new file mode 100644 (file)
index 0000000..f9edf44
--- /dev/null
@@ -0,0 +1,11 @@
+const QUERY = 'String::from_ut';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std::string::String', 'name': 'from_utf8' },
+        { 'path': 'std::string::String', 'name': 'from_utf8' },
+        { 'path': 'std::string::String', 'name': 'from_utf8_lossy' },
+        { 'path': 'std::string::String', 'name': 'from_utf16_lossy' },
+        { 'path': 'std::string::String', 'name': 'from_utf8_unchecked' },
+    ],
+};
diff --git a/src/test/rustdoc-js-std/struct-vec.js b/src/test/rustdoc-js-std/struct-vec.js
new file mode 100644 (file)
index 0000000..2c80814
--- /dev/null
@@ -0,0 +1,8 @@
+const QUERY = 'struct:Vec';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std::vec', 'name': 'Vec' },
+        { 'path': 'std::collections', 'name': 'VecDeque' },
+    ],
+};
diff --git a/src/test/rustdoc-js-std/vec-new.js b/src/test/rustdoc-js-std/vec-new.js
new file mode 100644 (file)
index 0000000..e4daa50
--- /dev/null
@@ -0,0 +1,8 @@
+const QUERY = 'Vec::new';
+
+const EXPECTED = {
+    'others': [
+        { 'path': 'std::vec::Vec', 'name': 'new' },
+        { 'path': 'std::vec::Vec', 'name': 'ne' },
+    ],
+};
diff --git a/src/test/rustdoc-js/alias-1.js b/src/test/rustdoc-js/alias-1.js
deleted file mode 100644 (file)
index 7c6327f..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-const QUERY = '&';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std', 'name': 'reference' },
-    ],
-};
diff --git a/src/test/rustdoc-js/alias-2.js b/src/test/rustdoc-js/alias-2.js
deleted file mode 100644 (file)
index f3c6713..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// ignore-order
-
-const QUERY = '+';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std::ops', 'name': 'AddAssign' },
-        { 'path': 'std::ops', 'name': 'Add' },
-    ],
-};
diff --git a/src/test/rustdoc-js/alias-3.js b/src/test/rustdoc-js/alias-3.js
deleted file mode 100644 (file)
index 392b1e8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-const QUERY = '!';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std', 'name': 'never' },
-    ],
-};
diff --git a/src/test/rustdoc-js/alias.js b/src/test/rustdoc-js/alias.js
deleted file mode 100644 (file)
index 2b709c9..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// ignore-order
-
-const QUERY = '[';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std', 'name': 'slice' },
-        { 'path': 'std::ops', 'name': 'IndexMut' },
-        { 'path': 'std::ops', 'name': 'Index' },
-    ],
-};
index 824cac71083328dd8e001f8a137c78d7d219db66..d99b23468b60cfa94361eac46317304aa7ae8332 100644 (file)
@@ -1,15 +1,7 @@
-const QUERY = 'String';
+const QUERY = 'Fo';
 
 const EXPECTED = {
     'others': [
-        { 'path': 'std::string', 'name': 'String' },
-        { 'path': 'std::ffi', 'name': 'CString' },
-        { 'path': 'std::ffi', 'name': 'OsString' },
-    ],
-    'in_args': [
-        { 'path': 'std::str', 'name': 'eq' },
-    ],
-    'returned': [
-        { 'path': 'std::string::String', 'name': 'add' },
+        { 'path': 'basic', 'name': 'Foo' },
     ],
 };
diff --git a/src/test/rustdoc-js/basic.rs b/src/test/rustdoc-js/basic.rs
new file mode 100644 (file)
index 0000000..4a83567
--- /dev/null
@@ -0,0 +1 @@
+pub struct Foo;
diff --git a/src/test/rustdoc-js/deduplication.js b/src/test/rustdoc-js/deduplication.js
deleted file mode 100644 (file)
index f02f6cf..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// ignore-order
-
-const QUERY = 'is_nan';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std::f32', 'name': 'is_nan' },
-        { 'path': 'std::f64', 'name': 'is_nan' },
-        { 'path': 'std::option::Option', 'name': 'is_none' },
-    ],
-};
diff --git a/src/test/rustdoc-js/enum-option.js b/src/test/rustdoc-js/enum-option.js
deleted file mode 100644 (file)
index 902e090..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-const QUERY = 'enum:Option';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std::option', 'name': 'Option' },
-    ],
-};
diff --git a/src/test/rustdoc-js/filter-crate.js b/src/test/rustdoc-js/filter-crate.js
deleted file mode 100644 (file)
index 2e0330c..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-// exact-check
-
-const QUERY = 'hashmap';
-const FILTER_CRATE = 'core';
-
-const EXPECTED = {
-    'others': [
-    ],
-};
diff --git a/src/test/rustdoc-js/fn-forget.js b/src/test/rustdoc-js/fn-forget.js
deleted file mode 100644 (file)
index 66a5fca..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-const QUERY = 'fn:forget';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std::mem', 'name': 'forget' },
-        { 'path': 'std::fmt', 'name': 'format' },
-    ],
-};
diff --git a/src/test/rustdoc-js/from_u.js b/src/test/rustdoc-js/from_u.js
deleted file mode 100644 (file)
index e3f3cd4..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-const QUERY = 'from_u';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std::char', 'name': 'from_u32' },
-        { 'path': 'std::str', 'name': 'from_utf8' },
-        { 'path': 'std::string::String', 'name': 'from_utf8' },
-    ],
-};
diff --git a/src/test/rustdoc-js/keyword.js b/src/test/rustdoc-js/keyword.js
deleted file mode 100644 (file)
index 868ddd7..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// ignore-order
-
-const QUERY = 'fn';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std', 'name': 'fn', ty: 15 }, // 15 is for primitive types
-        { 'path': 'std', 'name': 'fn', ty: 21 }, // 21 is for keywords
-    ],
-};
diff --git a/src/test/rustdoc-js/macro-check.js b/src/test/rustdoc-js/macro-check.js
deleted file mode 100644 (file)
index 242e0cb..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// ignore-order
-
-const QUERY = 'panic';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std', 'name': 'panic', ty: 14 }, // 15 is for macros
-        { 'path': 'std', 'name': 'panic', ty: 0 }, // 0 is for modules
-    ],
-};
diff --git a/src/test/rustdoc-js/macro-print.js b/src/test/rustdoc-js/macro-print.js
deleted file mode 100644 (file)
index 858046e..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-const QUERY = 'macro:print';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std', 'name': 'print' },
-        { 'path': 'std', 'name': 'eprint' },
-        { 'path': 'std', 'name': 'println' },
-        { 'path': 'std', 'name': 'eprintln' },
-    ],
-};
diff --git a/src/test/rustdoc-js/multi-query.js b/src/test/rustdoc-js/multi-query.js
deleted file mode 100644 (file)
index 01e5406..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-const QUERY = 'str,u8';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std', 'name': 'str' },
-        { 'path': 'std', 'name': 'u8' },
-        { 'path': 'std::ffi', 'name': 'CStr' },
-    ],
-};
diff --git a/src/test/rustdoc-js/never.js b/src/test/rustdoc-js/never.js
deleted file mode 100644 (file)
index 392b1e8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-const QUERY = '!';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std', 'name': 'never' },
-    ],
-};
diff --git a/src/test/rustdoc-js/quoted.js b/src/test/rustdoc-js/quoted.js
deleted file mode 100644 (file)
index 924129f..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-const QUERY = '"error"';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std', 'name': 'error' },
-        { 'path': 'std::fmt', 'name': 'Error' },
-        { 'path': 'std::io', 'name': 'Error' },
-    ],
-    'in_args': [],
-    'returned': [
-        { 'path': 'std::fmt::LowerExp', 'name': 'fmt' },
-    ],
-};
diff --git a/src/test/rustdoc-js/should-fail.js b/src/test/rustdoc-js/should-fail.js
deleted file mode 100644 (file)
index b85a47d..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-// should-fail
-
-const QUERY = 'fn';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std', 'name': 'fn', ty: 14 },
-    ],
-};
diff --git a/src/test/rustdoc-js/string-from_ut.js b/src/test/rustdoc-js/string-from_ut.js
deleted file mode 100644 (file)
index f9edf44..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-const QUERY = 'String::from_ut';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std::string::String', 'name': 'from_utf8' },
-        { 'path': 'std::string::String', 'name': 'from_utf8' },
-        { 'path': 'std::string::String', 'name': 'from_utf8_lossy' },
-        { 'path': 'std::string::String', 'name': 'from_utf16_lossy' },
-        { 'path': 'std::string::String', 'name': 'from_utf8_unchecked' },
-    ],
-};
diff --git a/src/test/rustdoc-js/struct-vec.js b/src/test/rustdoc-js/struct-vec.js
deleted file mode 100644 (file)
index 2c80814..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-const QUERY = 'struct:Vec';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std::vec', 'name': 'Vec' },
-        { 'path': 'std::collections', 'name': 'VecDeque' },
-    ],
-};
diff --git a/src/test/rustdoc-js/vec-new.js b/src/test/rustdoc-js/vec-new.js
deleted file mode 100644 (file)
index e4daa50..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-const QUERY = 'Vec::new';
-
-const EXPECTED = {
-    'others': [
-        { 'path': 'std::vec::Vec', 'name': 'new' },
-        { 'path': 'std::vec::Vec', 'name': 'ne' },
-    ],
-};
diff --git a/src/tools/rustdoc-js-not-std/tester.js b/src/tools/rustdoc-js-not-std/tester.js
deleted file mode 100644 (file)
index 61490b2..0000000
+++ /dev/null
@@ -1,365 +0,0 @@
-const fs = require('fs');
-const { spawnSync } = require('child_process');
-
-const TEST_FOLDER = 'src/test/rustdoc-js-not-std/';
-
-function getNextStep(content, pos, stop) {
-    while (pos < content.length && content[pos] !== stop &&
-           (content[pos] === ' ' || content[pos] === '\t' || content[pos] === '\n')) {
-        pos += 1;
-    }
-    if (pos >= content.length) {
-        return null;
-    }
-    if (content[pos] !== stop) {
-        return pos * -1;
-    }
-    return pos;
-}
-
-// Stupid function extractor based on indent. Doesn't support block
-// comments. If someone puts a ' or an " in a block comment this
-// will blow up. Template strings are not tested and might also be
-// broken.
-function extractFunction(content, functionName) {
-    var indent = 0;
-    var splitter = "function " + functionName + "(";
-
-    while (true) {
-        var start = content.indexOf(splitter);
-        if (start === -1) {
-            break;
-        }
-        var pos = start;
-        while (pos < content.length && content[pos] !== ')') {
-            pos += 1;
-        }
-        if (pos >= content.length) {
-            break;
-        }
-        pos = getNextStep(content, pos + 1, '{');
-        if (pos === null) {
-            break;
-        } else if (pos < 0) {
-            content = content.slice(-pos);
-            continue;
-        }
-        while (pos < content.length) {
-            // Eat single-line comments
-            if (content[pos] === '/' && pos > 0 && content[pos-1] === '/') {
-                do {
-                    pos += 1;
-                } while (pos < content.length && content[pos] !== '\n');
-
-            // Eat quoted strings
-            } else if (content[pos] === '"' || content[pos] === "'" || content[pos] === "`") {
-                var stop = content[pos];
-                var is_escaped = false;
-                do {
-                    if (content[pos] === '\\') {
-                        pos += 2;
-                    } else {
-                        pos += 1;
-                    }
-                } while (pos < content.length &&
-                         (content[pos] !== stop || content[pos - 1] === '\\'));
-
-            // Otherwise, check for indent
-            } else if (content[pos] === '{') {
-                indent += 1;
-            } else if (content[pos] === '}') {
-                indent -= 1;
-                if (indent === 0) {
-                    return content.slice(start, pos + 1);
-                }
-            }
-            pos += 1;
-        }
-        content = content.slice(start + 1);
-    }
-    return null;
-}
-
-// Stupid function extractor for array.
-function extractArrayVariable(content, arrayName) {
-    var splitter = "var " + arrayName;
-    while (true) {
-        var start = content.indexOf(splitter);
-        if (start === -1) {
-            break;
-        }
-        var pos = getNextStep(content, start, '=');
-        if (pos === null) {
-            break;
-        } else if (pos < 0) {
-            content = content.slice(-pos);
-            continue;
-        }
-        pos = getNextStep(content, pos, '[');
-        if (pos === null) {
-            break;
-        } else if (pos < 0) {
-            content = content.slice(-pos);
-            continue;
-        }
-        while (pos < content.length) {
-            if (content[pos] === '"' || content[pos] === "'") {
-                var stop = content[pos];
-                do {
-                    if (content[pos] === '\\') {
-                        pos += 2;
-                    } else {
-                        pos += 1;
-                    }
-                } while (pos < content.length &&
-                         (content[pos] !== stop || content[pos - 1] === '\\'));
-            } else if (content[pos] === ']' &&
-                       pos + 1 < content.length &&
-                       content[pos + 1] === ';') {
-                return content.slice(start, pos + 2);
-            }
-            pos += 1;
-        }
-        content = content.slice(start + 1);
-    }
-    return null;
-}
-
-// Stupid function extractor for variable.
-function extractVariable(content, varName) {
-    var splitter = "var " + varName;
-    while (true) {
-        var start = content.indexOf(splitter);
-        if (start === -1) {
-            break;
-        }
-        var pos = getNextStep(content, start, '=');
-        if (pos === null) {
-            break;
-        } else if (pos < 0) {
-            content = content.slice(-pos);
-            continue;
-        }
-        while (pos < content.length) {
-            if (content[pos] === '"' || content[pos] === "'") {
-                var stop = content[pos];
-                do {
-                    if (content[pos] === '\\') {
-                        pos += 2;
-                    } else {
-                        pos += 1;
-                    }
-                } while (pos < content.length &&
-                         (content[pos] !== stop || content[pos - 1] === '\\'));
-            } else if (content[pos] === ';') {
-                return content.slice(start, pos + 1);
-            }
-            pos += 1;
-        }
-        content = content.slice(start + 1);
-    }
-    return null;
-}
-
-function loadContent(content) {
-    var Module = module.constructor;
-    var m = new Module();
-    m._compile(content, "tmp.js");
-    m.exports.ignore_order = content.indexOf("\n// ignore-order\n") !== -1 ||
-        content.startsWith("// ignore-order\n");
-    m.exports.exact_check = content.indexOf("\n// exact-check\n") !== -1 ||
-        content.startsWith("// exact-check\n");
-    m.exports.should_fail = content.indexOf("\n// should-fail\n") !== -1 ||
-        content.startsWith("// should-fail\n");
-    return m.exports;
-}
-
-function readFile(filePath) {
-    return fs.readFileSync(filePath, 'utf8');
-}
-
-function loadThings(thingsToLoad, kindOfLoad, funcToCall, fileContent) {
-    var content = '';
-    for (var i = 0; i < thingsToLoad.length; ++i) {
-        var tmp = funcToCall(fileContent, thingsToLoad[i]);
-        if (tmp === null) {
-            console.error('unable to find ' + kindOfLoad + ' "' + thingsToLoad[i] + '"');
-            process.exit(1);
-        }
-        content += tmp;
-        content += 'exports.' + thingsToLoad[i] + ' = ' + thingsToLoad[i] + ';';
-    }
-    return content;
-}
-
-function lookForEntry(entry, data) {
-    for (var i = 0; i < data.length; ++i) {
-        var allGood = true;
-        for (var key in entry) {
-            if (!entry.hasOwnProperty(key)) {
-                continue;
-            }
-            var value = data[i][key];
-            // To make our life easier, if there is a "parent" type, we add it to the path.
-            if (key === 'path' && data[i]['parent'] !== undefined) {
-                if (value.length > 0) {
-                    value += '::' + data[i]['parent']['name'];
-                } else {
-                    value = data[i]['parent']['name'];
-                }
-            }
-            if (value !== entry[key]) {
-                allGood = false;
-                break;
-            }
-        }
-        if (allGood === true) {
-            return i;
-        }
-    }
-    return null;
-}
-
-function remove_docs(out_dir) {
-    spawnSync('rm', ['-rf', out_dir]);
-}
-
-function build_docs(out_dir, rustdoc_path, file_to_document) {
-    remove_docs(out_dir);
-    var c = spawnSync(rustdoc_path, [file_to_document, '-o', out_dir]);
-    var s = '';
-    if (c.error || c.stderr.length > 0) {
-        if (c.stderr.length > 0) {
-            s += '==> STDERR: ' + c.stderr + '\n';
-        }
-        s += '==> ERROR: ' + c.error;
-    }
-    return s;
-}
-
-function load_files(out_folder, crate) {
-    var mainJs = readFile(out_folder + "/main.js");
-    var ALIASES = readFile(out_folder + "/aliases.js");
-    var searchIndex = readFile(out_folder + "/search-index.js").split("\n");
-    if (searchIndex[searchIndex.length - 1].length === 0) {
-        searchIndex.pop();
-    }
-    searchIndex.pop();
-    searchIndex = loadContent(searchIndex.join("\n") + '\nexports.searchIndex = searchIndex;');
-    finalJS = "";
-
-    var arraysToLoad = ["itemTypes"];
-    var variablesToLoad = ["MAX_LEV_DISTANCE", "MAX_RESULTS",
-                           "GENERICS_DATA", "NAME", "INPUTS_DATA", "OUTPUT_DATA",
-                           "TY_PRIMITIVE", "TY_KEYWORD",
-                           "levenshtein_row2"];
-    // execQuery first parameter is built in getQuery (which takes in the search input).
-    // execQuery last parameter is built in buildIndex.
-    // buildIndex requires the hashmap from search-index.
-    var functionsToLoad = ["buildHrefAndPath", "pathSplitter", "levenshtein", "validateResult",
-                           "getQuery", "buildIndex", "execQuery", "execSearch"];
-
-    finalJS += 'window = { "currentCrate": "' + crate + '" };\n';
-    finalJS += 'var rootPath = "../";\n';
-    finalJS += ALIASES;
-    finalJS += loadThings(arraysToLoad, 'array', extractArrayVariable, mainJs);
-    finalJS += loadThings(variablesToLoad, 'variable', extractVariable, mainJs);
-    finalJS += loadThings(functionsToLoad, 'function', extractFunction, mainJs);
-
-    var loaded = loadContent(finalJS);
-    return [loaded, loaded.buildIndex(searchIndex.searchIndex)];
-}
-
-function main(argv) {
-    if (argv.length !== 4) {
-        console.error("USAGE: node tester.js [TOOLCHAIN] [STAGE]");
-        return 1;
-    }
-    const toolchain = argv[2];
-    const stage = argv[3];
-    const rustdoc_path = './build/' + toolchain + '/stage' + stage + '/bin/rustdoc';
-
-    var errors = 0;
-
-    fs.readdirSync(TEST_FOLDER).forEach(function(file) {
-        if (!file.endsWith('.js')) {
-            return;
-        }
-        var test_name = file.substring(0, file.length - 3);
-        process.stdout.write('Checking "' + test_name + '" ... ');
-        var rust_file = TEST_FOLDER + test_name + '.rs';
-
-        if (!fs.existsSync(rust_file)) {
-            console.error("FAILED");
-            console.error("==> Missing '" + test_name + ".rs' file...");
-            errors += 1;
-            return;
-        }
-
-        var out_folder = "build/" + toolchain + "/stage" + stage + "/tests/rustdoc-js-not-std/" +
-                         test_name;
-
-        var ret = build_docs(out_folder, rustdoc_path, rust_file);
-        if (ret.length > 0) {
-            console.error("FAILED");
-            console.error(ret);
-            errors += 1;
-            return;
-        }
-
-        var [loaded, index] = load_files(out_folder, test_name);
-        var loadedFile = loadContent(readFile(TEST_FOLDER + file) +
-                               'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;');
-        const expected = loadedFile.EXPECTED;
-        const query = loadedFile.QUERY;
-        const filter_crate = loadedFile.FILTER_CRATE;
-        const ignore_order = loadedFile.ignore_order;
-        const exact_check = loadedFile.exact_check;
-        const should_fail = loadedFile.should_fail;
-        var results = loaded.execSearch(loaded.getQuery(query), index);
-        var error_text = [];
-        for (var key in expected) {
-            if (!expected.hasOwnProperty(key)) {
-                continue;
-            }
-            if (!results.hasOwnProperty(key)) {
-                error_text.push('==> Unknown key "' + key + '"');
-                break;
-            }
-            var entry = expected[key];
-            var prev_pos = -1;
-            for (var i = 0; i < entry.length; ++i) {
-                var entry_pos = lookForEntry(entry[i], results[key]);
-                if (entry_pos === null) {
-                    error_text.push("==> Result not found in '" + key + "': '" +
-                                    JSON.stringify(entry[i]) + "'");
-                } else if (exact_check === true && prev_pos + 1 !== entry_pos) {
-                    error_text.push("==> Exact check failed at position " + (prev_pos + 1) + ": " +
-                                    "expected '" + JSON.stringify(entry[i]) + "' but found '" +
-                                    JSON.stringify(results[key][i]) + "'");
-                } else if (ignore_order === false && entry_pos < prev_pos) {
-                    error_text.push("==> '" + JSON.stringify(entry[i]) + "' was supposed to be " +
-                                    " before '" + JSON.stringify(results[key][entry_pos]) + "'");
-                } else {
-                    prev_pos = entry_pos;
-                }
-            }
-        }
-        if (error_text.length === 0 && should_fail === true) {
-            errors += 1;
-            console.error("FAILED");
-            console.error("==> Test was supposed to fail but all items were found...");
-        } else if (error_text.length !== 0 && should_fail === false) {
-            errors += 1;
-            console.error("FAILED");
-            console.error(error_text.join("\n"));
-        } else {
-            // In this case, we remove the docs, no need to keep them around.
-            remove_docs(out_folder);
-            console.log("OK");
-        }
-    });
-    return errors;
-}
-
-process.exit(main(process.argv));
diff --git a/src/tools/rustdoc-js-std/tester.js b/src/tools/rustdoc-js-std/tester.js
new file mode 100644 (file)
index 0000000..f49dd86
--- /dev/null
@@ -0,0 +1,317 @@
+const fs = require('fs');
+
+const TEST_FOLDER = 'src/test/rustdoc-js-std/';
+
+function getNextStep(content, pos, stop) {
+    while (pos < content.length && content[pos] !== stop &&
+           (content[pos] === ' ' || content[pos] === '\t' || content[pos] === '\n')) {
+        pos += 1;
+    }
+    if (pos >= content.length) {
+        return null;
+    }
+    if (content[pos] !== stop) {
+        return pos * -1;
+    }
+    return pos;
+}
+
+// Stupid function extractor based on indent. Doesn't support block
+// comments. If someone puts a ' or an " in a block comment this
+// will blow up. Template strings are not tested and might also be
+// broken.
+function extractFunction(content, functionName) {
+    var indent = 0;
+    var splitter = "function " + functionName + "(";
+
+    while (true) {
+        var start = content.indexOf(splitter);
+        if (start === -1) {
+            break;
+        }
+        var pos = start;
+        while (pos < content.length && content[pos] !== ')') {
+            pos += 1;
+        }
+        if (pos >= content.length) {
+            break;
+        }
+        pos = getNextStep(content, pos + 1, '{');
+        if (pos === null) {
+            break;
+        } else if (pos < 0) {
+            content = content.slice(-pos);
+            continue;
+        }
+        while (pos < content.length) {
+            // Eat single-line comments
+            if (content[pos] === '/' && pos > 0 && content[pos-1] === '/') {
+                do {
+                    pos += 1;
+                } while (pos < content.length && content[pos] !== '\n');
+
+            // Eat quoted strings
+            } else if (content[pos] === '"' || content[pos] === "'" || content[pos] === "`") {
+                var stop = content[pos];
+                var is_escaped = false;
+                do {
+                    if (content[pos] === '\\') {
+                        pos += 2;
+                    } else {
+                        pos += 1;
+                    }
+                } while (pos < content.length &&
+                         (content[pos] !== stop || content[pos - 1] === '\\'));
+
+            // Otherwise, check for indent
+            } else if (content[pos] === '{') {
+                indent += 1;
+            } else if (content[pos] === '}') {
+                indent -= 1;
+                if (indent === 0) {
+                    return content.slice(start, pos + 1);
+                }
+            }
+            pos += 1;
+        }
+        content = content.slice(start + 1);
+    }
+    return null;
+}
+
+// Stupid function extractor for array.
+function extractArrayVariable(content, arrayName) {
+    var splitter = "var " + arrayName;
+    while (true) {
+        var start = content.indexOf(splitter);
+        if (start === -1) {
+            break;
+        }
+        var pos = getNextStep(content, start, '=');
+        if (pos === null) {
+            break;
+        } else if (pos < 0) {
+            content = content.slice(-pos);
+            continue;
+        }
+        pos = getNextStep(content, pos, '[');
+        if (pos === null) {
+            break;
+        } else if (pos < 0) {
+            content = content.slice(-pos);
+            continue;
+        }
+        while (pos < content.length) {
+            if (content[pos] === '"' || content[pos] === "'") {
+                var stop = content[pos];
+                do {
+                    if (content[pos] === '\\') {
+                        pos += 2;
+                    } else {
+                        pos += 1;
+                    }
+                } while (pos < content.length &&
+                         (content[pos] !== stop || content[pos - 1] === '\\'));
+            } else if (content[pos] === ']' &&
+                       pos + 1 < content.length &&
+                       content[pos + 1] === ';') {
+                return content.slice(start, pos + 2);
+            }
+            pos += 1;
+        }
+        content = content.slice(start + 1);
+    }
+    return null;
+}
+
+// Stupid function extractor for variable.
+function extractVariable(content, varName) {
+    var splitter = "var " + varName;
+    while (true) {
+        var start = content.indexOf(splitter);
+        if (start === -1) {
+            break;
+        }
+        var pos = getNextStep(content, start, '=');
+        if (pos === null) {
+            break;
+        } else if (pos < 0) {
+            content = content.slice(-pos);
+            continue;
+        }
+        while (pos < content.length) {
+            if (content[pos] === '"' || content[pos] === "'") {
+                var stop = content[pos];
+                do {
+                    if (content[pos] === '\\') {
+                        pos += 2;
+                    } else {
+                        pos += 1;
+                    }
+                } while (pos < content.length &&
+                         (content[pos] !== stop || content[pos - 1] === '\\'));
+            } else if (content[pos] === ';') {
+                return content.slice(start, pos + 1);
+            }
+            pos += 1;
+        }
+        content = content.slice(start + 1);
+    }
+    return null;
+}
+
+function loadContent(content) {
+    var Module = module.constructor;
+    var m = new Module();
+    m._compile(content, "tmp.js");
+    m.exports.ignore_order = content.indexOf("\n// ignore-order\n") !== -1 ||
+        content.startsWith("// ignore-order\n");
+    m.exports.exact_check = content.indexOf("\n// exact-check\n") !== -1 ||
+        content.startsWith("// exact-check\n");
+    m.exports.should_fail = content.indexOf("\n// should-fail\n") !== -1 ||
+        content.startsWith("// should-fail\n");
+    return m.exports;
+}
+
+function readFile(filePath) {
+    return fs.readFileSync(filePath, 'utf8');
+}
+
+function loadThings(thingsToLoad, kindOfLoad, funcToCall, fileContent) {
+    var content = '';
+    for (var i = 0; i < thingsToLoad.length; ++i) {
+        var tmp = funcToCall(fileContent, thingsToLoad[i]);
+        if (tmp === null) {
+            console.error('unable to find ' + kindOfLoad + ' "' + thingsToLoad[i] + '"');
+            process.exit(1);
+        }
+        content += tmp;
+        content += 'exports.' + thingsToLoad[i] + ' = ' + thingsToLoad[i] + ';';
+    }
+    return content;
+}
+
+function lookForEntry(entry, data) {
+    for (var i = 0; i < data.length; ++i) {
+        var allGood = true;
+        for (var key in entry) {
+            if (!entry.hasOwnProperty(key)) {
+                continue;
+            }
+            var value = data[i][key];
+            // To make our life easier, if there is a "parent" type, we add it to the path.
+            if (key === 'path' && data[i]['parent'] !== undefined) {
+                if (value.length > 0) {
+                    value += '::' + data[i]['parent']['name'];
+                } else {
+                    value = data[i]['parent']['name'];
+                }
+            }
+            if (value !== entry[key]) {
+                allGood = false;
+                break;
+            }
+        }
+        if (allGood === true) {
+            return i;
+        }
+    }
+    return null;
+}
+
+function main(argv) {
+    if (argv.length !== 3) {
+        console.error("Expected toolchain to check as argument (for example \
+                       'x86_64-apple-darwin')");
+        return 1;
+    }
+    var toolchain = argv[2];
+
+    var mainJs = readFile("build/" + toolchain + "/doc/main.js");
+    var ALIASES = readFile("build/" + toolchain + "/doc/aliases.js");
+    var searchIndex = readFile("build/" + toolchain + "/doc/search-index.js").split("\n");
+    if (searchIndex[searchIndex.length - 1].length === 0) {
+        searchIndex.pop();
+    }
+    searchIndex.pop();
+    searchIndex = loadContent(searchIndex.join("\n") + '\nexports.searchIndex = searchIndex;');
+    finalJS = "";
+
+    var arraysToLoad = ["itemTypes"];
+    var variablesToLoad = ["MAX_LEV_DISTANCE", "MAX_RESULTS",
+                           "GENERICS_DATA", "NAME", "INPUTS_DATA", "OUTPUT_DATA",
+                           "TY_PRIMITIVE", "TY_KEYWORD",
+                           "levenshtein_row2"];
+    // execQuery first parameter is built in getQuery (which takes in the search input).
+    // execQuery last parameter is built in buildIndex.
+    // buildIndex requires the hashmap from search-index.
+    var functionsToLoad = ["buildHrefAndPath", "pathSplitter", "levenshtein", "validateResult",
+                           "getQuery", "buildIndex", "execQuery", "execSearch"];
+
+    finalJS += 'window = { "currentCrate": "std" };\n';
+    finalJS += 'var rootPath = "../";\n';
+    finalJS += ALIASES;
+    finalJS += loadThings(arraysToLoad, 'array', extractArrayVariable, mainJs);
+    finalJS += loadThings(variablesToLoad, 'variable', extractVariable, mainJs);
+    finalJS += loadThings(functionsToLoad, 'function', extractFunction, mainJs);
+
+    var loaded = loadContent(finalJS);
+    var index = loaded.buildIndex(searchIndex.searchIndex);
+
+    var errors = 0;
+
+    fs.readdirSync(TEST_FOLDER).forEach(function(file) {
+        var loadedFile = loadContent(readFile(TEST_FOLDER + file) +
+                               'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;');
+        const expected = loadedFile.EXPECTED;
+        const query = loadedFile.QUERY;
+        const filter_crate = loadedFile.FILTER_CRATE;
+        const ignore_order = loadedFile.ignore_order;
+        const exact_check = loadedFile.exact_check;
+        const should_fail = loadedFile.should_fail;
+        var results = loaded.execSearch(loaded.getQuery(query), index);
+        process.stdout.write('Checking "' + file + '" ... ');
+        var error_text = [];
+        for (var key in expected) {
+            if (!expected.hasOwnProperty(key)) {
+                continue;
+            }
+            if (!results.hasOwnProperty(key)) {
+                error_text.push('==> Unknown key "' + key + '"');
+                break;
+            }
+            var entry = expected[key];
+            var prev_pos = -1;
+            for (var i = 0; i < entry.length; ++i) {
+                var entry_pos = lookForEntry(entry[i], results[key]);
+                if (entry_pos === null) {
+                    error_text.push("==> Result not found in '" + key + "': '" +
+                                    JSON.stringify(entry[i]) + "'");
+                } else if (exact_check === true && prev_pos + 1 !== entry_pos) {
+                    error_text.push("==> Exact check failed at position " + (prev_pos + 1) + ": " +
+                                    "expected '" + JSON.stringify(entry[i]) + "' but found '" +
+                                    JSON.stringify(results[key][i]) + "'");
+                } else if (ignore_order === false && entry_pos < prev_pos) {
+                    error_text.push("==> '" + JSON.stringify(entry[i]) + "' was supposed to be " +
+                                    " before '" + JSON.stringify(results[key][entry_pos]) + "'");
+                } else {
+                    prev_pos = entry_pos;
+                }
+            }
+        }
+        if (error_text.length === 0 && should_fail === true) {
+            errors += 1;
+            console.error("FAILED");
+            console.error("==> Test was supposed to fail but all items were found...");
+        } else if (error_text.length !== 0 && should_fail === false) {
+            errors += 1;
+            console.error("FAILED");
+            console.error(error_text.join("\n"));
+        } else {
+            console.log("OK");
+        }
+    });
+    return errors;
+}
+
+process.exit(main(process.argv));
index 38fdcb4f468cf6b09c3ab9e5c7897805284ff94b..f7c15eaf1b07de779aeb37c1e899d7aa1e6232ac 100644 (file)
@@ -1,4 +1,5 @@
 const fs = require('fs');
+const { spawnSync } = require('child_process');
 
 const TEST_FOLDER = 'src/test/rustdoc-js/';
 
@@ -219,17 +220,22 @@ function lookForEntry(entry, data) {
     return null;
 }
 
-function main(argv) {
-    if (argv.length !== 3) {
-        console.error("Expected toolchain to check as argument (for example \
-                       'x86_64-apple-darwin')");
-        return 1;
+function build_docs(out_dir, rustdoc_path, file_to_document) {
+    var c = spawnSync(rustdoc_path, [file_to_document, '-o', out_dir]);
+    var s = '';
+    if (c.error || c.stderr.length > 0) {
+        if (c.stderr.length > 0) {
+            s += '==> STDERR: ' + c.stderr + '\n';
+        }
+        s += '==> ERROR: ' + c.error;
     }
-    var toolchain = argv[2];
+    return s;
+}
 
-    var mainJs = readFile("build/" + toolchain + "/doc/main.js");
-    var ALIASES = readFile("build/" + toolchain + "/doc/aliases.js");
-    var searchIndex = readFile("build/" + toolchain + "/doc/search-index.js").split("\n");
+function load_files(out_folder, crate) {
+    var mainJs = readFile(out_folder + "/main.js");
+    var ALIASES = readFile(out_folder + "/aliases.js");
+    var searchIndex = readFile(out_folder + "/search-index.js").split("\n");
     if (searchIndex[searchIndex.length - 1].length === 0) {
         searchIndex.pop();
     }
@@ -248,7 +254,7 @@ function main(argv) {
     var functionsToLoad = ["buildHrefAndPath", "pathSplitter", "levenshtein", "validateResult",
                            "getQuery", "buildIndex", "execQuery", "execSearch"];
 
-    finalJS += 'window = { "currentCrate": "std" };\n';
+    finalJS += 'window = { "currentCrate": "' + crate + '" };\n';
     finalJS += 'var rootPath = "../";\n';
     finalJS += ALIASES;
     finalJS += loadThings(arraysToLoad, 'array', extractArrayVariable, mainJs);
@@ -256,11 +262,47 @@ function main(argv) {
     finalJS += loadThings(functionsToLoad, 'function', extractFunction, mainJs);
 
     var loaded = loadContent(finalJS);
-    var index = loaded.buildIndex(searchIndex.searchIndex);
+    return [loaded, loaded.buildIndex(searchIndex.searchIndex)];
+}
+
+function main(argv) {
+    if (argv.length !== 4) {
+        console.error("USAGE: node tester.js [TOOLCHAIN] [STAGE]");
+        return 1;
+    }
+    const toolchain = argv[2];
+    const stage = argv[3];
+    const rustdoc_path = './build/' + toolchain + '/stage' + stage + '/bin/rustdoc';
 
     var errors = 0;
 
     fs.readdirSync(TEST_FOLDER).forEach(function(file) {
+        if (!file.endsWith('.js')) {
+            return;
+        }
+        var test_name = file.substring(0, file.length - 3);
+        process.stdout.write('Checking "' + test_name + '" ... ');
+        var rust_file = TEST_FOLDER + test_name + '.rs';
+
+        if (!fs.existsSync(rust_file)) {
+            console.error("FAILED");
+            console.error("==> Missing '" + test_name + ".rs' file...");
+            errors += 1;
+            return;
+        }
+
+        var out_folder = "build/" + toolchain + "/stage" + stage + "/tests/rustdoc-js/" +
+                         test_name;
+
+        var ret = build_docs(out_folder, rustdoc_path, rust_file);
+        if (ret.length > 0) {
+            console.error("FAILED");
+            console.error(ret);
+            errors += 1;
+            return;
+        }
+
+        var [loaded, index] = load_files(out_folder, test_name);
         var loadedFile = loadContent(readFile(TEST_FOLDER + file) +
                                'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;');
         const expected = loadedFile.EXPECTED;
@@ -270,7 +312,6 @@ function main(argv) {
         const exact_check = loadedFile.exact_check;
         const should_fail = loadedFile.should_fail;
         var results = loaded.execSearch(loaded.getQuery(query), index);
-        process.stdout.write('Checking "' + file + '" ... ');
         var error_text = [];
         for (var key in expected) {
             if (!expected.hasOwnProperty(key)) {