Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Greatly improve limitation handling on parallel rustdoc GUI test run #88188

Merged
merged 1 commit into from
Aug 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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