summaryrefslogtreecommitdiffstats
path: root/src/tools/rustdoc-gui
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
commit631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch)
treea1b87c8f8cad01cf18f7c5f57a08f102771ed303 /src/tools/rustdoc-gui
parentAdding debian version 1.69.0+dfsg1-1. (diff)
downloadrustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz
rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/rustdoc-gui')
-rw-r--r--src/tools/rustdoc-gui/.eslintrc.js96
-rw-r--r--src/tools/rustdoc-gui/tester.js64
2 files changed, 129 insertions, 31 deletions
diff --git a/src/tools/rustdoc-gui/.eslintrc.js b/src/tools/rustdoc-gui/.eslintrc.js
new file mode 100644
index 000000000..f4aadc071
--- /dev/null
+++ b/src/tools/rustdoc-gui/.eslintrc.js
@@ -0,0 +1,96 @@
+module.exports = {
+ "env": {
+ "browser": true,
+ "node": true,
+ "es6": true
+ },
+ "extends": "eslint:recommended",
+ "parserOptions": {
+ "ecmaVersion": 2018,
+ "sourceType": "module"
+ },
+ "rules": {
+ "linebreak-style": [
+ "error",
+ "unix"
+ ],
+ "semi": [
+ "error",
+ "always"
+ ],
+ "quotes": [
+ "error",
+ "double"
+ ],
+ "linebreak-style": [
+ "error",
+ "unix"
+ ],
+ "no-trailing-spaces": "error",
+ "no-var": ["error"],
+ "prefer-const": ["error"],
+ "prefer-arrow-callback": ["error"],
+ "brace-style": [
+ "error",
+ "1tbs",
+ { "allowSingleLine": false }
+ ],
+ "keyword-spacing": [
+ "error",
+ { "before": true, "after": true }
+ ],
+ "arrow-spacing": [
+ "error",
+ { "before": true, "after": true }
+ ],
+ "key-spacing": [
+ "error",
+ { "beforeColon": false, "afterColon": true, "mode": "strict" }
+ ],
+ "func-call-spacing": ["error", "never"],
+ "space-infix-ops": "error",
+ "space-before-function-paren": ["error", "never"],
+ "space-before-blocks": "error",
+ "comma-dangle": ["error", "always-multiline"],
+ "comma-style": ["error", "last"],
+ "max-len": ["error", { "code": 100, "tabWidth": 4 }],
+ "eol-last": ["error", "always"],
+ "arrow-parens": ["error", "as-needed"],
+ "no-unused-vars": [
+ "error",
+ {
+ "argsIgnorePattern": "^_",
+ "varsIgnorePattern": "^_"
+ }
+ ],
+ "eqeqeq": "error",
+ "no-const-assign": "error",
+ "no-debugger": "error",
+ "no-dupe-args": "error",
+ "no-dupe-else-if": "error",
+ "no-dupe-keys": "error",
+ "no-duplicate-case": "error",
+ "no-ex-assign": "error",
+ "no-fallthrough": "error",
+ "no-invalid-regexp": "error",
+ "no-import-assign": "error",
+ "no-self-compare": "error",
+ "no-template-curly-in-string": "error",
+ "block-scoped-var": "error",
+ "guard-for-in": "error",
+ "no-alert": "error",
+ "no-confusing-arrow": "error",
+ "no-div-regex": "error",
+ "no-floating-decimal": "error",
+ "no-implicit-globals": "error",
+ "no-implied-eval": "error",
+ "no-label-var": "error",
+ "no-lonely-if": "error",
+ "no-mixed-operators": "error",
+ "no-multi-assign": "error",
+ "no-return-assign": "error",
+ "no-script-url": "error",
+ "no-sequences": "error",
+ "no-div-regex": "error",
+ }
+};
diff --git a/src/tools/rustdoc-gui/tester.js b/src/tools/rustdoc-gui/tester.js
index 2f0ca1ec3..72baad606 100644
--- a/src/tools/rustdoc-gui/tester.js
+++ b/src/tools/rustdoc-gui/tester.js
@@ -6,8 +6,8 @@
const fs = require("fs");
const path = require("path");
-const os = require('os');
-const {Options, runTest} = require('browser-ui-test');
+const os = require("os");
+const {Options, runTest} = require("browser-ui-test");
// If a test fails or errors, we will retry it two more times in case it was a flaky failure.
const NB_RETRY = 3;
@@ -31,7 +31,7 @@ function isNumeric(s) {
}
function parseOptions(args) {
- var opts = {
+ const opts = {
"doc_folder": "",
"tests_folder": "",
"files": [],
@@ -42,7 +42,7 @@ function parseOptions(args) {
"executable_path": null,
"no_sandbox": false,
};
- var correspondances = {
+ const correspondances = {
"--doc-folder": "doc_folder",
"--tests-folder": "tests_folder",
"--debug": "debug",
@@ -52,39 +52,41 @@ function parseOptions(args) {
"--no-sandbox": "no_sandbox",
};
- for (var i = 0; i < args.length; ++i) {
- if (args[i] === "--doc-folder"
- || args[i] === "--tests-folder"
- || args[i] === "--file"
- || args[i] === "--jobs"
- || args[i] === "--executable-path") {
+ for (let i = 0; i < args.length; ++i) {
+ const arg = args[i];
+ if (arg === "--doc-folder"
+ || arg === "--tests-folder"
+ || arg === "--file"
+ || arg === "--jobs"
+ || arg === "--executable-path") {
i += 1;
if (i >= args.length) {
- console.log("Missing argument after `" + args[i - 1] + "` option.");
+ console.log("Missing argument after `" + arg + "` option.");
return null;
}
- if (args[i - 1] === "--jobs") {
- if (!isNumeric(args[i])) {
+ const arg_value = args[i];
+ if (arg === "--jobs") {
+ if (!isNumeric(arg_value)) {
console.log(
- "`--jobs` option expects a positive number, found `" + args[i] + "`");
+ "`--jobs` option expects a positive number, found `" + arg_value + "`");
return null;
}
- opts["jobs"] = parseInt(args[i]);
- } else if (args[i - 1] !== "--file") {
- opts[correspondances[args[i - 1]]] = args[i];
+ opts["jobs"] = parseInt(arg_value);
+ } else if (arg !== "--file") {
+ opts[correspondances[arg]] = arg_value;
} else {
- opts["files"].push(args[i]);
+ opts["files"].push(arg_value);
}
- } else if (args[i] === "--help") {
+ } else if (arg === "--help") {
showHelp();
process.exit(0);
- } else if (args[i] === "--no-sandbox") {
+ } else if (arg === "--no-sandbox") {
console.log("`--no-sandbox` is being used. Be very careful!");
- opts[correspondances[args[i]]] = true;
- } else if (correspondances[args[i]]) {
- opts[correspondances[args[i]]] = true;
+ opts[correspondances[arg]] = true;
+ } else if (correspondances[arg]) {
+ opts[correspondances[arg]] = true;
} else {
- console.log("Unknown option `" + args[i] + "`.");
+ console.log("Unknown option `" + arg + "`.");
console.log("Use `--help` to see the list of options");
return null;
}
@@ -186,7 +188,7 @@ function createEmptyResults() {
}
async function main(argv) {
- let opts = parseOptions(argv.slice(2));
+ const opts = parseOptions(argv.slice(2));
if (opts === null) {
process.exit(1);
}
@@ -198,7 +200,7 @@ async function main(argv) {
const framework_options = new Options();
try {
// This is more convenient that setting fields one by one.
- let args = [
+ const args = [
"--variable", "DOC_PATH", opts["doc_folder"], "--enable-fail-on-js-error",
"--allow-file-access-from-files",
];
@@ -232,7 +234,7 @@ async function main(argv) {
} else {
files = opts["files"];
}
- files = files.filter(file => path.extname(file) == ".goml");
+ files = files.filter(file => path.extname(file) === ".goml");
if (files.length === 0) {
console.error("rustdoc-gui: No test selected");
process.exit(2);
@@ -257,7 +259,7 @@ async function main(argv) {
// We catch this "event" to display a nicer message in case of unexpected exit (because of a
// missing `--no-sandbox`).
- const exitHandling = (code) => {
+ const exitHandling = () => {
if (!opts["no_sandbox"]) {
console.log("");
console.log(
@@ -266,10 +268,10 @@ async function main(argv) {
console.log("");
}
};
- process.on('exit', exitHandling);
+ process.on("exit", exitHandling);
const originalFilesLen = files.length;
- let results = createEmptyResults();
+ const results = createEmptyResults();
const status_bar = char_printer(files.length);
let new_results;
@@ -279,7 +281,7 @@ async function main(argv) {
Array.prototype.push.apply(results.successful, new_results.successful);
// We generate the new list of files with the previously failing tests.
files = Array.prototype.concat(new_results.failed, new_results.errored).map(
- f => f['file_name']);
+ f => f["file_name"]);
if (files.length > originalFilesLen / 2) {
// If we have too many failing tests, it's very likely not flaky failures anymore so
// no need to retry.