1
Fork 0

Don't stop running rustdoc-gui tests at first failure

This commit is contained in:
Guillaume Gomez 2021-05-07 16:51:00 +02:00
parent e5f83d24ae
commit 919bfd86d9
2 changed files with 38 additions and 46 deletions

View file

@ -831,28 +831,14 @@ impl Step for RustdocGUI {
command.arg("src/test/rustdoc-gui/lib.rs").arg("-o").arg(&out_dir); command.arg("src/test/rustdoc-gui/lib.rs").arg("-o").arg(&out_dir);
builder.run(&mut command); builder.run(&mut command);
let mut tests = Vec::new(); let mut command = Command::new(&nodejs);
for file in fs::read_dir("src/test/rustdoc-gui").unwrap() { command
let file = file.unwrap(); .arg("src/tools/rustdoc-gui/tester.js")
let file_path = file.path(); .arg("--doc-folder")
let file_name = file.file_name(); .arg(out_dir.join("test_docs"))
.arg("--tests-folder")
if !file_name.to_str().unwrap().ends_with(".goml") { .arg("src/test/rustdoc-gui");
continue; builder.run(&mut command);
}
tests.push(file_path);
}
tests.sort_unstable();
for test in tests {
let mut command = Command::new(&nodejs);
command
.arg("src/tools/rustdoc-gui/tester.js")
.arg("--doc-folder")
.arg(out_dir.join("test_docs"))
.arg("--test-file")
.arg(test);
builder.run(&mut command);
}
} else { } else {
builder.info("No nodejs found, skipping \"src/test/rustdoc-gui\" tests"); builder.info("No nodejs found, skipping \"src/test/rustdoc-gui\" tests");
} }

View file

@ -3,29 +3,30 @@
// ``` // ```
// npm install browser-ui-test // npm install browser-ui-test
// ``` // ```
const path = require('path'); const fs = require("fs");
const path = require("path");
const {Options, runTest} = require('browser-ui-test'); const {Options, runTest} = require('browser-ui-test');
function showHelp() { function showHelp() {
console.log("rustdoc-js options:"); console.log("rustdoc-js options:");
console.log(" --doc-folder [PATH] : location of the generated doc folder"); console.log(" --doc-folder [PATH] : location of the generated doc folder");
console.log(" --help : show this message then quit"); console.log(" --help : show this message then quit");
console.log(" --test-file [PATH] : location of the JS test file"); console.log(" --tests-folder [PATH] : location of the .GOML tests folder");
} }
function parseOptions(args) { function parseOptions(args) {
var opts = { var opts = {
"doc_folder": "", "doc_folder": "",
"test_file": "", "tests_folder": "",
}; };
var correspondances = { var correspondances = {
"--doc-folder": "doc_folder", "--doc-folder": "doc_folder",
"--test-file": "test_file", "--tests-folder": "tests_folder",
}; };
for (var i = 0; i < args.length; ++i) { for (var i = 0; i < args.length; ++i) {
if (args[i] === "--doc-folder" if (args[i] === "--doc-folder"
|| args[i] === "--test-file") { || args[i] === "--tests-folder") {
i += 1; i += 1;
if (i >= args.length) { if (i >= args.length) {
console.log("Missing argument after `" + args[i - 1] + "` option."); console.log("Missing argument after `" + args[i - 1] + "` option.");
@ -41,8 +42,8 @@ function parseOptions(args) {
return null; return null;
} }
} }
if (opts["test_file"].length < 1) { if (opts["tests_folder"].length < 1) {
console.log("Missing `--test-file` option."); console.log("Missing `--tests-folder` option.");
} else if (opts["doc_folder"].length < 1) { } else if (opts["doc_folder"].length < 1) {
console.log("Missing `--doc-folder` option."); console.log("Missing `--doc-folder` option.");
} else { } else {
@ -51,15 +52,8 @@ function parseOptions(args) {
return null; return null;
} }
function checkFile(test_file, opts, loaded, index) { async function main(argv) {
const test_name = path.basename(test_file, ".js"); let opts = parseOptions(argv.slice(2));
process.stdout.write('Checking "' + test_name + '" ... ');
return runChecks(test_file, loaded, index);
}
function main(argv) {
var opts = parseOptions(argv.slice(2));
if (opts === null) { if (opts === null) {
process.exit(1); process.exit(1);
} }
@ -68,7 +62,7 @@ function main(argv) {
try { try {
// This is more convenient that setting fields one by one. // This is more convenient that setting fields one by one.
options.parseArguments([ options.parseArguments([
'--no-screenshot', "--no-screenshot",
"--variable", "DOC_PATH", opts["doc_folder"], "--variable", "DOC_PATH", opts["doc_folder"],
]); ]);
} catch (error) { } catch (error) {
@ -76,14 +70,26 @@ function main(argv) {
process.exit(1); process.exit(1);
} }
runTest(opts["test_file"], options).then(out => { let failed = false;
const [output, nb_failures] = out; let files = fs.readdirSync(opts["tests_folder"]).filter(file => path.extname(file) == ".goml");
console.log(output);
process.exit(nb_failures); files.sort();
}).catch(err => { for (var i = 0; i < files.length; ++i) {
console.error(err); const testPath = path.join(opts["tests_folder"], files[i]);
await runTest(testPath, options).then(out => {
const [output, nb_failures] = out;
console.log(output);
if (nb_failures > 0) {
failed = true;
}
}).catch(err => {
console.error(err);
failed = true;
});
}
if (failed) {
process.exit(1); process.exit(1);
}); }
} }
main(process.argv); main(process.argv);