]>
git.proxmox.com Git - rustc.git/blob - src/tools/rustdoc-gui/tester.js
1 // This package needs to be install:
4 // npm install browser-ui-test
6 const path
= require('path');
7 const {Options
, runTest
} = require('browser-ui-test');
10 console
.log("rustdoc-js options:");
11 console
.log(" --doc-folder [PATH] : location of the generated doc folder");
12 console
.log(" --help : show this message then quit");
13 console
.log(" --test-file [PATH] : location of the JS test file");
16 function parseOptions(args
) {
21 var correspondances
= {
22 "--doc-folder": "doc_folder",
23 "--test-file": "test_file",
26 for (var i
= 0; i
< args
.length
; ++i
) {
27 if (args
[i
] === "--doc-folder"
28 || args
[i
] === "--test-file") {
30 if (i
>= args
.length
) {
31 console
.log("Missing argument after `" + args
[i
- 1] + "` option.");
34 opts
[correspondances
[args
[i
- 1]]] = args
[i
];
35 } else if (args
[i
] === "--help") {
39 console
.log("Unknown option `" + args
[i
] + "`.");
40 console
.log("Use `--help` to see the list of options");
44 if (opts
["test_file"].length
< 1) {
45 console
.log("Missing `--test-file` option.");
46 } else if (opts
["doc_folder"].length
< 1) {
47 console
.log("Missing `--doc-folder` option.");
54 function checkFile(test_file
, opts
, loaded
, index
) {
55 const test_name
= path
.basename(test_file
, ".js");
57 process
.stdout
.write('Checking "' + test_name
+ '" ... ');
58 return runChecks(test_file
, loaded
, index
);
62 var opts
= parseOptions(argv
.slice(2));
67 const options
= new Options();
69 // This is more convenient that setting fields one by one.
70 options
.parseArguments([
72 "--variable", "DOC_PATH", opts
["doc_folder"],
75 console
.error(`invalid argument: ${error}`);
79 runTest(opts
["test_file"], options
).then(out
=> {
80 const [output
, nb_failures
] = out
;
82 process
.exit(nb_failures
);