Merge pull request #20768 from calixteman/rm_yargs

Remove dependency to yargs and use node:utils parseArgs
This commit is contained in:
Tim van der Meij 2026-03-01 20:19:11 +01:00 committed by GitHub
commit 5cbb8413cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 136 additions and 307 deletions

View File

@ -736,7 +736,7 @@ function runTests(testsName, { bot = false, xfaOnly = false } = {}) {
} }
if (process.argv.includes("--coverage-output")) { if (process.argv.includes("--coverage-output")) {
args.push( args.push(
"--coverage-output", "--coverageOutput",
process.argv[process.argv.indexOf("--coverage-output") + 1] process.argv[process.argv.indexOf("--coverage-output") + 1]
); );
} }

143
package-lock.json generated
View File

@ -70,8 +70,7 @@
"typescript": "^5.9.3", "typescript": "^5.9.3",
"vinyl": "^3.0.1", "vinyl": "^3.0.1",
"webpack": "^5.105.2", "webpack": "^5.105.2",
"webpack-stream": "^7.0.0", "webpack-stream": "^7.0.0"
"yargs": "^18.0.0"
}, },
"engines": { "engines": {
"node": ">=20.19.0 || >=22.13.0 || >=24" "node": ">=20.19.0 || >=22.13.0 || >=24"
@ -108,6 +107,7 @@
"integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==", "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@babel/code-frame": "^7.29.0", "@babel/code-frame": "^7.29.0",
"@babel/generator": "^7.29.0", "@babel/generator": "^7.29.0",
@ -1647,6 +1647,7 @@
"integrity": "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==", "integrity": "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@keyv/serialize": "^1.1.1" "@keyv/serialize": "^1.1.1"
} }
@ -1688,6 +1689,7 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=20.19.0" "node": ">=20.19.0"
}, },
@ -1728,6 +1730,7 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=20.19.0" "node": ">=20.19.0"
} }
@ -3097,6 +3100,7 @@
"integrity": "sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag==", "integrity": "sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@types/estree": "*", "@types/estree": "*",
"@types/json-schema": "*" "@types/json-schema": "*"
@ -3161,6 +3165,7 @@
"integrity": "sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog==", "integrity": "sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@types/linkify-it": "^5", "@types/linkify-it": "^5",
"@types/mdurl": "^2" "@types/mdurl": "^2"
@ -3587,6 +3592,7 @@
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"bin": { "bin": {
"acorn": "bin/acorn" "acorn": "bin/acorn"
}, },
@ -4242,7 +4248,8 @@
"resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.7.0.tgz", "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.7.0.tgz",
"integrity": "sha512-b3N5eTW1g7vXkw+0CXh/HazGTcO5KYuu/RCNaJbDMPI6LHDi+7qe8EmxKUVe1sUbY2KZOVZFyj62x0OEz9qyAA==", "integrity": "sha512-b3N5eTW1g7vXkw+0CXh/HazGTcO5KYuu/RCNaJbDMPI6LHDi+7qe8EmxKUVe1sUbY2KZOVZFyj62x0OEz9qyAA==",
"dev": true, "dev": true,
"license": "Apache-2.0" "license": "Apache-2.0",
"peer": true
}, },
"node_modules/bare-fs": { "node_modules/bare-fs": {
"version": "4.5.4", "version": "4.5.4",
@ -4478,6 +4485,7 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"baseline-browser-mapping": "^2.9.0", "baseline-browser-mapping": "^2.9.0",
"caniuse-lite": "^1.0.30001759", "caniuse-lite": "^1.0.30001759",
@ -5054,77 +5062,6 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/cliui": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz",
"integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==",
"dev": true,
"license": "ISC",
"dependencies": {
"string-width": "^7.2.0",
"strip-ansi": "^7.1.0",
"wrap-ansi": "^9.0.0"
},
"engines": {
"node": ">=20"
}
},
"node_modules/cliui/node_modules/ansi-styles": {
"version": "6.2.3",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz",
"integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/cliui/node_modules/emoji-regex": {
"version": "10.5.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.5.0.tgz",
"integrity": "sha512-lb49vf1Xzfx080OKA0o6l8DQQpV+6Vg95zyCJX9VB/BqKYlhG7N4wgROUUHRA+ZPUefLnteQOad7z1kT2bV7bg==",
"dev": true,
"license": "MIT"
},
"node_modules/cliui/node_modules/string-width": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
"integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"emoji-regex": "^10.3.0",
"get-east-asian-width": "^1.0.0",
"strip-ansi": "^7.1.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/cliui/node_modules/wrap-ansi": {
"version": "9.0.2",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz",
"integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^6.2.1",
"string-width": "^7.0.0",
"strip-ansi": "^7.1.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
}
},
"node_modules/clone": { "node_modules/clone": {
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
@ -5738,7 +5675,8 @@
"resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1566079.tgz", "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1566079.tgz",
"integrity": "sha512-MJfAEA1UfVhSs7fbSQOG4czavUp1ajfg6prlAN0+cmfa2zNjaIbvq8VneP7do1WAQQIvgNJWSMeP6UyI90gIlQ==", "integrity": "sha512-MJfAEA1UfVhSs7fbSQOG4czavUp1ajfg6prlAN0+cmfa2zNjaIbvq8VneP7do1WAQQIvgNJWSMeP6UyI90gIlQ==",
"dev": true, "dev": true,
"license": "BSD-3-Clause" "license": "BSD-3-Clause",
"peer": true
}, },
"node_modules/dir-glob": { "node_modules/dir-glob": {
"version": "3.0.1", "version": "3.0.1",
@ -6275,6 +6213,7 @@
"integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/eslint-utils": "^4.8.0",
"@eslint-community/regexpp": "^4.12.1", "@eslint-community/regexpp": "^4.12.1",
@ -6335,6 +6274,7 @@
"integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==", "integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"bin": { "bin": {
"eslint-config-prettier": "bin/cli.js" "eslint-config-prettier": "bin/cli.js"
}, },
@ -7729,6 +7669,7 @@
"integrity": "sha512-PErok3DZSA5WGMd6XXV3IRNO0mlB+wW3OzhFJLEec1jSERg2j1bxJ6e5Fh6N6fn3FH2T9AP4UYNb/pYlADB9sA==", "integrity": "sha512-PErok3DZSA5WGMd6XXV3IRNO0mlB+wW3OzhFJLEec1jSERg2j1bxJ6e5Fh6N6fn3FH2T9AP4UYNb/pYlADB9sA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"glob-watcher": "^6.0.0", "glob-watcher": "^6.0.0",
"gulp-cli": "^3.1.0", "gulp-cli": "^3.1.0",
@ -9810,6 +9751,7 @@
"integrity": "sha512-BuU2qnTti9YKgK5N+IeMubp14ZUKUUw7yeJbkjtosvHiP0AZ5c8IAgEMk79D0eC8F23r4Ac/q8cAIFdm2FtyoA==", "integrity": "sha512-BuU2qnTti9YKgK5N+IeMubp14ZUKUUw7yeJbkjtosvHiP0AZ5c8IAgEMk79D0eC8F23r4Ac/q8cAIFdm2FtyoA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"argparse": "^2.0.1", "argparse": "^2.0.1",
"entities": "^4.4.0", "entities": "^4.4.0",
@ -9951,6 +9893,7 @@
"integrity": "sha512-DkoXO1jz0UY+k1tj1LpxYLrN+jeGKBicbtsQYeYF8nX9QK4AGyGh4g421qsmEOGfZ02GjW1qxr1XP+8afwcTGQ==", "integrity": "sha512-DkoXO1jz0UY+k1tj1LpxYLrN+jeGKBicbtsQYeYF8nX9QK4AGyGh4g421qsmEOGfZ02GjW1qxr1XP+8afwcTGQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"chokidar": "^4.0.3", "chokidar": "^4.0.3",
"commander": "^11.1.0", "commander": "^11.1.0",
@ -11044,6 +10987,7 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"nanoid": "^3.3.11", "nanoid": "^3.3.11",
"picocolors": "^1.1.1", "picocolors": "^1.1.1",
@ -11196,6 +11140,7 @@
"integrity": "sha512-orRsuYpJVw8LdAwqqLykBj9ecS5/cRHlI5+nvTo8LcCKmzDmqVORXtOIYEEQuL9D4BxtA1lm5isAqzQZCoQ6Eg==", "integrity": "sha512-orRsuYpJVw8LdAwqqLykBj9ecS5/cRHlI5+nvTo8LcCKmzDmqVORXtOIYEEQuL9D4BxtA1lm5isAqzQZCoQ6Eg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"cssesc": "^3.0.0", "cssesc": "^3.0.0",
"util-deprecate": "^1.0.2" "util-deprecate": "^1.0.2"
@ -11248,6 +11193,7 @@
"integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==", "integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"bin": { "bin": {
"prettier": "bin/prettier.cjs" "prettier": "bin/prettier.cjs"
}, },
@ -12124,6 +12070,7 @@
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"fast-deep-equal": "^3.1.3", "fast-deep-equal": "^3.1.3",
"fast-uri": "^3.0.1", "fast-uri": "^3.0.1",
@ -13889,6 +13836,7 @@
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=12" "node": ">=12"
}, },
@ -14142,6 +14090,7 @@
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"dev": true, "dev": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"peer": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"
@ -14528,6 +14477,7 @@
"integrity": "sha512-dRXm0a2qcHPUBEzVk8uph0xWSjV/xZxenQQbLwnwP7caQCYpqG1qddwlyEkIDkYn0K8tvmcrZ+bOrzoQ3HxCDw==", "integrity": "sha512-dRXm0a2qcHPUBEzVk8uph0xWSjV/xZxenQQbLwnwP7caQCYpqG1qddwlyEkIDkYn0K8tvmcrZ+bOrzoQ3HxCDw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@types/eslint-scope": "^3.7.7", "@types/eslint-scope": "^3.7.7",
"@types/estree": "^1.0.8", "@types/estree": "^1.0.8",
@ -15139,24 +15089,6 @@
"node": ">= 14.6" "node": ">= 14.6"
} }
}, },
"node_modules/yargs": {
"version": "18.0.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-18.0.0.tgz",
"integrity": "sha512-4UEqdc2RYGHZc7Doyqkrqiln3p9X2DZVxaGbwhn2pi7MrRagKaOcIKe8L3OxYcbhXLgLFUS3zAYuQjKBQgmuNg==",
"dev": true,
"license": "MIT",
"dependencies": {
"cliui": "^9.0.1",
"escalade": "^3.1.1",
"get-caller-file": "^2.0.5",
"string-width": "^7.2.0",
"y18n": "^5.0.5",
"yargs-parser": "^22.0.0"
},
"engines": {
"node": "^20.19.0 || ^22.12.0 || >=23"
}
},
"node_modules/yargs-parser": { "node_modules/yargs-parser": {
"version": "22.0.0", "version": "22.0.0",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz",
@ -15167,31 +15099,6 @@
"node": "^20.19.0 || ^22.12.0 || >=23" "node": "^20.19.0 || ^22.12.0 || >=23"
} }
}, },
"node_modules/yargs/node_modules/emoji-regex": {
"version": "10.5.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.5.0.tgz",
"integrity": "sha512-lb49vf1Xzfx080OKA0o6l8DQQpV+6Vg95zyCJX9VB/BqKYlhG7N4wgROUUHRA+ZPUefLnteQOad7z1kT2bV7bg==",
"dev": true,
"license": "MIT"
},
"node_modules/yargs/node_modules/string-width": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
"integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"emoji-regex": "^10.3.0",
"get-east-asian-width": "^1.0.0",
"strip-ansi": "^7.1.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/yauzl": { "node_modules/yauzl": {
"version": "2.10.0", "version": "2.10.0",
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz",

View File

@ -65,8 +65,7 @@
"typescript": "^5.9.3", "typescript": "^5.9.3",
"vinyl": "^3.0.1", "vinyl": "^3.0.1",
"webpack": "^5.105.2", "webpack": "^5.105.2",
"webpack-stream": "^7.0.0", "webpack-stream": "^7.0.0"
"yargs": "^18.0.0"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -2,6 +2,7 @@
import { createRequire } from "module"; import { createRequire } from "module";
import fs from "fs"; import fs from "fs";
import { parseArgs } from "node:util";
const require = createRequire(import.meta.url); const require = createRequire(import.meta.url);
const ttest = require("ttest"); const ttest = require("ttest");
@ -9,26 +10,28 @@ const ttest = require("ttest");
const VALID_GROUP_BYS = ["browser", "pdf", "page", "round", "stat"]; const VALID_GROUP_BYS = ["browser", "pdf", "page", "round", "stat"];
function parseOptions() { function parseOptions() {
const yargs = require("yargs") const { values, positionals } = parseArgs({
.usage( args: process.argv.slice(2),
allowPositionals: true,
options: {
groupBy: { type: "string", default: "browser,stat" },
},
});
if (positionals.length < 2) {
console.error(
"Compare the results of two stats files.\n" + "Compare the results of two stats files.\n" +
"Usage:\n $0 <BASELINE> <CURRENT> [options]" "Usage:\n statcmp.js <BASELINE> <CURRENT> [--groupBy=<fields>]\n\n" +
) ` --groupBy How statistics should be grouped. Valid options: ${VALID_GROUP_BYS.join(" ")}. [browser,stat]`
.demand(2) );
.string(["groupBy"]) process.exit(1);
.describe(
"groupBy",
"How statistics should grouped. Valid options: " +
VALID_GROUP_BYS.join(" ")
)
.default("groupBy", "browser,stat");
const result = yargs.argv;
result.baseline = result._[0];
result.current = result._[1];
if (result.groupBy) {
result.groupBy = result.groupBy.split(/[;, ]+/);
} }
return result;
return {
baseline: positionals[0],
current: positionals[1],
groupBy: values.groupBy.split(/[;, ]+/),
};
} }
function group(stats, groupBy) { function group(stats, groupBy) {

View File

@ -25,184 +25,104 @@ import istanbulCoverage from "istanbul-lib-coverage";
import istanbulReportGenerator from "istanbul-reports"; import istanbulReportGenerator from "istanbul-reports";
import libReport from "istanbul-lib-report"; import libReport from "istanbul-lib-report";
import os from "os"; import os from "os";
import { parseArgs } from "node:util";
import path from "path"; import path from "path";
import puppeteer from "puppeteer"; import puppeteer from "puppeteer";
import readline from "readline"; import readline from "readline";
import { translateFont } from "./font/ttxdriver.mjs"; import { translateFont } from "./font/ttxdriver.mjs";
import { WebServer } from "./webserver.mjs"; import { WebServer } from "./webserver.mjs";
import yargs from "yargs";
const __dirname = import.meta.dirname; const __dirname = import.meta.dirname;
function parseOptions() { function parseOptions() {
const parsedArgs = yargs(process.argv) const { values } = parseArgs({
.usage("Usage: $0") args: process.argv.slice(2),
.option("downloadOnly", { options: {
default: false, coverage: { type: "boolean", default: false },
describe: "Download test PDFs without running the tests.", coverageOutput: { type: "string", default: "build/coverage" },
type: "boolean", downloadOnly: { type: "boolean", default: false },
}) fontTest: { type: "boolean", default: false },
.option("fontTest", { headless: { type: "boolean", default: false },
default: false, help: { type: "boolean", short: "h", default: false },
describe: "Run the font tests.", integration: { type: "boolean", default: false },
type: "boolean", manifestFile: { type: "string", default: "test_manifest.json" },
}) masterMode: { type: "boolean", short: "m", default: false },
.option("help", { noChrome: { type: "boolean", default: false },
alias: "h", noDownload: { type: "boolean", default: false },
default: false, noFirefox: { type: "boolean", default: false },
describe: "Show this help message.", noPrompts: { type: "boolean", default: false },
type: "boolean", port: { type: "string", default: "0" },
}) reftest: { type: "boolean", default: false },
.option("integration", { statsDelay: { type: "string", default: "0" },
default: false, statsFile: { type: "string", default: "" },
describe: "Run the integration tests.", strictVerify: { type: "boolean", default: false },
type: "boolean", testfilter: { type: "string", short: "t", multiple: true, default: [] },
}) unitTest: { type: "boolean", default: false },
.option("manifestFile", { xfaOnly: { type: "boolean", default: false },
default: "test_manifest.json", },
describe: "A path to JSON file in the form of `test_manifest.json`.", });
type: "string",
}) if (values.help) {
.option("masterMode", { console.log(
alias: "m", "Usage: test.mjs\n\n" +
default: false, " --coverage Enable code coverage collection.\n" +
describe: "Run the script in master mode.", " --coverageOutput Directory for code coverage data. [build/coverage]\n" +
type: "boolean", " --downloadOnly Download test PDFs without running the tests.\n" +
}) " --fontTest Run the font tests.\n" +
.option("noChrome", { " --headless Run tests without visible browser windows.\n" +
default: false, " --help, -h Show this help message.\n" +
describe: "Skip Chrome when running tests.", " --integration Run the integration tests.\n" +
type: "boolean", " --manifestFile Path to manifest JSON file. [test_manifest.json]\n" +
}) " --masterMode, -m Run the script in master mode.\n" +
.option("noFirefox", { " --noChrome Skip Chrome when running tests.\n" +
default: false, " --noDownload Skip downloading of test PDFs.\n" +
describe: "Skip Firefox when running tests.", " --noFirefox Skip Firefox when running tests.\n" +
type: "boolean", " --noPrompts Use default answers (for CLOUD TESTS only!).\n" +
}) " --port Port for the HTTP server. [0]\n" +
.option("noDownload", { " --reftest Start reftest viewer on comparison failures.\n" +
default: false, " --statsDelay Milliseconds to wait before starting stats. [0]\n" +
describe: "Skip downloading of test PDFs.", " --statsFile File where to store stats.\n" +
type: "boolean", " --strictVerify Error if manifest file verification fails.\n" +
}) " --testfilter, -t Run specific reftest(s), e.g. -t=issue5567.\n" +
.option("noPrompts", { " --unitTest Run the unit tests.\n" +
default: false, " --xfaOnly Only run the XFA reftest(s)."
describe: "Uses default answers (intended for CLOUD TESTS only!).", );
type: "boolean", process.exit(0);
}) }
.option("headless", {
default: false,
describe:
"Run the tests in headless mode, i.e. without visible browser windows.",
type: "boolean",
})
.option("port", {
default: 0,
describe: "The port the HTTP server should listen on.",
type: "number",
})
.option("reftest", {
default: false,
describe:
"Automatically start reftest showing comparison test failures, if there are any.",
type: "boolean",
})
.option("statsDelay", {
default: 0,
describe:
"The amount of time in milliseconds the browser should wait before starting stats.",
type: "number",
})
.option("statsFile", {
default: "",
describe: "The file where to store stats.",
type: "string",
})
.option("strictVerify", {
default: false,
describe: "Error if verifying the manifest files fails.",
type: "boolean",
})
.option("coverage", {
default: false,
describe: "Enable code coverage collection.",
type: "boolean",
})
.option("coverageOutput", {
default: "build/coverage",
describe: "The directory where to store code coverage data.",
type: "string",
})
.option("testfilter", {
alias: "t",
default: [],
describe: "Run specific reftest(s).",
type: "array",
})
.example(
"testfilter",
"$0 -t=issue5567 -t=issue5909\n" +
"Run the reftest identified by issue5567 and issue5909."
)
.option("unitTest", {
default: false,
describe: "Run the unit tests.",
type: "boolean",
})
.option("xfaOnly", {
default: false,
describe: "Only run the XFA reftest(s).",
type: "boolean",
})
.check(argv => {
if ( if (
+argv.reftest + argv.unitTest + argv.fontTest + argv.masterMode <= +values.reftest + values.unitTest + values.fontTest + values.masterMode >
1 1
) { ) {
return true;
}
throw new Error( throw new Error(
"--reftest, --unitTest, --fontTest, and --masterMode must not be specified together." "--reftest, --unitTest, --fontTest, and --masterMode must not be specified together."
); );
}) }
.check(argv => {
if ( if (
+argv.unitTest + argv.fontTest + argv.integration + argv.xfaOnly <= +values.unitTest + values.fontTest + values.integration + values.xfaOnly >
1 1
) { ) {
return true;
}
throw new Error( throw new Error(
"--unitTest, --fontTest, --integration, and --xfaOnly must not be specified together." "--unitTest, --fontTest, --integration, and --xfaOnly must not be specified together."
); );
}) }
.check(argv => { if (values.testfilter.length > 0 && values.xfaOnly) {
if (argv.testfilter?.length > 0 && argv.xfaOnly) {
throw new Error("--testfilter and --xfaOnly cannot be used together."); throw new Error("--testfilter and --xfaOnly cannot be used together.");
} }
return true; if (values.noDownload && values.downloadOnly) {
}) throw new Error("--noDownload and --downloadOnly cannot be used together.");
.check(argv => {
if (!argv.noDownload || !argv.downloadOnly) {
return true;
}
throw new Error(
"--noDownload and --downloadOnly cannot be used together."
);
})
.check(argv => {
if (!argv.masterMode || argv.manifestFile === "test_manifest.json") {
return true;
} }
if (values.masterMode && values.manifestFile !== "test_manifest.json") {
throw new Error( throw new Error(
"when --masterMode is specified --manifestFile shall be equal to `test_manifest.json`." "when --masterMode is specified --manifestFile shall be equal to `test_manifest.json`."
); );
}); }
const result = parsedArgs.argv; return {
result.testfilter = Array.isArray(result.testfilter) ...values,
? result.testfilter port: parseInt(values.port, 10) || 0,
: [result.testfilter]; statsDelay: parseInt(values.statsDelay, 10) || 0,
return result; };
} }
var refsTmpDir = "tmp"; var refsTmpDir = "tmp";