Skip to content

Commit

Permalink
Allow to run only a few GUI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jun 14, 2021
1 parent 7510b0c commit 6a66b79
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/bootstrap/test.rs
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
Expand Down
18 changes: 15 additions & 3 deletions src/tools/rustdoc-gui/tester.js
Expand Up @@ -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");
}
Expand All @@ -18,6 +19,7 @@ function parseOptions(args) {
var opts = {
"doc_folder": "",
"tests_folder": "",
"files": [],
};
var correspondances = {
"--doc-folder": "doc_folder",
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 6a66b79

Please sign in to comment.