Skip to content

Commit 844319c

Browse files
committed
Add a special gulp xfatest command, to limit the ref-tests to only XFA-documents (issue 13744)
The new command is a *variation* of the standard `gulp test` command and will run all unit/font/integration-tests just as normal, while *only* running ref-tests for XFA-documents to speed up development. Given that we currently have (some) unit-tests for XFA-documents, and that we may also (in the future) want to add integration-tests, it thus makes sense to run all test-suites in my opinion. *Please note:* Once this patch has landed, I'll submit a follow-up patch to https://github.com/mozilla/botio-files-pdfjs such that we can also run the new command on the bots.
1 parent 0b95d69 commit 844319c

File tree

3 files changed

+79
-12
lines changed

3 files changed

+79
-12
lines changed

gulpfile.js

+36-8
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ function getTempFile(prefix, suffix) {
551551
return filePath;
552552
}
553553

554-
function createTestSource(testsName, bot) {
554+
function createTestSource(testsName, { bot = false, xfaOnly = false } = {}) {
555555
const source = stream.Readable({ objectMode: true });
556556
source._read = function () {
557557
console.log();
@@ -561,9 +561,12 @@ function createTestSource(testsName, bot) {
561561
const args = ["test.js"];
562562
switch (testsName) {
563563
case "browser":
564-
args.push("--reftest", "--manifestFile=" + PDF_TEST);
565-
break;
566-
case "browser (no reftest)":
564+
if (!bot) {
565+
args.push("--reftest");
566+
}
567+
if (xfaOnly) {
568+
args.push("--xfaOnly");
569+
}
567570
args.push("--manifestFile=" + PDF_TEST);
568571
break;
569572
case "unit":
@@ -1592,9 +1595,34 @@ gulp.task(
15921595
gulp.series(setTestEnv, "generic", "components", function runBotTest() {
15931596
return streamqueue(
15941597
{ objectMode: true },
1595-
createTestSource("unit", true),
1596-
createTestSource("font", true),
1597-
createTestSource("browser (no reftest)", true),
1598+
createTestSource("unit", { bot: true }),
1599+
createTestSource("font", { bot: true }),
1600+
createTestSource("browser", { bot: true }),
1601+
createTestSource("integration")
1602+
);
1603+
})
1604+
);
1605+
1606+
gulp.task(
1607+
"xfatest",
1608+
gulp.series(setTestEnv, "generic", "components", function runXfaTest() {
1609+
return streamqueue(
1610+
{ objectMode: true },
1611+
createTestSource("unit"),
1612+
createTestSource("browser", { xfaOnly: true }),
1613+
createTestSource("integration")
1614+
);
1615+
})
1616+
);
1617+
1618+
gulp.task(
1619+
"botxfatest",
1620+
gulp.series(setTestEnv, "generic", "components", function runBotXfaTest() {
1621+
return streamqueue(
1622+
{ objectMode: true },
1623+
createTestSource("unit", { bot: true }),
1624+
createTestSource("font", { bot: true }),
1625+
createTestSource("browser", { bot: true, xfaOnly: true }),
15981626
createTestSource("integration")
15991627
);
16001628
})
@@ -1616,7 +1644,7 @@ gulp.task(
16161644
function runBotBrowserTest() {
16171645
return streamqueue(
16181646
{ objectMode: true },
1619-
createTestSource("browser (no reftest)", true)
1647+
createTestSource("browser", { bot: true })
16201648
);
16211649
}
16221650
)

test/driver.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ var Driver = (function DriverClosure() {
382382
this.testFilter = parameters.testFilter
383383
? JSON.parse(parameters.testFilter)
384384
: [];
385+
this.xfaOnly = parameters.xfaOnly === "true";
385386

386387
// Create a working canvas
387388
this.canvas = document.createElement("canvas");
@@ -425,9 +426,15 @@ var Driver = (function DriverClosure() {
425426
if (r.readyState === 4) {
426427
self._log("done\n");
427428
self.manifest = JSON.parse(r.responseText);
428-
if (self.testFilter && self.testFilter.length) {
429+
if (self.testFilter?.length || self.xfaOnly) {
429430
self.manifest = self.manifest.filter(function (item) {
430-
return self.testFilter.includes(item.id);
431+
if (self.testFilter.includes(item.id)) {
432+
return true;
433+
}
434+
if (self.xfaOnly && item.enableXfa) {
435+
return true;
436+
}
437+
return false;
431438
});
432439
}
433440
self.currentTask = 0;

test/test.js

+34-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ function parseOptions() {
4545
describe: "Show this help message.",
4646
type: "boolean",
4747
})
48+
.option("integration", {
49+
default: false,
50+
describe: "Run the integration tests.",
51+
type: "boolean",
52+
})
4853
.option("manifestFile", {
4954
default: "test_manifest.json",
5055
describe: "A path to JSON file in the form of `test_manifest.json`.",
@@ -114,6 +119,11 @@ function parseOptions() {
114119
describe: "Run the unit tests.",
115120
type: "boolean",
116121
})
122+
.option("xfaOnly", {
123+
default: false,
124+
describe: "Only run the XFA reftest(s).",
125+
type: "boolean",
126+
})
117127
.check(argv => {
118128
if (
119129
+argv.reftest + argv.unitTest + argv.fontTest + argv.masterMode <=
@@ -125,6 +135,23 @@ function parseOptions() {
125135
"--reftest, --unitTest, --fontTest, and --masterMode must not be specified together."
126136
);
127137
})
138+
.check(argv => {
139+
if (
140+
+argv.unitTest + argv.fontTest + argv.integration + argv.xfaOnly <=
141+
1
142+
) {
143+
return true;
144+
}
145+
throw new Error(
146+
"--unitTest, --fontTest, --integration, and --xfaOnly must not be specified together."
147+
);
148+
})
149+
.check(argv => {
150+
if (argv.testfilter && argv.testfilter.length > 0 && argv.xfaOnly) {
151+
throw new Error("--testfilter and --xfaOnly cannot be used together.");
152+
}
153+
return true;
154+
})
128155
.check(argv => {
129156
if (!argv.noDownload || !argv.downloadOnly) {
130157
return true;
@@ -361,14 +388,18 @@ function handleSessionTimeout(session) {
361388
function getTestManifest() {
362389
var manifest = JSON.parse(fs.readFileSync(options.manifestFile));
363390

364-
var testFilter = options.testfilter.slice(0);
365-
if (testFilter.length) {
391+
const testFilter = options.testfilter.slice(0),
392+
xfaOnly = options.xfaOnly;
393+
if (testFilter.length || xfaOnly) {
366394
manifest = manifest.filter(function (item) {
367395
var i = testFilter.indexOf(item.id);
368396
if (i !== -1) {
369397
testFilter.splice(i, 1);
370398
return true;
371399
}
400+
if (xfaOnly && item.enableXfa) {
401+
return true;
402+
}
372403
return false;
373404
});
374405
if (testFilter.length) {
@@ -732,6 +763,7 @@ function makeTestUrl(startUrl) {
732763
`?browser=${encodeURIComponent(browserName)}` +
733764
`&manifestFile=${encodeURIComponent("/test/" + options.manifestFile)}` +
734765
`&testFilter=${JSON.stringify(options.testfilter)}` +
766+
`&xfaOnly=${options.xfaOnly}` +
735767
`&delay=${options.statsDelay}` +
736768
`&masterMode=${options.masterMode}`;
737769
return startUrl + queryParameters;

0 commit comments

Comments
 (0)