Skip to content

Commit 919bfd8

Browse files
Don't stop running rustdoc-gui tests at first failure
1 parent e5f83d2 commit 919bfd8

File tree

2 files changed

+38
-46
lines changed

2 files changed

+38
-46
lines changed

src/bootstrap/test.rs

+8-22
Original file line numberDiff line numberDiff line change
@@ -831,28 +831,14 @@ impl Step for RustdocGUI {
831831
command.arg("src/test/rustdoc-gui/lib.rs").arg("-o").arg(&out_dir);
832832
builder.run(&mut command);
833833

834-
let mut tests = Vec::new();
835-
for file in fs::read_dir("src/test/rustdoc-gui").unwrap() {
836-
let file = file.unwrap();
837-
let file_path = file.path();
838-
let file_name = file.file_name();
839-
840-
if !file_name.to_str().unwrap().ends_with(".goml") {
841-
continue;
842-
}
843-
tests.push(file_path);
844-
}
845-
tests.sort_unstable();
846-
for test in tests {
847-
let mut command = Command::new(&nodejs);
848-
command
849-
.arg("src/tools/rustdoc-gui/tester.js")
850-
.arg("--doc-folder")
851-
.arg(out_dir.join("test_docs"))
852-
.arg("--test-file")
853-
.arg(test);
854-
builder.run(&mut command);
855-
}
834+
let mut command = Command::new(&nodejs);
835+
command
836+
.arg("src/tools/rustdoc-gui/tester.js")
837+
.arg("--doc-folder")
838+
.arg(out_dir.join("test_docs"))
839+
.arg("--tests-folder")
840+
.arg("src/test/rustdoc-gui");
841+
builder.run(&mut command);
856842
} else {
857843
builder.info("No nodejs found, skipping \"src/test/rustdoc-gui\" tests");
858844
}

src/tools/rustdoc-gui/tester.js

+30-24
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,30 @@
33
// ```
44
// npm install browser-ui-test
55
// ```
6-
const path = require('path');
6+
const fs = require("fs");
7+
const path = require("path");
78
const {Options, runTest} = require('browser-ui-test');
89

910
function showHelp() {
1011
console.log("rustdoc-js options:");
1112
console.log(" --doc-folder [PATH] : location of the generated doc folder");
1213
console.log(" --help : show this message then quit");
13-
console.log(" --test-file [PATH] : location of the JS test file");
14+
console.log(" --tests-folder [PATH] : location of the .GOML tests folder");
1415
}
1516

1617
function parseOptions(args) {
1718
var opts = {
1819
"doc_folder": "",
19-
"test_file": "",
20+
"tests_folder": "",
2021
};
2122
var correspondances = {
2223
"--doc-folder": "doc_folder",
23-
"--test-file": "test_file",
24+
"--tests-folder": "tests_folder",
2425
};
2526

2627
for (var i = 0; i < args.length; ++i) {
2728
if (args[i] === "--doc-folder"
28-
|| args[i] === "--test-file") {
29+
|| args[i] === "--tests-folder") {
2930
i += 1;
3031
if (i >= args.length) {
3132
console.log("Missing argument after `" + args[i - 1] + "` option.");
@@ -41,8 +42,8 @@ function parseOptions(args) {
4142
return null;
4243
}
4344
}
44-
if (opts["test_file"].length < 1) {
45-
console.log("Missing `--test-file` option.");
45+
if (opts["tests_folder"].length < 1) {
46+
console.log("Missing `--tests-folder` option.");
4647
} else if (opts["doc_folder"].length < 1) {
4748
console.log("Missing `--doc-folder` option.");
4849
} else {
@@ -51,15 +52,8 @@ function parseOptions(args) {
5152
return null;
5253
}
5354

54-
function checkFile(test_file, opts, loaded, index) {
55-
const test_name = path.basename(test_file, ".js");
56-
57-
process.stdout.write('Checking "' + test_name + '" ... ');
58-
return runChecks(test_file, loaded, index);
59-
}
60-
61-
function main(argv) {
62-
var opts = parseOptions(argv.slice(2));
55+
async function main(argv) {
56+
let opts = parseOptions(argv.slice(2));
6357
if (opts === null) {
6458
process.exit(1);
6559
}
@@ -68,22 +62,34 @@ function main(argv) {
6862
try {
6963
// This is more convenient that setting fields one by one.
7064
options.parseArguments([
71-
'--no-screenshot',
65+
"--no-screenshot",
7266
"--variable", "DOC_PATH", opts["doc_folder"],
7367
]);
7468
} catch (error) {
7569
console.error(`invalid argument: ${error}`);
7670
process.exit(1);
7771
}
7872

79-
runTest(opts["test_file"], options).then(out => {
80-
const [output, nb_failures] = out;
81-
console.log(output);
82-
process.exit(nb_failures);
83-
}).catch(err => {
84-
console.error(err);
73+
let failed = false;
74+
let files = fs.readdirSync(opts["tests_folder"]).filter(file => path.extname(file) == ".goml");
75+
76+
files.sort();
77+
for (var i = 0; i < files.length; ++i) {
78+
const testPath = path.join(opts["tests_folder"], files[i]);
79+
await runTest(testPath, options).then(out => {
80+
const [output, nb_failures] = out;
81+
console.log(output);
82+
if (nb_failures > 0) {
83+
failed = true;
84+
}
85+
}).catch(err => {
86+
console.error(err);
87+
failed = true;
88+
});
89+
}
90+
if (failed) {
8591
process.exit(1);
86-
});
92+
}
8793
}
8894

8995
main(process.argv);

0 commit comments

Comments
 (0)