Skip to content

Commit 6d1c5b6

Browse files
authored
Rollup merge of #88188 - GuillaumeGomez:rustdoc-gui-parallel-limit, r=dns2utf8
Greatly improve limitation handling on parallel rustdoc GUI test run Follow-up of #88082. r? `@dns2utf8`
2 parents d486ce7 + b7fe005 commit 6d1c5b6

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/tools/rustdoc-gui/tester.js

+18-10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// ```
44
// npm install browser-ui-test
55
// ```
6+
67
const fs = require("fs");
78
const path = require("path");
89
const os = require('os');
@@ -172,12 +173,14 @@ async function main(argv) {
172173
files.sort();
173174

174175
console.log(`Running ${files.length} rustdoc-gui tests...`);
176+
175177
if (opts["jobs"] < 1) {
176178
process.setMaxListeners(files.length + 1);
177179
} else {
178-
process.setMaxListeners(opts["jobs"]);
180+
process.setMaxListeners(opts["jobs"] + 1);
179181
}
180-
let tests = [];
182+
183+
const tests_queue = [];
181184
let results = {
182185
successful: [],
183186
failed: [],
@@ -187,19 +190,18 @@ async function main(argv) {
187190
for (let i = 0; i < files.length; ++i) {
188191
const file_name = files[i];
189192
const testPath = path.join(opts["tests_folder"], file_name);
190-
tests.push(
191-
runTest(testPath, options)
193+
const callback = runTest(testPath, options)
192194
.then(out => {
193195
const [output, nb_failures] = out;
194196
results[nb_failures === 0 ? "successful" : "failed"].push({
195197
file_name: file_name,
196198
output: output,
197199
});
198200
if (nb_failures > 0) {
199-
status_bar.erroneous()
201+
status_bar.erroneous();
200202
failed = true;
201203
} else {
202-
status_bar.successful()
204+
status_bar.successful();
203205
}
204206
})
205207
.catch(err => {
@@ -210,13 +212,19 @@ async function main(argv) {
210212
status_bar.erroneous();
211213
failed = true;
212214
})
213-
);
215+
.finally(() => {
216+
// We now remove the promise from the tests_queue.
217+
tests_queue.splice(tests_queue.indexOf(callback), 1);
218+
});
219+
tests_queue.push(callback);
214220
if (no_headless) {
215-
await tests[i];
221+
await tests_queue[i];
222+
} else if (opts["jobs"] > 0 && tests_queue.length >= opts["jobs"]) {
223+
await Promise.race(tests_queue);
216224
}
217225
}
218-
if (!no_headless) {
219-
await Promise.all(tests);
226+
if (!no_headless && tests_queue.length > 0) {
227+
await Promise.all(tests_queue);
220228
}
221229
status_bar.finish();
222230

0 commit comments

Comments
 (0)