]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/rustdoc-js/tester.js
Auto merge of #91101 - birkenfeld:io_error_docs, r=Mark-Simulacrum
[rust.git] / src / tools / rustdoc-js / tester.js
index bb9cd00f3f5829196df0a2a93d12274d82702f8a..4f73a7f634098f2f7d6846e593a083c24877fcb4 100644 (file)
@@ -401,7 +401,8 @@ function showHelp() {
     console.log("  --doc-folder [PATH]        : location of the generated doc folder");
     console.log("  --help                     : show this message then quit");
     console.log("  --crate-name [STRING]      : crate name to be used");
-    console.log("  --test-file [PATH]         : location of the JS test file");
+    console.log("  --test-file [PATHs]        : location of the JS test files (can be called " +
+                "multiple times)");
     console.log("  --test-folder [PATH]       : location of the JS tests folder");
     console.log("  --resource-suffix [STRING] : suffix to refer to the correct files");
 }
@@ -412,9 +413,9 @@ function parseOptions(args) {
         "resource_suffix": "",
         "doc_folder": "",
         "test_folder": "",
-        "test_file": "",
+        "test_file": [],
     };
-    var correspondances = {
+    var correspondences = {
         "--resource-suffix": "resource_suffix",
         "--doc-folder": "doc_folder",
         "--test-folder": "test_folder",
@@ -423,17 +424,17 @@ function parseOptions(args) {
     };
 
     for (var i = 0; i < args.length; ++i) {
-        if (args[i] === "--resource-suffix"
-            || args[i] === "--doc-folder"
-            || args[i] === "--test-folder"
-            || args[i] === "--test-file"
-            || args[i] === "--crate-name") {
+        if (correspondences.hasOwnProperty(args[i])) {
             i += 1;
             if (i >= args.length) {
                 console.log("Missing argument after `" + args[i - 1] + "` option.");
                 return null;
             }
-            opts[correspondances[args[i - 1]]] = args[i];
+            if (args[i - 1] !== "--test-file") {
+                opts[correspondences[args[i - 1]]] = args[i];
+            } else {
+                opts[correspondences[args[i - 1]]].push(args[i]);
+            }
         } else if (args[i] === "--help") {
             showHelp();
             process.exit(0);
@@ -475,9 +476,10 @@ function main(argv) {
     var errors = 0;
 
     if (opts["test_file"].length !== 0) {
-        errors += checkFile(opts["test_file"], opts, loaded, index);
-    }
-    if (opts["test_folder"].length !== 0) {
+        opts["test_file"].forEach(function(file) {
+            errors += checkFile(file, opts, loaded, index);
+        });
+    } else if (opts["test_folder"].length !== 0) {
         fs.readdirSync(opts["test_folder"]).forEach(function(file) {
             if (!file.endsWith(".js")) {
                 return;