Skip to content

Commit

Permalink
Allow to pass arguments to rustdoc-gui tool
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jun 16, 2021
1 parent 52b2286 commit 95c1bf6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,9 @@ impl Step for RustdocGUI {
}
}
}
for test_arg in builder.config.cmd.test_args() {
command.arg(test_arg);
}
builder.run(&mut command);
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/test/rustdoc-gui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,17 @@ test what's being currently displayed in the web page.

You can find more information and its documentation in its [repository][browser-ui-test].

If you need to have more information on the tests run, you can use `--test-args`:

```bash
$ ./x.py test src/test/rustdoc-gui --stage 1 --jobs 8 --test-args --debug
```

There are three options supported:

* `--debug`: allows to see puppeteer commands.
* `--no-headless`: disable headless mode so you can see what's going on.
* `--show-text`: by default, text isn't rendered because of issues with fonts, it enables it back.

[browser-ui-test]: https://github.com/GuillaumeGomez/browser-UI-test/
[puppeteer]: https://pptr.dev/
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer
32 changes: 23 additions & 9 deletions src/tools/rustdoc-gui/tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ 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(" --debug : show extra information about script run");
console.log(" --show-text : render font in pages");
console.log(" --no-headless : disable headless mode");
console.log(" --help : show this message then quit");
console.log(" --tests-folder [PATH] : location of the .GOML tests folder");
}
Expand All @@ -20,10 +23,16 @@ function parseOptions(args) {
"doc_folder": "",
"tests_folder": "",
"files": [],
"debug": false,
"show_text": false,
"no_headless": false,
};
var correspondances = {
"--doc-folder": "doc_folder",
"--tests-folder": "tests_folder",
"--debug": "debug",
"--show-text": "show_text",
"--no-headless": "no_headless",
};

for (var i = 0; i < args.length; ++i) {
Expand All @@ -43,6 +52,8 @@ function parseOptions(args) {
} else if (args[i] === "--help") {
showHelp();
process.exit(0);
} else if (correspondances[args[i]]) {
opts[correspondances[args[i]]] = true;
} else {
console.log("Unknown option `" + args[i] + "`.");
console.log("Use `--help` to see the list of options");
Expand All @@ -68,17 +79,20 @@ async function main(argv) {
const options = new Options();
try {
// This is more convenient that setting fields one by one.
options.parseArguments([
let args = [
"--no-screenshot",
// This option shows what puppeteer "code" is run
// "--debug",
// This option disable the headless mode, allowing you to see what's going on.
// "--no-headless",
// The text isn't rendered by default because of a lot of small differences
// between hosts.
// "--show-text",
"--variable", "DOC_PATH", opts["doc_folder"],
]);
];
if (opts["debug"]) {
args.push("--debug");
}
if (opts["show_text"]) {
args.push("--show-text");
}
if (opts["no_headless"]) {
args.push("--no-headless");
}
options.parseArguments(args);
} catch (error) {
console.error(`invalid argument: ${error}`);
process.exit(1);
Expand Down

0 comments on commit 95c1bf6

Please sign in to comment.