Skip to content

Commit 7dca2e2

Browse files
authored
Rollup merge of #86297 - GuillaumeGomez:rustdoc-gui-args, r=Mark-Simulacrum
Allow to pass arguments to rustdoc-gui tool Very convenient for testing. This is another part of #86293 cc ``@jsha`` r? ``@Mark-Simulacrum``
2 parents 7ee6b8b + 95c1bf6 commit 7dca2e2

File tree

4 files changed

+39
-10
lines changed

4 files changed

+39
-10
lines changed

src/bootstrap/test.rs

+3
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,9 @@ impl Step for RustdocGUI {
894894
}
895895
}
896896
}
897+
for test_arg in builder.config.cmd.test_args() {
898+
command.arg(test_arg);
899+
}
897900
builder.run(&mut command);
898901
}
899902
}

src/test/rustdoc-gui/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,17 @@ test what's being currently displayed in the web page.
88

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

11+
If you need to have more information on the tests run, you can use `--test-args`:
12+
13+
```bash
14+
$ ./x.py test src/test/rustdoc-gui --stage 1 --jobs 8 --test-args --debug
15+
```
16+
17+
There are three options supported:
18+
19+
* `--debug`: allows to see puppeteer commands.
20+
* `--no-headless`: disable headless mode so you can see what's going on.
21+
* `--show-text`: by default, text isn't rendered because of issues with fonts, it enables it back.
22+
1123
[browser-ui-test]: https://github.com/GuillaumeGomez/browser-UI-test/
1224
[puppeteer]: https://pptr.dev/

src/tools/rust-analyzer

src/tools/rustdoc-gui/tester.js

+23-9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ function showHelp() {
1111
console.log("rustdoc-js options:");
1212
console.log(" --doc-folder [PATH] : location of the generated doc folder");
1313
console.log(" --file [PATH] : file to run (can be repeated)");
14+
console.log(" --debug : show extra information about script run");
15+
console.log(" --show-text : render font in pages");
16+
console.log(" --no-headless : disable headless mode");
1417
console.log(" --help : show this message then quit");
1518
console.log(" --tests-folder [PATH] : location of the .GOML tests folder");
1619
}
@@ -20,10 +23,16 @@ function parseOptions(args) {
2023
"doc_folder": "",
2124
"tests_folder": "",
2225
"files": [],
26+
"debug": false,
27+
"show_text": false,
28+
"no_headless": false,
2329
};
2430
var correspondances = {
2531
"--doc-folder": "doc_folder",
2632
"--tests-folder": "tests_folder",
33+
"--debug": "debug",
34+
"--show-text": "show_text",
35+
"--no-headless": "no_headless",
2736
};
2837

2938
for (var i = 0; i < args.length; ++i) {
@@ -43,6 +52,8 @@ function parseOptions(args) {
4352
} else if (args[i] === "--help") {
4453
showHelp();
4554
process.exit(0);
55+
} else if (correspondances[args[i]]) {
56+
opts[correspondances[args[i]]] = true;
4657
} else {
4758
console.log("Unknown option `" + args[i] + "`.");
4859
console.log("Use `--help` to see the list of options");
@@ -68,17 +79,20 @@ async function main(argv) {
6879
const options = new Options();
6980
try {
7081
// This is more convenient that setting fields one by one.
71-
options.parseArguments([
82+
let args = [
7283
"--no-screenshot",
73-
// This option shows what puppeteer "code" is run
74-
// "--debug",
75-
// This option disable the headless mode, allowing you to see what's going on.
76-
// "--no-headless",
77-
// The text isn't rendered by default because of a lot of small differences
78-
// between hosts.
79-
// "--show-text",
8084
"--variable", "DOC_PATH", opts["doc_folder"],
81-
]);
85+
];
86+
if (opts["debug"]) {
87+
args.push("--debug");
88+
}
89+
if (opts["show_text"]) {
90+
args.push("--show-text");
91+
}
92+
if (opts["no_headless"]) {
93+
args.push("--no-headless");
94+
}
95+
options.parseArguments(args);
8296
} catch (error) {
8397
console.error(`invalid argument: ${error}`);
8498
process.exit(1);

0 commit comments

Comments
 (0)