Implement a command line flag to skip Chrome when running tests

To save time or resources during development it can be useful to run
tests only in Firefox. Previously this could be done by editing the
browser manifest file, but since that file is no longer used for
Puppeteer, this command line flag replaces it. For example, executing
`gulp unittest --noChrome` will only run the unit tests in Firefox.
This commit is contained in:
Tim van der Meij 2020-04-18 23:04:28 +02:00
parent 4834a276fd
commit 9ebb18f505
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762
2 changed files with 12 additions and 1 deletions

View File

@ -436,6 +436,9 @@ function createTestSource(testsName, bot) {
if (bot) { if (bot) {
args.push("--strictVerify"); args.push("--strictVerify");
} }
if (process.argv.includes("--noChrome")) {
args.push("--noChrome");
}
var testProcess = startNode(args, { cwd: TEST_DIR, stdio: "inherit" }); var testProcess = startNode(args, { cwd: TEST_DIR, stdio: "inherit" });
testProcess.on("close", function (code) { testProcess.on("close", function (code) {
@ -454,6 +457,10 @@ function makeRef(done, bot) {
if (bot) { if (bot) {
args.push("--noPrompts", "--strictVerify"); args.push("--noPrompts", "--strictVerify");
} }
if (process.argv.includes("--noChrome")) {
args.push("--noChrome");
}
var testProcess = startNode(args, { cwd: TEST_DIR, stdio: "inherit" }); var testProcess = startNode(args, { cwd: TEST_DIR, stdio: "inherit" });
testProcess.on("close", function (code) { testProcess.on("close", function (code) {
done(); done();

View File

@ -43,6 +43,7 @@ function parseOptions() {
"fontTest", "fontTest",
"noPrompts", "noPrompts",
"noDownload", "noDownload",
"noChrome",
"downloadOnly", "downloadOnly",
"strictVerify", "strictVerify",
]) ])
@ -77,6 +78,7 @@ function parseOptions() {
.describe("unitTest", "Run the unit tests.") .describe("unitTest", "Run the unit tests.")
.describe("fontTest", "Run the font tests.") .describe("fontTest", "Run the font tests.")
.describe("noDownload", "Skips test PDFs downloading.") .describe("noDownload", "Skips test PDFs downloading.")
.describe("noChrome", "Skip Chrome when running tests.")
.describe("downloadOnly", "Download test PDFs without running the tests.") .describe("downloadOnly", "Download test PDFs without running the tests.")
.describe("strictVerify", "Error if verifying the manifest files fails.") .describe("strictVerify", "Error if verifying the manifest files fails.")
.describe("statsFile", "The file where to store stats.") .describe("statsFile", "The file where to store stats.")
@ -799,8 +801,10 @@ async function startBrowser(browserName, startUrl) {
} }
function startBrowsers(rootUrl, initSessionCallback) { function startBrowsers(rootUrl, initSessionCallback) {
const browserNames = options.noChrome ? ["firefox"] : ["firefox", "chrome"];
sessions = []; sessions = [];
for (const browserName of ["chrome", "firefox"]) { for (const browserName of browserNames) {
// The session must be pushed first and augmented with the browser once // The session must be pushed first and augmented with the browser once
// it's initialized. The reason for this is that browser initialization // it's initialized. The reason for this is that browser initialization
// takes more time when the browser is not found locally yet and we don't // takes more time when the browser is not found locally yet and we don't