mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Merge pull request #13247 from Snuffleupagus/update-yargs
Update the `yargs` package to the latest version
This commit is contained in:
commit
6e8ff2fed9
3 changed files with 183 additions and 269 deletions
193
test/test.js
193
test/test.js
|
@ -24,90 +24,125 @@ var os = require("os");
|
|||
var puppeteer = require("puppeteer");
|
||||
var url = require("url");
|
||||
var testUtils = require("./testutils.js");
|
||||
const yargs = require("yargs");
|
||||
|
||||
function parseOptions() {
|
||||
function describeCheck(fn, text) {
|
||||
fn.toString = function () {
|
||||
return text;
|
||||
};
|
||||
return fn;
|
||||
}
|
||||
|
||||
var yargs = require("yargs")
|
||||
yargs
|
||||
.usage("Usage: $0")
|
||||
.boolean([
|
||||
"help",
|
||||
"masterMode",
|
||||
"reftest",
|
||||
"unitTest",
|
||||
"fontTest",
|
||||
"noPrompts",
|
||||
"noDownload",
|
||||
"noChrome",
|
||||
"downloadOnly",
|
||||
"strictVerify",
|
||||
])
|
||||
.string(["manifestFile", "port", "statsFile", "statsDelay", "testfilter"])
|
||||
.alias("help", "h")
|
||||
.alias("masterMode", "m")
|
||||
.alias("testfilter", "t")
|
||||
.describe("help", "Show this help message")
|
||||
.describe("masterMode", "Run the script in master mode.")
|
||||
.describe(
|
||||
"noPrompts",
|
||||
"Uses default answers (intended for CLOUD TESTS only!)."
|
||||
)
|
||||
.describe(
|
||||
"manifestFile",
|
||||
"A path to JSON file in the form of test_manifest.json"
|
||||
)
|
||||
.default("manifestFile", "test_manifest.json")
|
||||
.describe(
|
||||
"reftest",
|
||||
"Automatically start reftest showing comparison " +
|
||||
"test failures, if there are any."
|
||||
)
|
||||
.describe("testfilter", "Run specific reftest(s).")
|
||||
.default("testfilter", [])
|
||||
.option("downloadOnly", {
|
||||
default: false,
|
||||
describe: "Download test PDFs without running the tests.",
|
||||
type: "boolean",
|
||||
})
|
||||
.option("fontTest", {
|
||||
default: false,
|
||||
describe: "Run the font tests.",
|
||||
type: "boolean",
|
||||
})
|
||||
.option("help", {
|
||||
alias: "h",
|
||||
default: false,
|
||||
describe: "Show this help message.",
|
||||
type: "boolean",
|
||||
})
|
||||
.option("manifestFile", {
|
||||
default: "test_manifest.json",
|
||||
describe: "A path to JSON file in the form of `test_manifest.json`.",
|
||||
type: "string",
|
||||
})
|
||||
.option("masterMode", {
|
||||
alias: "m",
|
||||
default: false,
|
||||
describe: "Run the script in master mode.",
|
||||
type: "boolean",
|
||||
})
|
||||
.option("noChrome", {
|
||||
default: false,
|
||||
describe: "Skip Chrome when running tests.",
|
||||
type: "boolean",
|
||||
})
|
||||
.option("noDownload", {
|
||||
default: false,
|
||||
describe: "Skip downloading of test PDFs.",
|
||||
type: "boolean",
|
||||
})
|
||||
.option("noPrompts", {
|
||||
default: false,
|
||||
describe: "Uses default answers (intended for CLOUD TESTS only!).",
|
||||
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("testfilter", {
|
||||
alias: "t",
|
||||
default: [],
|
||||
describe: "Run specific reftest(s).",
|
||||
type: "array",
|
||||
})
|
||||
.example(
|
||||
"$0 -t=issue5567 -t=issue5909",
|
||||
"Run the reftest identified by issue5567 and issue5909."
|
||||
"testfilter",
|
||||
"$0 -t=issue5567 -t=issue5909\n" +
|
||||
"Run the reftest identified by issue5567 and issue5909."
|
||||
)
|
||||
.describe("port", "The port the HTTP server should listen on.")
|
||||
.default("port", 0)
|
||||
.describe("unitTest", "Run the unit tests.")
|
||||
.describe("fontTest", "Run the font tests.")
|
||||
.describe("noDownload", "Skips test PDFs downloading.")
|
||||
.describe("noChrome", "Skip Chrome when running tests.")
|
||||
.describe("downloadOnly", "Download test PDFs without running the tests.")
|
||||
.describe("strictVerify", "Error if verifying the manifest files fails.")
|
||||
.describe("statsFile", "The file where to store stats.")
|
||||
.describe(
|
||||
"statsDelay",
|
||||
"The amount of time in milliseconds the browser " +
|
||||
"should wait before starting stats."
|
||||
)
|
||||
.default("statsDelay", 0)
|
||||
.check(
|
||||
describeCheck(function (argv) {
|
||||
return (
|
||||
+argv.reftest + argv.unitTest + argv.fontTest + argv.masterMode <= 1
|
||||
);
|
||||
}, "--reftest, --unitTest, --fontTest and --masterMode must not be " +
|
||||
"specified at the same time.")
|
||||
)
|
||||
.check(
|
||||
describeCheck(function (argv) {
|
||||
return !argv.noDownload || !argv.downloadOnly;
|
||||
}, "--noDownload and --downloadOnly cannot be used together.")
|
||||
)
|
||||
.check(
|
||||
describeCheck(function (argv) {
|
||||
return !argv.masterMode || argv.manifestFile === "test_manifest.json";
|
||||
}, "when --masterMode is specified --manifestFile shall be equal " +
|
||||
"test_manifest.json")
|
||||
);
|
||||
var result = yargs.argv;
|
||||
.option("unitTest", {
|
||||
default: false,
|
||||
describe: "Run the unit tests.",
|
||||
type: "boolean",
|
||||
})
|
||||
.check(argv => {
|
||||
if (
|
||||
+argv.reftest + argv.unitTest + argv.fontTest + argv.masterMode <=
|
||||
1
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
throw new Error(
|
||||
"--reftest, --unitTest, --fontTest, and --masterMode must not be specified 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;
|
||||
}
|
||||
throw new Error(
|
||||
"when --masterMode is specified --manifestFile shall be equal to `test_manifest.json`."
|
||||
);
|
||||
});
|
||||
|
||||
const result = yargs.argv;
|
||||
if (result.help) {
|
||||
yargs.showHelp();
|
||||
process.exit(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue