From 4c1e24beb7dcf9b838f3b4963b527747c8a4e682 Mon Sep 17 00:00:00 2001
From: Guillaume Gomez <guillaume.gomez@huawei.com>
Date: Mon, 6 Dec 2021 10:40:38 +0100
Subject: [PATCH] Improve code for rustdoc-gui tester

---
 src/tools/rustdoc-gui/tester.js | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/tools/rustdoc-gui/tester.js b/src/tools/rustdoc-gui/tester.js
index 3feb4940d87f8..32340ec7eecf2 100644
--- a/src/tools/rustdoc-gui/tester.js
+++ b/src/tools/rustdoc-gui/tester.js
@@ -133,7 +133,7 @@ async function main(argv) {
     // Print successful tests too
     let debug = false;
     // Run tests in sequentially
-    let no_headless = false;
+    let headless = true;
     const options = new Options();
     try {
         // This is more convenient that setting fields one by one.
@@ -150,7 +150,7 @@ async function main(argv) {
         }
         if (opts["no_headless"]) {
             args.push("--no-headless");
-            no_headless = true;
+            headless = false;
         }
         options.parseArguments(args);
     } catch (error) {
@@ -172,7 +172,7 @@ async function main(argv) {
     }
     files.sort();
 
-    if (no_headless) {
+    if (!headless) {
         opts["jobs"] = 1;
         console.log("`--no-headless` option is active, disabling concurrency for running tests.");
     }
@@ -181,7 +181,7 @@ async function main(argv) {
 
     if (opts["jobs"] < 1) {
         process.setMaxListeners(files.length + 1);
-    } else if (!no_headless) {
+    } else if (headless) {
         process.setMaxListeners(opts["jobs"] + 1);
     }
 
@@ -226,7 +226,7 @@ async function main(argv) {
             await Promise.race(tests_queue);
         }
     }
-    if (!no_headless && tests_queue.length > 0) {
+    if (tests_queue.length > 0) {
         await Promise.all(tests_queue);
     }
     status_bar.finish();