Implement optionally running the tests in headless mode
This commit prepares for running the font tests on GitHub Actions where we can't spin up headful browsers because there are no display capabilities on the workers. This will also be useful for porting other test targets to GitHub Actions at a later time, as well as running the tests locally in headless mode.
This commit is contained in:
parent
a1d84f8ce1
commit
69452bb60e
@ -684,6 +684,9 @@ function createTestSource(testsName, { bot = false, xfaOnly = false } = {}) {
|
|||||||
if (process.argv.includes("--noChrome") || forceNoChrome) {
|
if (process.argv.includes("--noChrome") || forceNoChrome) {
|
||||||
args.push("--noChrome");
|
args.push("--noChrome");
|
||||||
}
|
}
|
||||||
|
if (process.argv.includes("--headless")) {
|
||||||
|
args.push("--headless");
|
||||||
|
}
|
||||||
|
|
||||||
const testProcess = startNode(args, { cwd: TEST_DIR, stdio: "inherit" });
|
const testProcess = startNode(args, { cwd: TEST_DIR, stdio: "inherit" });
|
||||||
testProcess.on("close", function (code) {
|
testProcess.on("close", function (code) {
|
||||||
@ -712,6 +715,9 @@ function makeRef(done, bot) {
|
|||||||
if (process.argv.includes("--noChrome") || forceNoChrome) {
|
if (process.argv.includes("--noChrome") || forceNoChrome) {
|
||||||
args.push("--noChrome");
|
args.push("--noChrome");
|
||||||
}
|
}
|
||||||
|
if (process.argv.includes("--headless")) {
|
||||||
|
args.push("--headless");
|
||||||
|
}
|
||||||
|
|
||||||
const testProcess = startNode(args, { cwd: TEST_DIR, stdio: "inherit" });
|
const testProcess = startNode(args, { cwd: TEST_DIR, stdio: "inherit" });
|
||||||
testProcess.on("close", function (code) {
|
testProcess.on("close", function (code) {
|
||||||
|
@ -99,6 +99,12 @@ function parseOptions() {
|
|||||||
describe: "Uses default answers (intended for CLOUD TESTS only!).",
|
describe: "Uses default answers (intended for CLOUD TESTS only!).",
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
})
|
})
|
||||||
|
.option("headless", {
|
||||||
|
default: false,
|
||||||
|
describe:
|
||||||
|
"Run the tests in headless mode, i.e. without visible browser windows.",
|
||||||
|
type: "boolean",
|
||||||
|
})
|
||||||
.option("port", {
|
.option("port", {
|
||||||
default: 0,
|
default: 0,
|
||||||
describe: "The port the HTTP server should listen on.",
|
describe: "The port the HTTP server should listen on.",
|
||||||
@ -252,6 +258,7 @@ function examineRefImages() {
|
|||||||
|
|
||||||
startBrowser({
|
startBrowser({
|
||||||
browserName: "firefox",
|
browserName: "firefox",
|
||||||
|
headless: false,
|
||||||
startUrl: `http://${host}:${server.port}/test/resources/reftest-analyzer.html#web=/test/eq.log`,
|
startUrl: `http://${host}:${server.port}/test/resources/reftest-analyzer.html#web=/test/eq.log`,
|
||||||
}).then(function (browser) {
|
}).then(function (browser) {
|
||||||
browser.on("disconnected", function () {
|
browser.on("disconnected", function () {
|
||||||
@ -897,10 +904,12 @@ function unitTestPostHandler(req, res) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startBrowser({ browserName, startUrl }) {
|
async function startBrowser({ browserName, headless, startUrl }) {
|
||||||
const options = {
|
const options = {
|
||||||
product: browserName,
|
product: browserName,
|
||||||
headless: false,
|
// Note that using `headless: true` gives a deprecation warning; see
|
||||||
|
// https://github.com/puppeteer/puppeteer#default-runtime-settings.
|
||||||
|
headless: headless === true ? "new" : false,
|
||||||
defaultViewport: null,
|
defaultViewport: null,
|
||||||
ignoreDefaultArgs: ["--disable-extensions"],
|
ignoreDefaultArgs: ["--disable-extensions"],
|
||||||
// The timeout for individual protocol (CDP) calls should always be lower
|
// The timeout for individual protocol (CDP) calls should always be lower
|
||||||
@ -1006,7 +1015,7 @@ async function startBrowsers({ baseUrl, initializeSession }) {
|
|||||||
startUrl = baseUrl + queryParameters;
|
startUrl = baseUrl + queryParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
await startBrowser({ browserName, startUrl })
|
await startBrowser({ browserName, headless: options.headless, startUrl })
|
||||||
.then(function (browser) {
|
.then(function (browser) {
|
||||||
session.browser = browser;
|
session.browser = browser;
|
||||||
initializeSession(session);
|
initializeSession(session);
|
||||||
|
Loading…
Reference in New Issue
Block a user