Skip to content

Commit fe025a7

Browse files
Rollup merge of #88082 - GuillaumeGomez:rustdoc-gui-jobs-opt, r=dns2utf8
Take into account jobs number for rustdoc GUI tests Fixes #88054. r? `@Mark-Simulacrum`
2 parents 016f691 + 9c21da6 commit fe025a7

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/bootstrap/test.rs

+2
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,8 @@ impl Step for RustdocGUI {
933933
let mut command = Command::new(&nodejs);
934934
command
935935
.arg(builder.build.src.join("src/tools/rustdoc-gui/tester.js"))
936+
.arg("--jobs")
937+
.arg(&builder.jobs().to_string())
936938
.arg("--doc-folder")
937939
.arg(out_dir.join("doc"))
938940
.arg("--tests-folder")

src/tools/rustdoc-gui/tester.js

+21-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ function showHelp() {
1717
console.log(" --no-headless : disable headless mode");
1818
console.log(" --help : show this message then quit");
1919
console.log(" --tests-folder [PATH] : location of the .GOML tests folder");
20+
console.log(" --jobs [NUMBER] : number of threads to run tests on");
21+
}
22+
23+
function isNumeric(s) {
24+
return /^\d+$/.test(s);
2025
}
2126

2227
function parseOptions(args) {
@@ -27,6 +32,7 @@ function parseOptions(args) {
2732
"debug": false,
2833
"show_text": false,
2934
"no_headless": false,
35+
"jobs": -1,
3036
};
3137
var correspondances = {
3238
"--doc-folder": "doc_folder",
@@ -39,13 +45,21 @@ function parseOptions(args) {
3945
for (var i = 0; i < args.length; ++i) {
4046
if (args[i] === "--doc-folder"
4147
|| args[i] === "--tests-folder"
42-
|| args[i] === "--file") {
48+
|| args[i] === "--file"
49+
|| args[i] === "--jobs") {
4350
i += 1;
4451
if (i >= args.length) {
4552
console.log("Missing argument after `" + args[i - 1] + "` option.");
4653
return null;
4754
}
48-
if (args[i - 1] !== "--file") {
55+
if (args[i - 1] === "--jobs") {
56+
if (!isNumeric(args[i])) {
57+
console.log(
58+
"`--jobs` option expects a positive number, found `" + args[i] + "`");
59+
return null;
60+
}
61+
opts["jobs"] = parseInt(args[i]);
62+
} else if (args[i - 1] !== "--file") {
4963
opts[correspondances[args[i - 1]]] = args[i];
5064
} else {
5165
opts["files"].push(args[i]);
@@ -158,7 +172,11 @@ async function main(argv) {
158172
files.sort();
159173

160174
console.log(`Running ${files.length} rustdoc-gui tests...`);
161-
process.setMaxListeners(files.length + 1);
175+
if (opts["jobs"] < 1) {
176+
process.setMaxListeners(files.length + 1);
177+
} else {
178+
process.setMaxListeners(opts["jobs"]);
179+
}
162180
let tests = [];
163181
let results = {
164182
successful: [],

0 commit comments

Comments
 (0)