Skip to content

Commit

Permalink
Take into account jobs number for rustdoc gui tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Aug 16, 2021
1 parent 73d96b0 commit 9c21da6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
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"]);
}
let tests = [];
let results = {
successful: [],
Expand Down

0 comments on commit 9c21da6

Please sign in to comment.