1 // This package needs to be install:
4 // npm install browser-ui-test
6 const fs = require("fs");
7 const path = require("path");
8 const {Options, runTest} = require('browser-ui-test');
11 console.log("rustdoc-js options:");
12 console.log(" --doc-folder [PATH] : location of the generated doc folder");
13 console.log(" --help : show this message then quit");
14 console.log(" --tests-folder [PATH] : location of the .GOML tests folder");
17 function parseOptions(args) {
22 var correspondances = {
23 "--doc-folder": "doc_folder",
24 "--tests-folder": "tests_folder",
27 for (var i = 0; i < args.length; ++i) {
28 if (args[i] === "--doc-folder"
29 || args[i] === "--tests-folder") {
31 if (i >= args.length) {
32 console.log("Missing argument after `" + args[i - 1] + "` option.");
35 opts[correspondances[args[i - 1]]] = args[i];
36 } else if (args[i] === "--help") {
40 console.log("Unknown option `" + args[i] + "`.");
41 console.log("Use `--help` to see the list of options");
45 if (opts["tests_folder"].length < 1) {
46 console.log("Missing `--tests-folder` option.");
47 } else if (opts["doc_folder"].length < 1) {
48 console.log("Missing `--doc-folder` option.");
55 async function main(argv) {
56 let opts = parseOptions(argv.slice(2));
61 const options = new Options();
63 // This is more convenient that setting fields one by one.
64 options.parseArguments([
66 "--variable", "DOC_PATH", opts["doc_folder"],
69 console.error(`invalid argument: ${error}`);
74 let files = fs.readdirSync(opts["tests_folder"]).filter(file => path.extname(file) == ".goml");
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;
82 if (nb_failures > 0) {