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;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTestSource(testsName, bot) {
|
function createTestSource(testsName, { bot = false, xfaOnly = false } = {}) {
|
||||||
const source = stream.Readable({ objectMode: true });
|
const source = stream.Readable({ objectMode: true });
|
||||||
source._read = function () {
|
source._read = function () {
|
||||||
console.log();
|
console.log();
|
||||||
@ -561,9 +561,12 @@ function createTestSource(testsName, bot) {
|
|||||||
const args = ["test.js"];
|
const args = ["test.js"];
|
||||||
switch (testsName) {
|
switch (testsName) {
|
||||||
case "browser":
|
case "browser":
|
||||||
args.push("--reftest", "--manifestFile=" + PDF_TEST);
|
if (!bot) {
|
||||||
break;
|
args.push("--reftest");
|
||||||
case "browser (no reftest)":
|
}
|
||||||
|
if (xfaOnly) {
|
||||||
|
args.push("--xfaOnly");
|
||||||
|
}
|
||||||
args.push("--manifestFile=" + PDF_TEST);
|
args.push("--manifestFile=" + PDF_TEST);
|
||||||
break;
|
break;
|
||||||
case "unit":
|
case "unit":
|
||||||
@ -1592,9 +1595,34 @@ gulp.task(
|
|||||||
gulp.series(setTestEnv, "generic", "components", function runBotTest() {
|
gulp.series(setTestEnv, "generic", "components", function runBotTest() {
|
||||||
return streamqueue(
|
return streamqueue(
|
||||||
{ objectMode: true },
|
{ objectMode: true },
|
||||||
createTestSource("unit", true),
|
createTestSource("unit", { bot: true }),
|
||||||
createTestSource("font", true),
|
createTestSource("font", { bot: true }),
|
||||||
createTestSource("browser (no reftest)", 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")
|
createTestSource("integration")
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
@ -1616,7 +1644,7 @@ gulp.task(
|
|||||||
function runBotBrowserTest() {
|
function runBotBrowserTest() {
|
||||||
return streamqueue(
|
return streamqueue(
|
||||||
{ objectMode: true },
|
{ objectMode: true },
|
||||||
createTestSource("browser (no reftest)", true)
|
createTestSource("browser", { bot: true })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -382,6 +382,7 @@ var Driver = (function DriverClosure() {
|
|||||||
this.testFilter = parameters.testFilter
|
this.testFilter = parameters.testFilter
|
||||||
? JSON.parse(parameters.testFilter)
|
? JSON.parse(parameters.testFilter)
|
||||||
: [];
|
: [];
|
||||||
|
this.xfaOnly = parameters.xfaOnly === "true";
|
||||||
|
|
||||||
// Create a working canvas
|
// Create a working canvas
|
||||||
this.canvas = document.createElement("canvas");
|
this.canvas = document.createElement("canvas");
|
||||||
@ -425,9 +426,15 @@ var Driver = (function DriverClosure() {
|
|||||||
if (r.readyState === 4) {
|
if (r.readyState === 4) {
|
||||||
self._log("done\n");
|
self._log("done\n");
|
||||||
self.manifest = JSON.parse(r.responseText);
|
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) {
|
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;
|
self.currentTask = 0;
|
||||||
|
36
test/test.js
36
test/test.js
@ -45,6 +45,11 @@ function parseOptions() {
|
|||||||
describe: "Show this help message.",
|
describe: "Show this help message.",
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
})
|
})
|
||||||
|
.option("integration", {
|
||||||
|
default: false,
|
||||||
|
describe: "Run the integration tests.",
|
||||||
|
type: "boolean",
|
||||||
|
})
|
||||||
.option("manifestFile", {
|
.option("manifestFile", {
|
||||||
default: "test_manifest.json",
|
default: "test_manifest.json",
|
||||||
describe: "A path to JSON file in the form of `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.",
|
describe: "Run the unit tests.",
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
})
|
})
|
||||||
|
.option("xfaOnly", {
|
||||||
|
default: false,
|
||||||
|
describe: "Only run the XFA reftest(s).",
|
||||||
|
type: "boolean",
|
||||||
|
})
|
||||||
.check(argv => {
|
.check(argv => {
|
||||||
if (
|
if (
|
||||||
+argv.reftest + argv.unitTest + argv.fontTest + argv.masterMode <=
|
+argv.reftest + argv.unitTest + argv.fontTest + argv.masterMode <=
|
||||||
@ -125,6 +135,23 @@ function parseOptions() {
|
|||||||
"--reftest, --unitTest, --fontTest, and --masterMode must not be specified together."
|
"--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 => {
|
.check(argv => {
|
||||||
if (!argv.noDownload || !argv.downloadOnly) {
|
if (!argv.noDownload || !argv.downloadOnly) {
|
||||||
return true;
|
return true;
|
||||||
@ -361,14 +388,18 @@ function handleSessionTimeout(session) {
|
|||||||
function getTestManifest() {
|
function getTestManifest() {
|
||||||
var manifest = JSON.parse(fs.readFileSync(options.manifestFile));
|
var manifest = JSON.parse(fs.readFileSync(options.manifestFile));
|
||||||
|
|
||||||
var testFilter = options.testfilter.slice(0);
|
const testFilter = options.testfilter.slice(0),
|
||||||
if (testFilter.length) {
|
xfaOnly = options.xfaOnly;
|
||||||
|
if (testFilter.length || xfaOnly) {
|
||||||
manifest = manifest.filter(function (item) {
|
manifest = manifest.filter(function (item) {
|
||||||
var i = testFilter.indexOf(item.id);
|
var i = testFilter.indexOf(item.id);
|
||||||
if (i !== -1) {
|
if (i !== -1) {
|
||||||
testFilter.splice(i, 1);
|
testFilter.splice(i, 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (xfaOnly && item.enableXfa) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
if (testFilter.length) {
|
if (testFilter.length) {
|
||||||
@ -732,6 +763,7 @@ function makeTestUrl(startUrl) {
|
|||||||
`?browser=${encodeURIComponent(browserName)}` +
|
`?browser=${encodeURIComponent(browserName)}` +
|
||||||
`&manifestFile=${encodeURIComponent("/test/" + options.manifestFile)}` +
|
`&manifestFile=${encodeURIComponent("/test/" + options.manifestFile)}` +
|
||||||
`&testFilter=${JSON.stringify(options.testfilter)}` +
|
`&testFilter=${JSON.stringify(options.testfilter)}` +
|
||||||
|
`&xfaOnly=${options.xfaOnly}` +
|
||||||
`&delay=${options.statsDelay}` +
|
`&delay=${options.statsDelay}` +
|
||||||
`&masterMode=${options.masterMode}`;
|
`&masterMode=${options.masterMode}`;
|
||||||
return startUrl + queryParameters;
|
return startUrl + queryParameters;
|
||||||
|
Loading…
Reference in New Issue
Block a user