about summary refs log tree commit diff
path: root/src/tools/rustdoc-gui/tester.js
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2021-08-20 20:55:48 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2021-08-23 14:23:59 +0200
commitb7fe005eefda2a6df190f3d6a2ba8a51fb3acbe2 (patch)
tree4ecb3e3ec2fb5fdbc6a78e7f5af4b0ecf22d0455 /src/tools/rustdoc-gui/tester.js
parent521734787ecf80ff12df7ca5998f7ec0b3b7b2c9 (diff)
downloadrust-b7fe005eefda2a6df190f3d6a2ba8a51fb3acbe2.tar.gz
rust-b7fe005eefda2a6df190f3d6a2ba8a51fb3acbe2.zip
Greatly improve limitation handling on parallel rustdoc GUI test run
Diffstat (limited to 'src/tools/rustdoc-gui/tester.js')
-rw-r--r--src/tools/rustdoc-gui/tester.js28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/tools/rustdoc-gui/tester.js b/src/tools/rustdoc-gui/tester.js
index e697e1f86a9..d34dcc0f094 100644
--- a/src/tools/rustdoc-gui/tester.js
+++ b/src/tools/rustdoc-gui/tester.js
@@ -3,6 +3,7 @@
 // ```
 // npm install browser-ui-test
 // ```
+
 const fs = require("fs");
 const path = require("path");
 const os = require('os');
@@ -172,12 +173,14 @@ async function main(argv) {
     files.sort();
 
     console.log(`Running ${files.length} rustdoc-gui tests...`);
+
     if (opts["jobs"] < 1) {
         process.setMaxListeners(files.length + 1);
     } else {
-        process.setMaxListeners(opts["jobs"]);
+        process.setMaxListeners(opts["jobs"] + 1);
     }
-    let tests = [];
+
+    const tests_queue = [];
     let results = {
         successful: [],
         failed: [],
@@ -187,8 +190,7 @@ async function main(argv) {
     for (let i = 0; i < files.length; ++i) {
         const file_name = files[i];
         const testPath = path.join(opts["tests_folder"], file_name);
-        tests.push(
-            runTest(testPath, options)
+        const callback = runTest(testPath, options)
             .then(out => {
                 const [output, nb_failures] = out;
                 results[nb_failures === 0 ? "successful" : "failed"].push({
@@ -196,10 +198,10 @@ async function main(argv) {
                     output: output,
                 });
                 if (nb_failures > 0) {
-                    status_bar.erroneous()
+                    status_bar.erroneous();
                     failed = true;
                 } else {
-                    status_bar.successful()
+                    status_bar.successful();
                 }
             })
             .catch(err => {
@@ -210,13 +212,19 @@ async function main(argv) {
                 status_bar.erroneous();
                 failed = true;
             })
-        );
+            .finally(() => {
+                // We now remove the promise from the tests_queue.
+                tests_queue.splice(tests_queue.indexOf(callback), 1);
+            });
+        tests_queue.push(callback);
         if (no_headless) {
-            await tests[i];
+            await tests_queue[i];
+        } else if (opts["jobs"] > 0 && tests_queue.length >= opts["jobs"]) {
+            await Promise.race(tests_queue);
         }
     }
-    if (!no_headless) {
-        await Promise.all(tests);
+    if (!no_headless && tests_queue.length > 0) {
+        await Promise.all(tests_queue);
     }
     status_bar.finish();