diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-08-18 19:55:00 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-18 19:55:00 +0200 |
| commit | fe025a71a15044d16f367714f83d32a46a51f32c (patch) | |
| tree | 54764ba33411233d405d2c83c209e825a9ae680c | |
| parent | 016f691068fee70a99d2c0024ebe26b3e10f02d5 (diff) | |
| parent | 9c21da6ecec2e9668b27647baa2e5ed2dcd462b7 (diff) | |
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`
| -rw-r--r-- | src/bootstrap/test.rs | 2 | ||||
| -rw-r--r-- | src/tools/rustdoc-gui/tester.js | 24 |
2 files changed, 23 insertions, 3 deletions
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 9effdb2c959..d12e86b7c1d 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -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") diff --git a/src/tools/rustdoc-gui/tester.js b/src/tools/rustdoc-gui/tester.js index d1cf5fb803d..e697e1f86a9 100644 --- a/src/tools/rustdoc-gui/tester.js +++ b/src/tools/rustdoc-gui/tester.js @@ -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) { @@ -27,6 +32,7 @@ function parseOptions(args) { "debug": false, "show_text": false, "no_headless": false, + "jobs": -1, }; var correspondances = { "--doc-folder": "doc_folder", @@ -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]); @@ -158,7 +172,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: [], |
