Skip to content

Commit

Permalink
Rollup merge of #131230 - GuillaumeGomez:no-sandbox, r=notriddle
Browse files Browse the repository at this point in the history
Enable `--no-sandbox` option by default for rustdoc GUI tests

It's apparently common enough for people to have issues with the `sandbox` mode in chromium, so better disable it by default.

r? `@notriddle`
  • Loading branch information
GuillaumeGomez authored Oct 4, 2024
2 parents ba94a2a + 32099db commit 11b1b4f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ RUN /scripts/build-gccjit.sh /scripts
# the local version of the package is different than the one used by the CI.
ENV SCRIPT /tmp/checktools.sh ../x.py && \
npm install browser-ui-test@$(head -n 1 /tmp/browser-ui-test.version) --unsafe-perm=true && \
python3 ../x.py test tests/rustdoc-gui --stage 2 --test-args "'--no-sandbox --jobs 1'"
python3 ../x.py test tests/rustdoc-gui --stage 2 --test-args "'--jobs 1'"
26 changes: 1 addition & 25 deletions src/tools/rustdoc-gui/tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function showHelp() {
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(" --no-sandbox : disable sandbox mode");
console.log(" --help : show this message then quit");
console.log(" --tests-folder [PATH] : location of the .GOML tests folder");
console.log(" --jobs [NUMBER] : number of threads to run tests on");
Expand All @@ -40,7 +39,6 @@ function parseOptions(args) {
"no_headless": false,
"jobs": -1,
"executable_path": null,
"no_sandbox": false,
};
const correspondences = {
"--doc-folder": "doc_folder",
Expand All @@ -49,7 +47,6 @@ function parseOptions(args) {
"--show-text": "show_text",
"--no-headless": "no_headless",
"--executable-path": "executable_path",
"--no-sandbox": "no_sandbox",
};

for (let i = 0; i < args.length; ++i) {
Expand Down Expand Up @@ -80,9 +77,6 @@ function parseOptions(args) {
} else if (arg === "--help") {
showHelp();
process.exit(0);
} else if (arg === "--no-sandbox") {
console.log("`--no-sandbox` is being used. Be very careful!");
opts[correspondences[arg]] = true;
} else if (correspondences[arg]) {
opts[correspondences[arg]] = true;
} else {
Expand Down Expand Up @@ -203,6 +197,7 @@ async function main(argv) {
const args = [
"--variable", "DOC_PATH", opts["doc_folder"].split("\\").join("/"),
"--enable-fail-on-js-error", "--allow-file-access-from-files",
"--no-sandbox",
];
if (opts["debug"]) {
debug = true;
Expand All @@ -211,9 +206,6 @@ async function main(argv) {
if (opts["show_text"]) {
args.push("--show-text");
}
if (opts["no_sandbox"]) {
args.push("--no-sandbox");
}
if (opts["no_headless"]) {
args.push("--no-headless");
headless = false;
Expand Down Expand Up @@ -262,19 +254,6 @@ async function main(argv) {
console.log(`Running ${files.length} rustdoc-gui ...`);
}

// We catch this "event" to display a nicer message in case of unexpected exit (because of a
// missing `--no-sandbox`).
const exitHandling = () => {
if (!opts["no_sandbox"]) {
console.log("");
console.log(
"`browser-ui-test` crashed unexpectedly. Please try again with adding `--test-args \
--no-sandbox` at the end. For example: `x.py test tests/rustdoc-gui --test-args --no-sandbox`");
console.log("");
}
};
process.on("exit", exitHandling);

const originalFilesLen = files.length;
const results = createEmptyResults();
const status_bar = char_printer(files.length);
Expand All @@ -299,9 +278,6 @@ async function main(argv) {
Array.prototype.push.apply(results.failed, new_results.failed);
Array.prototype.push.apply(results.errored, new_results.errored);

// We don't need this listener anymore.
process.removeListener("exit", exitHandling);

if (debug) {
results.successful.sort(by_filename);
results.successful.forEach(r => {
Expand Down
7 changes: 0 additions & 7 deletions tests/rustdoc-gui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,5 @@ $ ./x.py test tests/rustdoc-gui --stage 1 --test-args --no-headless

To see the supported options, use `--help`.

Important to be noted: if the chromium instance crashes when you run it, you might need to
use `--no-sandbox` to make it work:

```bash
$ ./x.py test tests/rustdoc-gui --stage 1 --test-args --no-sandbox
```

[browser-ui-test]: https://github.com/GuillaumeGomez/browser-UI-test/
[puppeteer]: https://pptr.dev/

0 comments on commit 11b1b4f

Please sign in to comment.