From 6a66b79fb6b85f01aeaa1cd339160957a98c97a6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 14 Jun 2021 16:40:10 +0200 Subject: [PATCH] Allow to run only a few GUI tests --- src/bootstrap/test.rs | 9 ++++++++- src/tools/rustdoc-gui/tester.js | 18 +++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index fe4666effe622..0b7a0e25df1ac 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -805,7 +805,7 @@ impl Step for RustdocGUI { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; - let run = run.path("src/test/rustdoc-gui"); + let run = run.suite_path("src/test/rustdoc-gui"); run.default_condition( builder.config.nodejs.is_some() && builder @@ -870,6 +870,13 @@ impl Step for RustdocGUI { .arg(out_dir) .arg("--tests-folder") .arg(builder.build.src.join("src/test/rustdoc-gui")); + for path in &builder.paths { + if let Some(name) = path.file_name().and_then(|f| f.to_str()) { + if name.ends_with(".goml") { + command.arg("--file").arg(name); + } + } + } builder.run(&mut command); } } diff --git a/src/tools/rustdoc-gui/tester.js b/src/tools/rustdoc-gui/tester.js index c55e014e834d4..8c8d86d5e3817 100644 --- a/src/tools/rustdoc-gui/tester.js +++ b/src/tools/rustdoc-gui/tester.js @@ -10,6 +10,7 @@ const {Options, runTest} = require('browser-ui-test'); function showHelp() { console.log("rustdoc-js options:"); console.log(" --doc-folder [PATH] : location of the generated doc folder"); + console.log(" --file [PATH] : file to run (can be repeated)"); console.log(" --help : show this message then quit"); console.log(" --tests-folder [PATH] : location of the .GOML tests folder"); } @@ -18,6 +19,7 @@ function parseOptions(args) { var opts = { "doc_folder": "", "tests_folder": "", + "files": [], }; var correspondances = { "--doc-folder": "doc_folder", @@ -26,13 +28,18 @@ function parseOptions(args) { for (var i = 0; i < args.length; ++i) { if (args[i] === "--doc-folder" - || args[i] === "--tests-folder") { + || args[i] === "--tests-folder" + || args[i] === "--file") { i += 1; if (i >= args.length) { console.log("Missing argument after `" + args[i - 1] + "` option."); return null; } - opts[correspondances[args[i - 1]]] = args[i]; + if (args[i - 1] !== "--file") { + opts[correspondances[args[i - 1]]] = args[i]; + } else { + opts["files"].push(args[i]); + } } else if (args[i] === "--help") { showHelp(); process.exit(0); @@ -78,7 +85,12 @@ async function main(argv) { } let failed = false; - let files = fs.readdirSync(opts["tests_folder"]).filter(file => path.extname(file) == ".goml"); + let files; + if (opts["files"].length === 0) { + files = fs.readdirSync(opts["tests_folder"]).filter(file => path.extname(file) == ".goml"); + } else { + files = opts["files"].filter(file => path.extname(file) == ".goml"); + } files.sort(); for (var i = 0; i < files.length; ++i) {