Skip to content

Commit

Permalink
Greatly improve limitation handling on parallel rustdoc GUI test run
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Aug 23, 2021
1 parent 5217347 commit b7fe005
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/tools/rustdoc-gui/tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// ```
// npm install browser-ui-test
// ```

const fs = require("fs");
const path = require("path");
const os = require('os');
Expand Down Expand Up @@ -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: [],
Expand All @@ -187,19 +190,18 @@ 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({
file_name: file_name,
output: output,
});
if (nb_failures > 0) {
status_bar.erroneous()
status_bar.erroneous();
failed = true;
} else {
status_bar.successful()
status_bar.successful();
}
})
.catch(err => {
Expand All @@ -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();

Expand Down

0 comments on commit b7fe005

Please sign in to comment.