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.
This commit is contained in:
parent
0b95d698d8
commit
844319cdb0
44
gulpfile.js
44
gulpfile.js
@ -551,7 +551,7 @@ function getTempFile(prefix, suffix) {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
function createTestSource(testsName, bot) {
|
||||
function createTestSource(testsName, { bot = false, xfaOnly = false } = {}) {
|
||||
const source = stream.Readable({ objectMode: true });
|
||||
source._read = function () {
|
||||
console.log();
|
||||
@ -561,9 +561,12 @@ function createTestSource(testsName, bot) {
|
||||
const args = ["test.js"];
|
||||
switch (testsName) {
|
||||
case "browser":
|
||||
args.push("--reftest", "--manifestFile=" + PDF_TEST);
|
||||
break;
|
||||
case "browser (no reftest)":
|
||||
if (!bot) {
|
||||
args.push("--reftest");
|
||||
}
|
||||
if (xfaOnly) {
|
||||
args.push("--xfaOnly");
|
||||
}
|
||||
args.push("--manifestFile=" + PDF_TEST);
|
||||
break;
|
||||
case "unit":
|
||||
@ -1592,9 +1595,34 @@ gulp.task(
|
||||
gulp.series(setTestEnv, "generic", "components", function runBotTest() {
|
||||
return streamqueue(
|
||||
{ objectMode: true },
|
||||
createTestSource("unit", true),
|
||||
createTestSource("font", true),
|
||||
createTestSource("browser (no reftest)", true),
|
||||
createTestSource("unit", { bot: true }),
|
||||
createTestSource("font", { bot: true }),
|
||||
createTestSource("browser", { bot: true }),
|
||||
createTestSource("integration")
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
gulp.task(
|
||||
"xfatest",
|
||||
gulp.series(setTestEnv, "generic", "components", function runXfaTest() {
|
||||
return streamqueue(
|
||||
{ objectMode: true },
|
||||
createTestSource("unit"),
|
||||
createTestSource("browser", { xfaOnly: true }),
|
||||
createTestSource("integration")
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
gulp.task(
|
||||
"botxfatest",
|
||||
gulp.series(setTestEnv, "generic", "components", function runBotXfaTest() {
|
||||
return streamqueue(
|
||||
{ objectMode: true },
|
||||
createTestSource("unit", { bot: true }),
|
||||
createTestSource("font", { bot: true }),
|
||||
createTestSource("browser", { bot: true, xfaOnly: true }),
|
||||
createTestSource("integration")
|
||||
);
|
||||
})
|
||||
@ -1616,7 +1644,7 @@ gulp.task(
|
||||
function runBotBrowserTest() {
|
||||
return streamqueue(
|
||||
{ objectMode: true },
|
||||
createTestSource("browser (no reftest)", true)
|
||||
createTestSource("browser", { bot: true })
|
||||
);
|
||||
}
|
||||
)
|
||||
|
@ -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…
Reference in New Issue
Block a user