mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #13846 from Snuffleupagus/test-xfa
Add a special `gulp xfatest` command, to limit the ref-tests to only XFA-documents (issue 13744)
This commit is contained in:
commit
b317e9311d
3 changed files with 79 additions and 12 deletions
|
@ -382,6 +382,7 @@ var Driver = (function DriverClosure() {
|
|||
this.testFilter = parameters.testFilter
|
||||
? JSON.parse(parameters.testFilter)
|
||||
: [];
|
||||
this.xfaOnly = parameters.xfaOnly === "true";
|
||||
|
||||
// Create a working canvas
|
||||
this.canvas = document.createElement("canvas");
|
||||
|
@ -425,9 +426,15 @@ var Driver = (function DriverClosure() {
|
|||
if (r.readyState === 4) {
|
||||
self._log("done\n");
|
||||
self.manifest = JSON.parse(r.responseText);
|
||||
if (self.testFilter && self.testFilter.length) {
|
||||
if (self.testFilter?.length || self.xfaOnly) {
|
||||
self.manifest = self.manifest.filter(function (item) {
|
||||
return self.testFilter.includes(item.id);
|
||||
if (self.testFilter.includes(item.id)) {
|
||||
return true;
|
||||
}
|
||||
if (self.xfaOnly && item.enableXfa) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
self.currentTask = 0;
|
||||
|
|
36
test/test.js
36
test/test.js
|
@ -45,6 +45,11 @@ function parseOptions() {
|
|||
describe: "Show this help message.",
|
||||
type: "boolean",
|
||||
})
|
||||
.option("integration", {
|
||||
default: false,
|
||||
describe: "Run the integration tests.",
|
||||
type: "boolean",
|
||||
})
|
||||
.option("manifestFile", {
|
||||
default: "test_manifest.json",
|
||||
describe: "A path to JSON file in the form of `test_manifest.json`.",
|
||||
|
@ -114,6 +119,11 @@ function parseOptions() {
|
|||
describe: "Run the unit tests.",
|
||||
type: "boolean",
|
||||
})
|
||||
.option("xfaOnly", {
|
||||
default: false,
|
||||
describe: "Only run the XFA reftest(s).",
|
||||
type: "boolean",
|
||||
})
|
||||
.check(argv => {
|
||||
if (
|
||||
+argv.reftest + argv.unitTest + argv.fontTest + argv.masterMode <=
|
||||
|
@ -125,6 +135,23 @@ function parseOptions() {
|
|||
"--reftest, --unitTest, --fontTest, and --masterMode must not be specified together."
|
||||
);
|
||||
})
|
||||
.check(argv => {
|
||||
if (
|
||||
+argv.unitTest + argv.fontTest + argv.integration + argv.xfaOnly <=
|
||||
1
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
throw new Error(
|
||||
"--unitTest, --fontTest, --integration, and --xfaOnly must not be specified together."
|
||||
);
|
||||
})
|
||||
.check(argv => {
|
||||
if (argv.testfilter && argv.testfilter.length > 0 && argv.xfaOnly) {
|
||||
throw new Error("--testfilter and --xfaOnly cannot be used together.");
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.check(argv => {
|
||||
if (!argv.noDownload || !argv.downloadOnly) {
|
||||
return true;
|
||||
|
@ -361,14 +388,18 @@ function handleSessionTimeout(session) {
|
|||
function getTestManifest() {
|
||||
var manifest = JSON.parse(fs.readFileSync(options.manifestFile));
|
||||
|
||||
var testFilter = options.testfilter.slice(0);
|
||||
if (testFilter.length) {
|
||||
const testFilter = options.testfilter.slice(0),
|
||||
xfaOnly = options.xfaOnly;
|
||||
if (testFilter.length || xfaOnly) {
|
||||
manifest = manifest.filter(function (item) {
|
||||
var i = testFilter.indexOf(item.id);
|
||||
if (i !== -1) {
|
||||
testFilter.splice(i, 1);
|
||||
return true;
|
||||
}
|
||||
if (xfaOnly && item.enableXfa) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (testFilter.length) {
|
||||
|
@ -732,6 +763,7 @@ function makeTestUrl(startUrl) {
|
|||
`?browser=${encodeURIComponent(browserName)}` +
|
||||
`&manifestFile=${encodeURIComponent("/test/" + options.manifestFile)}` +
|
||||
`&testFilter=${JSON.stringify(options.testfilter)}` +
|
||||
`&xfaOnly=${options.xfaOnly}` +
|
||||
`&delay=${options.statsDelay}` +
|
||||
`&masterMode=${options.masterMode}`;
|
||||
return startUrl + queryParameters;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue