Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,8 @@ impl Step for RustdocGUI {
let mut command = Command::new(&nodejs);
command
.arg(builder.build.src.join("src/tools/rustdoc-gui/tester.js"))
.arg("--jobs")
.arg(&builder.jobs().to_string())
.arg("--doc-folder")
.arg(out_dir.join("doc"))
.arg("--tests-folder")
Expand Down
24 changes: 21 additions & 3 deletions src/tools/rustdoc-gui/tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ function showHelp() {
console.log(" --no-headless : disable headless mode");
console.log(" --help : show this message then quit");
console.log(" --tests-folder [PATH] : location of the .GOML tests folder");
console.log(" --jobs [NUMBER] : number of threads to run tests on");
}

function isNumeric(s) {
return /^\d+$/.test(s);
}

function parseOptions(args) {
Expand All @@ -27,6 +32,7 @@ function parseOptions(args) {
"debug": false,
"show_text": false,
"no_headless": false,
"jobs": -1,
};
var correspondances = {
"--doc-folder": "doc_folder",
Expand All @@ -39,13 +45,21 @@ function parseOptions(args) {
for (var i = 0; i < args.length; ++i) {
if (args[i] === "--doc-folder"
|| args[i] === "--tests-folder"
|| args[i] === "--file") {
|| args[i] === "--file"
|| args[i] === "--jobs") {
i += 1;
if (i >= args.length) {
console.log("Missing argument after `" + args[i - 1] + "` option.");
return null;
}
if (args[i - 1] !== "--file") {
if (args[i - 1] === "--jobs") {
if (!isNumeric(args[i])) {
console.log(
"`--jobs` option expects a positive number, found `" + args[i] + "`");
return null;
}
opts["jobs"] = parseInt(args[i]);
} else if (args[i - 1] !== "--file") {
opts[correspondances[args[i - 1]]] = args[i];
} else {
opts["files"].push(args[i]);
Expand Down Expand Up @@ -153,7 +167,11 @@ async function main(argv) {
files.sort();

console.log(`Running ${files.length} rustdoc-gui tests...`);
process.setMaxListeners(files.length + 1);
if (opts["jobs"] < 1) {
process.setMaxListeners(files.length + 1);
} else {
process.setMaxListeners(opts["jobs"]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this give a warning to the users? If I remember correctly that warning was the reason why I increased the number to files.length + 1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't have any warning, so no idea. But we shouldn't go above the limit provided by the tester in any case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool ☺️ It is a very clean solution 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\o/

}
let tests = [];
let results = {
successful: [],
Expand Down