提交 b7fe005e 编写于 作者: G Guillaume Gomez

Greatly improve limitation handling on parallel rustdoc GUI test run

上级 52173478
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// ``` // ```
// npm install browser-ui-test // npm install browser-ui-test
// ``` // ```
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const path = require("path");
const os = require('os'); const os = require('os');
...@@ -172,12 +173,14 @@ async function main(argv) { ...@@ -172,12 +173,14 @@ async function main(argv) {
files.sort(); files.sort();
console.log(`Running ${files.length} rustdoc-gui tests...`); console.log(`Running ${files.length} rustdoc-gui tests...`);
if (opts["jobs"] < 1) { if (opts["jobs"] < 1) {
process.setMaxListeners(files.length + 1); process.setMaxListeners(files.length + 1);
} else { } else {
process.setMaxListeners(opts["jobs"]); process.setMaxListeners(opts["jobs"] + 1);
} }
let tests = [];
const tests_queue = [];
let results = { let results = {
successful: [], successful: [],
failed: [], failed: [],
...@@ -187,8 +190,7 @@ async function main(argv) { ...@@ -187,8 +190,7 @@ async function main(argv) {
for (let i = 0; i < files.length; ++i) { for (let i = 0; i < files.length; ++i) {
const file_name = files[i]; const file_name = files[i];
const testPath = path.join(opts["tests_folder"], file_name); const testPath = path.join(opts["tests_folder"], file_name);
tests.push( const callback = runTest(testPath, options)
runTest(testPath, options)
.then(out => { .then(out => {
const [output, nb_failures] = out; const [output, nb_failures] = out;
results[nb_failures === 0 ? "successful" : "failed"].push({ results[nb_failures === 0 ? "successful" : "failed"].push({
...@@ -196,10 +198,10 @@ async function main(argv) { ...@@ -196,10 +198,10 @@ async function main(argv) {
output: output, output: output,
}); });
if (nb_failures > 0) { if (nb_failures > 0) {
status_bar.erroneous() status_bar.erroneous();
failed = true; failed = true;
} else { } else {
status_bar.successful() status_bar.successful();
} }
}) })
.catch(err => { .catch(err => {
...@@ -210,13 +212,19 @@ async function main(argv) { ...@@ -210,13 +212,19 @@ async function main(argv) {
status_bar.erroneous(); status_bar.erroneous();
failed = true; 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) { 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) { if (!no_headless && tests_queue.length > 0) {
await Promise.all(tests); await Promise.all(tests_queue);
} }
status_bar.finish(); status_bar.finish();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册