From 1f799b463cc53d7d0c06a5359afec8bca979aca9 Mon Sep 17 00:00:00 2001 From: Chris Cuellar <58723+ChrisC@users.noreply.github.com> Date: Tue, 23 Jul 2024 14:00:43 -0700 Subject: [PATCH 01/18] first pass at calling test runner directly from host --- src/agent/create-test-runner.js | 11 +++++----- src/agent/mock-test-runner.js | 12 +++++------ src/agent/types.js | 2 +- src/host/cli-run-plan.js | 26 ++++++++++-------------- src/host/main.js | 36 ++++++++++++++++----------------- 5 files changed, 40 insertions(+), 47 deletions(-) diff --git a/src/agent/create-test-runner.js b/src/agent/create-test-runner.js index 203a647..b0c2441 100644 --- a/src/agent/create-test-runner.js +++ b/src/agent/create-test-runner.js @@ -13,7 +13,6 @@ import { AgentMessage } from './messages.js'; /** * @param {object} options - * @param {Promise} options.abortSignal resolves when runner should stop * @param {{hostname: string, port: number | string, pathname: string}} options.atDriverUrl * @param {AriaATCIShared.BaseURL} options.baseUrl * @param {AriaATCIAgent.Log} options.log @@ -23,9 +22,9 @@ import { AgentMessage } from './messages.js'; * @returns {Promise} */ export async function createRunner(options) { - if (!options.abortSignal) { - throw new Error('createRunner requires abortSignal option.'); - } + // stubbing this out for now + const abortSignal = new Promise(resolve => resolve()); + if (options.mock) { return new MockTestRunner({ mock: options.mock, ...options }); } @@ -34,13 +33,13 @@ export async function createRunner(options) { createBrowserDriver({ url: options.webDriverUrl, browser: options.webDriverBrowser, - abortSignal: options.abortSignal, + abortSignal, }).catch(cause => { throw new Error('Error initializing browser driver', { cause }); }), createATDriver({ url: options.atDriverUrl, - abortSignal: options.abortSignal, + abortSignal, log: options.log, }).catch(cause => { throw new Error('Error connecting to at-driver', { cause }); diff --git a/src/agent/mock-test-runner.js b/src/agent/mock-test-runner.js index e13ccb8..7d4cf0d 100644 --- a/src/agent/mock-test-runner.js +++ b/src/agent/mock-test-runner.js @@ -22,7 +22,7 @@ export class MockTestRunner { */ constructor({ baseUrl, log, mock: config }) { this.baseUrl = baseUrl; - this.log = log; + this.log = console.log; this.config = config; } @@ -62,14 +62,12 @@ export class MockTestRunner { /** * @param {AriaATCIData.CollectedTest} task + * @param {AriaATCIShared.BaseURL} baseUrl */ - async run(task) { - const base = `${this.baseUrl.protocol}//${this.baseUrl.hostname}:${this.baseUrl.port}${this.baseUrl.pathname}`; + async run(task, baseUrl) { + const base = `${baseUrl.protocol}://${baseUrl.hostname}:${baseUrl.port}${baseUrl.pathname}`; await this.openPage( - new URL( - `${this.baseUrl.pathname ? `${this.baseUrl.pathname}/` : ''}${task.target.referencePage}`, - base - ) + new URL(`${baseUrl.pathname ? `${baseUrl.pathname}/` : ''}${task.target.referencePage}`, base) ); const commandsOutput = []; diff --git a/src/agent/types.js b/src/agent/types.js index db10769..e4da2ab 100644 --- a/src/agent/types.js +++ b/src/agent/types.js @@ -28,7 +28,7 @@ /** * @typedef AriaATCIAgent.TestRunner - * @property {function(AriaATCIData.Test): Promise} run run a test + * @property {function(AriaATCIData.Test, AriaATCIShared.BaseURL): Promise} run run a test */ /** diff --git a/src/host/cli-run-plan.js b/src/host/cli-run-plan.js index ee1b311..f6432c6 100644 --- a/src/host/cli-run-plan.js +++ b/src/host/cli-run-plan.js @@ -16,6 +16,9 @@ import { HostMessage, createHostLogger } from './messages.js'; import { plansFrom } from './plan-from.js'; import { HostServer } from './server.js'; +import { createRunner } from '../agent/create-test-runner.js'; +import { agentMockOptions } from '../agent/cli.js'; + export const command = 'run-plan [plan-files..]'; export const describe = 'Run test plans'; @@ -193,7 +196,7 @@ function mainMiddleware(argv) { mainLoggerMiddleware(argv); mainTestPlanMiddleware(argv); mainServerMiddleware(argv); - mainAgentMiddleware(argv); + mainRunnerMiddleware(argv); mainResultMiddleware(argv); } @@ -258,13 +261,9 @@ function mainServerMiddleware(argv) { argv.server = new HostServer({ log, baseUrl: { hostname: argv.referenceHostname } }); } -function mainAgentMiddleware(argv) { +async function mainRunnerMiddleware(argv) { const { log, - agentProtocol: protocol, - agentDebug, - agentQuiet, - agentVerbose, agentWebDriverUrl, agentWebDriverBrowser, agentAtDriverUrl, @@ -272,19 +271,16 @@ function mainAgentMiddleware(argv) { agentMockOpenPage, } = argv; - argv.agent = new Agent({ + argv.runner = await createRunner({ log, - protocol, - config: pickAgentCliOptions({ - debug: agentDebug, - quiet: agentQuiet, - verbose: agentVerbose, - webDriverUrl: agentWebDriverUrl, - webDriverBrowser: agentWebDriverBrowser, - atDriverUrl: agentAtDriverUrl, + baseUrl: argv.server.baseUrl, + mock: agentMockOptions({ mock: agentMock, mockOpenPage: agentMockOpenPage, }), + webDriverUrl: agentWebDriverUrl, + webDriverBrowser: agentWebDriverBrowser, + atDriverUrl: agentAtDriverUrl, }); } diff --git a/src/host/main.js b/src/host/main.js index 7dfb9d9..7a10f8e 100644 --- a/src/host/main.js +++ b/src/host/main.js @@ -32,7 +32,7 @@ const logUnsuccessfulHTTP = async (log, response) => { * @param {AriaATCIHost.Log} options.log * @param {AsyncIterable} options.plans * @param {AriaATCIHost.ReferenceFileServer} options.server - * @param {AriaATCIHost.Agent} options.agent + * @param {AriaATCIAgent.TestRunner} options.runner * @param {AriaATCIHost.EmitPlanResults} options.emitPlanResults * @param {string} [options.callbackUrl] * @param {Record} [options.callbackHeader] @@ -42,7 +42,7 @@ export async function hostMain({ log, plans, server, - agent, + runner, emitPlanResults, callbackUrl, callbackHeader, @@ -50,11 +50,11 @@ export async function hostMain({ }) { log(HostMessage.START); - const hostLogJob = startJob(async function (signal) { - for await (const agentLog of signal.cancelable(agent.logs())) { - log(HostMessage.AGENT_LOG, agentLog); - } - }); + // const hostLogJob = startJob(async function (signal) { + // for await (const agentLog of signal.cancelable(agent.logs())) { + // log(HostMessage.AGENT_LOG, agentLog); + // } + // }); await server.ready; log(HostMessage.SERVER_LISTENING, { url: server.baseUrl }); @@ -66,7 +66,7 @@ export async function hostMain({ setServerOptionsInTestPlan(plan, { baseUrl: serverDirectory.baseUrl }); log(HostMessage.START_AGENT); - await agent.start({ referenceBaseUrl: serverDirectory.baseUrl }); + // await agent.start({ referenceBaseUrl: serverDirectory.baseUrl }); let lastCallbackRequest = Promise.resolve(); @@ -92,12 +92,12 @@ export async function hostMain({ for (const test of plan.tests) { log(HostMessage.START_TEST); - const testLogJob = startJob(async function (signal) { - for await (const testLog of signal.cancelable(agent.logs())) { - plan = addLogToTestPlan(plan, testLog); - plan = addTestLogToTestPlan(plan, test); - } - }); + // const testLogJob = startJob(async function (signal) { + // for await (const testLog of signal.cancelable(agent.logs())) { + // plan = addLogToTestPlan(plan, testLog); + // plan = addTestLogToTestPlan(plan, test); + // } + // }); const file = plan.files.find(({ name }) => name === test.filepath); const testSource = JSON.parse(textDecoder.decode(file.bufferData)); @@ -109,7 +109,7 @@ export async function hostMain({ try { postCallbackWhenEnabled({ ...callbackBody, status: 'RUNNING' }); - const result = await agent.run(testSource); + const result = await runner.run(testSource, serverDirectory.baseUrl); const { capabilities, commands } = result; @@ -128,7 +128,7 @@ export async function hostMain({ await lastCallbackRequest; throw exception; } finally { - await testLogJob.cancel(); + // await testLogJob.cancel(); } } @@ -137,11 +137,11 @@ export async function hostMain({ log(HostMessage.STOP_AGENT); await lastCallbackRequest; - await agent.stop(); + // await agent.stop(); await emitPlanResults(plan); } - await hostLogJob.cancel(); + // await hostLogJob.cancel(); log(HostMessage.STOP_SERVER); await server.close(); From c0f6e0d78f61e0dc96f53b74f2964596298481ec Mon Sep 17 00:00:00 2001 From: Chris Cuellar <58723+ChrisC@users.noreply.github.com> Date: Wed, 24 Jul 2024 18:08:22 -0700 Subject: [PATCH 02/18] creates test runner directly in host/main --- src/agent/create-test-runner.js | 7 +++-- src/agent/driver-test-runner.js | 4 +-- src/agent/mock-test-runner.js | 2 +- src/host/cli-run-plan.js | 29 ------------------ src/host/main.js | 54 +++++++++++++++++++++++++-------- src/host/messages.js | 2 ++ 6 files changed, 50 insertions(+), 48 deletions(-) diff --git a/src/agent/create-test-runner.js b/src/agent/create-test-runner.js index b0c2441..a68e35d 100644 --- a/src/agent/create-test-runner.js +++ b/src/agent/create-test-runner.js @@ -15,7 +15,8 @@ import { AgentMessage } from './messages.js'; * @param {object} options * @param {{hostname: string, port: number | string, pathname: string}} options.atDriverUrl * @param {AriaATCIShared.BaseURL} options.baseUrl - * @param {AriaATCIAgent.Log} options.log + * @param {AriaATCIHost.Log} options.log + * @param {Promise} options.abortSignal * @param {AriaATCIAgent.MockOptions} [options.mock] * @param {AriaATCIAgent.Browser} [options.webDriverBrowser] * @param {{toString: function(): string}} options.webDriverUrl @@ -23,7 +24,7 @@ import { AgentMessage } from './messages.js'; */ export async function createRunner(options) { // stubbing this out for now - const abortSignal = new Promise(resolve => resolve()); + const abortSignal = options.abortSignal; if (options.mock) { return new MockTestRunner({ mock: options.mock, ...options }); @@ -40,7 +41,7 @@ export async function createRunner(options) { createATDriver({ url: options.atDriverUrl, abortSignal, - log: options.log, + log: console.log, }).catch(cause => { throw new Error('Error connecting to at-driver', { cause }); }), diff --git a/src/agent/driver-test-runner.js b/src/agent/driver-test-runner.js index 6c2c9fa..baa15ec 100644 --- a/src/agent/driver-test-runner.js +++ b/src/agent/driver-test-runner.js @@ -19,7 +19,7 @@ export class DriverTestRunner { /** * @param {object} options * @param {AriaATCIShared.BaseURL} options.baseUrl - * @param {AriaATCIAgent.Log} options.log + * @param {AriaATCIHost.Log} options.log * @param {BrowserDriver} options.browserDriver * @param {ATDriver} options.atDriver */ @@ -296,7 +296,7 @@ export class DriverTestRunner { _appendBaseUrl(pathname) { // protocol ends with a ':' and pathname starts with a '/' - const base = `${this.baseUrl.protocol}//${this.baseUrl.hostname}:${this.baseUrl.port}${this.baseUrl.pathname}`; + const base = `${this.baseUrl.protocol}://${this.baseUrl.hostname}:${this.baseUrl.port}${this.baseUrl.pathname}`; const newPath = `${this.baseUrl.pathname ? `${this.baseUrl.pathname}/` : ''}${pathname}`; return new URL(newPath, base); } diff --git a/src/agent/mock-test-runner.js b/src/agent/mock-test-runner.js index 7d4cf0d..4dffb0c 100644 --- a/src/agent/mock-test-runner.js +++ b/src/agent/mock-test-runner.js @@ -17,7 +17,7 @@ export class MockTestRunner { /** * @param {object} options * @param {AriaATCIShared.BaseURL} options.baseUrl - * @param {AriaATCIAgent.Log} options.log + * @param {AriaATCIHost.Log} options.log * @param {AriaATCIAgent.MockOptions} options.mock */ constructor({ baseUrl, log, mock: config }) { diff --git a/src/host/cli-run-plan.js b/src/host/cli-run-plan.js index f6432c6..4ebcfad 100644 --- a/src/host/cli-run-plan.js +++ b/src/host/cli-run-plan.js @@ -7,18 +7,13 @@ import { Readable } from 'stream'; import fetch, { Response } from 'node-fetch'; import yargs from 'yargs'; -import { pickAgentCliOptions } from '../agent/cli.js'; import { AgentMessage } from '../agent/messages.js'; -import { AgentController as Agent } from './agent.js'; import { hostMain } from './main.js'; import { HostMessage, createHostLogger } from './messages.js'; import { plansFrom } from './plan-from.js'; import { HostServer } from './server.js'; -import { createRunner } from '../agent/create-test-runner.js'; -import { agentMockOptions } from '../agent/cli.js'; - export const command = 'run-plan [plan-files..]'; export const describe = 'Run test plans'; @@ -196,7 +191,6 @@ function mainMiddleware(argv) { mainLoggerMiddleware(argv); mainTestPlanMiddleware(argv); mainServerMiddleware(argv); - mainRunnerMiddleware(argv); mainResultMiddleware(argv); } @@ -261,29 +255,6 @@ function mainServerMiddleware(argv) { argv.server = new HostServer({ log, baseUrl: { hostname: argv.referenceHostname } }); } -async function mainRunnerMiddleware(argv) { - const { - log, - agentWebDriverUrl, - agentWebDriverBrowser, - agentAtDriverUrl, - agentMock, - agentMockOpenPage, - } = argv; - - argv.runner = await createRunner({ - log, - baseUrl: argv.server.baseUrl, - mock: agentMockOptions({ - mock: agentMock, - mockOpenPage: agentMockOpenPage, - }), - webDriverUrl: agentWebDriverUrl, - webDriverBrowser: agentWebDriverBrowser, - atDriverUrl: agentAtDriverUrl, - }); -} - function mainResultMiddleware(argv) { const { stdout } = argv; diff --git a/src/host/main.js b/src/host/main.js index 7a10f8e..7ff78da 100644 --- a/src/host/main.js +++ b/src/host/main.js @@ -4,6 +4,9 @@ * @module host */ +import { EventEmitter } from 'events'; +import { agentMockOptions } from '../agent/cli.js'; +import { createRunner } from '../agent/create-test-runner.js'; import { startJob } from '../shared/job.js'; import { HostMessage } from './messages.js'; @@ -37,17 +40,27 @@ const logUnsuccessfulHTTP = async (log, response) => { * @param {string} [options.callbackUrl] * @param {Record} [options.callbackHeader] * @param {typeof fetch} options.fetch + * @param options.agentMock + * @param options.agentMockOpenPage + * @param options.agentWebDriverUrl + * @param options.agentWebDriverBrowser + * @param options.agentAtDriverUrl */ -export async function hostMain({ - log, - plans, - server, - runner, - emitPlanResults, - callbackUrl, - callbackHeader, - fetch, -}) { +export async function hostMain(options) { + const { + log, + plans, + server, + emitPlanResults, + callbackUrl, + callbackHeader, + fetch, + agentMock, + agentMockOpenPage, + agentWebDriverUrl, + agentWebDriverBrowser, + agentAtDriverUrl, + } = options; log(HostMessage.START); // const hostLogJob = startJob(async function (signal) { @@ -65,8 +78,21 @@ export async function hostMain({ log(HostMessage.ADD_SERVER_DIRECTORY, { url: serverDirectory.baseUrl }); setServerOptionsInTestPlan(plan, { baseUrl: serverDirectory.baseUrl }); - log(HostMessage.START_AGENT); - // await agent.start({ referenceBaseUrl: serverDirectory.baseUrl }); + const emitter = new EventEmitter(); + const runner = await createRunner({ + log: console.log, + abortSignal: new Promise(resolve => { + emitter.on(HostMessage.STOP_RUNNER, () => resolve()); + }), + baseUrl: serverDirectory.baseUrl, + mock: agentMockOptions({ + mock: agentMock, + mockOpenPage: agentMockOpenPage, + }), + webDriverUrl: agentWebDriverUrl, + webDriverBrowser: agentWebDriverBrowser, + atDriverUrl: agentAtDriverUrl, + }); let lastCallbackRequest = Promise.resolve(); @@ -137,7 +163,9 @@ export async function hostMain({ log(HostMessage.STOP_AGENT); await lastCallbackRequest; - // await agent.stop(); + + emitter.emit(HostMessage.STOP_RUNNER); + await emitPlanResults(plan); } diff --git a/src/host/messages.js b/src/host/messages.js index b8e40af..d637d8a 100644 --- a/src/host/messages.js +++ b/src/host/messages.js @@ -34,6 +34,8 @@ export const HostMessage = { AGENT_PROTOCOL: 'agentProtocol', /** @type {'stopAgent'} */ STOP_AGENT: 'stopAgent', + /** @type {'stopRunner'} */ + STOP_RUNNER: 'stopRunner', /** @type {'agentLog'} */ AGENT_LOG: 'agentLog', /** @type {'agentCrashed'} */ From d1ed94a91b46a12c0ab567aab72ac1053d4484dc Mon Sep 17 00:00:00 2001 From: Chris Cuellar <58723+ChrisC@users.noreply.github.com> Date: Thu, 25 Jul 2024 13:20:39 -0700 Subject: [PATCH 03/18] [minor] more times option merge cleanup --- src/agent/create-test-runner.js | 7 +++---- src/host/main.js | 4 ++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/agent/create-test-runner.js b/src/agent/create-test-runner.js index 8e3e83c..1b3db51 100644 --- a/src/agent/create-test-runner.js +++ b/src/agent/create-test-runner.js @@ -24,19 +24,18 @@ import { AgentMessage } from './messages.js'; * @returns {Promise} */ export async function createRunner(options) { - // stubbing this out for now - const abortSignal = options.abortSignal; + const { abortSignal, timesOption } = options; if (options.mock) { return new MockTestRunner({ mock: options.mock, ...options }); } await new Promise(resolve => setTimeout(resolve, 1000)); - const { timesOption } = options; + const [browserDriver, atDriver] = await Promise.all([ createBrowserDriver({ url: options.webDriverUrl, browser: options.webDriverBrowser, - abortSignal: options.abortSignal, + abortSignal, timesOption, }).catch(cause => { throw new Error('Error initializing browser driver', { cause }); diff --git a/src/host/main.js b/src/host/main.js index 7ff78da..ba93993 100644 --- a/src/host/main.js +++ b/src/host/main.js @@ -16,6 +16,7 @@ import { addTestLogToTestPlan, addTestResultToTestPlan, } from './plan-object.js'; +import { getTimesOption } from '../shared/times-option.js'; /** * @param {AriaATCIHost.Log} log @@ -78,12 +79,15 @@ export async function hostMain(options) { log(HostMessage.ADD_SERVER_DIRECTORY, { url: serverDirectory.baseUrl }); setServerOptionsInTestPlan(plan, { baseUrl: serverDirectory.baseUrl }); + const timesOption = getTimesOption(options); + const emitter = new EventEmitter(); const runner = await createRunner({ log: console.log, abortSignal: new Promise(resolve => { emitter.on(HostMessage.STOP_RUNNER, () => resolve()); }), + timesOption, baseUrl: serverDirectory.baseUrl, mock: agentMockOptions({ mock: agentMock, From 93b4d16c7d6233272cb1489ebea2916727287360 Mon Sep 17 00:00:00 2001 From: Chris Cuellar <58723+ChrisC@users.noreply.github.com> Date: Thu, 25 Jul 2024 15:15:37 -0700 Subject: [PATCH 04/18] adds agent messages+templates to host logger --- src/agent/at-driver.js | 2 +- src/agent/create-test-runner.js | 4 ++-- src/host/cli-run-plan.js | 2 +- src/host/main.js | 18 +----------------- src/host/messages.js | 3 ++- src/host/types.js | 7 +++++++ 6 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/agent/at-driver.js b/src/agent/at-driver.js index 51cc518..deae8ed 100644 --- a/src/agent/at-driver.js +++ b/src/agent/at-driver.js @@ -10,7 +10,7 @@ import { AgentMessage } from './messages.js'; * @param {string} [options.url.pathname] * @param {number | string} [options.url.port] * @param {Promise} [options.abortSignal] - * @param {AriaATCIAgent.Log} [options.log] + * @param {AriaATCIHost.Log} [options.log] * @returns {Promise} */ export async function createATDriver({ diff --git a/src/agent/create-test-runner.js b/src/agent/create-test-runner.js index 1b3db51..de6a3eb 100644 --- a/src/agent/create-test-runner.js +++ b/src/agent/create-test-runner.js @@ -24,7 +24,7 @@ import { AgentMessage } from './messages.js'; * @returns {Promise} */ export async function createRunner(options) { - const { abortSignal, timesOption } = options; + const { abortSignal, log, timesOption } = options; if (options.mock) { return new MockTestRunner({ mock: options.mock, ...options }); @@ -43,7 +43,7 @@ export async function createRunner(options) { createATDriver({ url: options.atDriverUrl, abortSignal, - log: console.log, + log, }).catch(cause => { throw new Error('Error connecting to at-driver', { cause }); }), diff --git a/src/host/cli-run-plan.js b/src/host/cli-run-plan.js index 2b5e0ee..44e833a 100644 --- a/src/host/cli-run-plan.js +++ b/src/host/cli-run-plan.js @@ -13,7 +13,7 @@ import { hostMain } from './main.js'; import { HostMessage, createHostLogger } from './messages.js'; import { plansFrom } from './plan-from.js'; import { HostServer } from './server.js'; -import { getTimesOption, timesOptionsConfig } from '../shared/times-option.js'; +import { timesOptionsConfig } from '../shared/times-option.js'; export const command = 'run-plan [plan-files..]'; diff --git a/src/host/main.js b/src/host/main.js index ba93993..a75ed79 100644 --- a/src/host/main.js +++ b/src/host/main.js @@ -64,12 +64,6 @@ export async function hostMain(options) { } = options; log(HostMessage.START); - // const hostLogJob = startJob(async function (signal) { - // for await (const agentLog of signal.cancelable(agent.logs())) { - // log(HostMessage.AGENT_LOG, agentLog); - // } - // }); - await server.ready; log(HostMessage.SERVER_LISTENING, { url: server.baseUrl }); @@ -83,7 +77,7 @@ export async function hostMain(options) { const emitter = new EventEmitter(); const runner = await createRunner({ - log: console.log, + log, abortSignal: new Promise(resolve => { emitter.on(HostMessage.STOP_RUNNER, () => resolve()); }), @@ -122,12 +116,6 @@ export async function hostMain(options) { for (const test of plan.tests) { log(HostMessage.START_TEST); - // const testLogJob = startJob(async function (signal) { - // for await (const testLog of signal.cancelable(agent.logs())) { - // plan = addLogToTestPlan(plan, testLog); - // plan = addTestLogToTestPlan(plan, test); - // } - // }); const file = plan.files.find(({ name }) => name === test.filepath); const testSource = JSON.parse(textDecoder.decode(file.bufferData)); @@ -157,8 +145,6 @@ export async function hostMain(options) { postCallbackWhenEnabled({ ...callbackBody, error, status: 'ERROR' }); await lastCallbackRequest; throw exception; - } finally { - // await testLogJob.cancel(); } } @@ -173,8 +159,6 @@ export async function hostMain(options) { await emitPlanResults(plan); } - // await hostLogJob.cancel(); - log(HostMessage.STOP_SERVER); await server.close(); diff --git a/src/host/messages.js b/src/host/messages.js index d637d8a..43ab280 100644 --- a/src/host/messages.js +++ b/src/host/messages.js @@ -4,6 +4,7 @@ * @module host */ +import { AGENT_TEMPLATES } from '../agent/messages.js'; import { createSharedLogger } from '../shared/messages.js'; /** @enum {AriaATCIHost.HostLogType} */ @@ -75,6 +76,6 @@ export const HOST_TEMPLATES = { * @param {*} messages * @returns {{log: AriaATCIHost.Log, emitter: import("events").EventEmitter}} */ -export function createHostLogger(messages = HOST_TEMPLATES) { +export function createHostLogger(messages = { ...HOST_TEMPLATES, ...AGENT_TEMPLATES }) { return createSharedLogger(messages); } diff --git a/src/host/types.js b/src/host/types.js index da80b73..07afa38 100644 --- a/src/host/types.js +++ b/src/host/types.js @@ -26,6 +26,13 @@ * | 'startTest' * | 'reportingError' * | 'testError' + * | 'atDriverComms' + * | 'openPage' + * | 'pressKeys' + * | 'speechEvent' + * | 'invalidKeys' + * | 'noRunTestSetup' + * | 'capabilities' * } AriaATCIHost.HostLogType */ From 15e94f25e70fabe673383661822dd6ea70f7d74a Mon Sep 17 00:00:00 2001 From: Chris Cuellar <58723+ChrisC@users.noreply.github.com> Date: Thu, 25 Jul 2024 16:43:11 -0700 Subject: [PATCH 05/18] adds more agent messages to host process --- src/agent/mock-test-runner.js | 2 +- src/host/cli-run-plan.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/agent/mock-test-runner.js b/src/agent/mock-test-runner.js index 4dffb0c..2c50ac4 100644 --- a/src/agent/mock-test-runner.js +++ b/src/agent/mock-test-runner.js @@ -22,7 +22,7 @@ export class MockTestRunner { */ constructor({ baseUrl, log, mock: config }) { this.baseUrl = baseUrl; - this.log = console.log; + this.log = log; this.config = config; } diff --git a/src/host/cli-run-plan.js b/src/host/cli-run-plan.js index 44e833a..8d2240c 100644 --- a/src/host/cli-run-plan.js +++ b/src/host/cli-run-plan.js @@ -168,7 +168,7 @@ async function verboseMiddleware(argv) { let verbosity; if (debug) { - verbosity = Object.values(HostMessage); + verbosity = Object.values({ ...HostMessage, ...AgentMessage }); } else if (quiet) { verbosity = []; } else { @@ -181,6 +181,8 @@ async function verboseMiddleware(argv) { HostMessage.SERVER_LISTENING, HostMessage.ADD_SERVER_DIRECTORY, HostMessage.REMOVE_SERVER_DIRECTORY, + AgentMessage.OPEN_PAGE, + AgentMessage.UNCAUGHT_ERROR, ]; } From 2777e89772dbc441e5fcc5d0df88ac293756210b Mon Sep 17 00:00:00 2001 From: Chris Cuellar <58723+ChrisC@users.noreply.github.com> Date: Tue, 30 Jul 2024 10:28:11 -0700 Subject: [PATCH 06/18] adds back missing agent logs to test plan log records --- src/host/cli-run-plan.js | 1 + src/host/main.js | 20 +++++++++++++++----- src/host/types.js | 6 ++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/host/cli-run-plan.js b/src/host/cli-run-plan.js index 8d2240c..1937bad 100644 --- a/src/host/cli-run-plan.js +++ b/src/host/cli-run-plan.js @@ -227,6 +227,7 @@ function mainLoggerMiddleware(argv) { const logger = createHostLogger(); argv.log = logger.log; + argv.logger = logger; logger.emitter.on('message', ({ data: { type }, text }) => { if (verbosity.includes(type)) { diff --git a/src/host/main.js b/src/host/main.js index a75ed79..c3ab576 100644 --- a/src/host/main.js +++ b/src/host/main.js @@ -17,6 +17,7 @@ import { addTestResultToTestPlan, } from './plan-object.js'; import { getTimesOption } from '../shared/times-option.js'; +import { AGENT_TEMPLATES } from '../agent/messages.js'; /** * @param {AriaATCIHost.Log} log @@ -33,7 +34,7 @@ const logUnsuccessfulHTTP = async (log, response) => { /** * @param {object} options - * @param {AriaATCIHost.Log} options.log + * @param {AriaATCIHost.Logger} options.logger * @param {AsyncIterable} options.plans * @param {AriaATCIHost.ReferenceFileServer} options.server * @param {AriaATCIAgent.TestRunner} options.runner @@ -49,7 +50,7 @@ const logUnsuccessfulHTTP = async (log, response) => { */ export async function hostMain(options) { const { - log, + logger, plans, server, emitPlanResults, @@ -62,6 +63,7 @@ export async function hostMain(options) { agentWebDriverBrowser, agentAtDriverUrl, } = options; + const { log } = logger; log(HostMessage.START); await server.ready; @@ -115,8 +117,6 @@ export async function hostMain(options) { }; for (const test of plan.tests) { - log(HostMessage.START_TEST); - const file = plan.files.find(({ name }) => name === test.filepath); const testSource = JSON.parse(textDecoder.decode(file.bufferData)); @@ -124,6 +124,15 @@ export async function hostMain(options) { const callbackBody = presentationNumber ? { presentationNumber } : { testCsvRow }; + log(HostMessage.START_TEST, { id: testSource.info.testId, title: testSource.info.title }); + const addLogtoPlan = message => { + if (Object.keys(AGENT_TEMPLATES).includes(message.data.type)) { + plan = addLogToTestPlan(plan, message); + plan = addTestLogToTestPlan(plan, test); + } + }; + logger.emitter.on('message', addLogtoPlan); + try { postCallbackWhenEnabled({ ...callbackBody, status: 'RUNNING' }); @@ -145,13 +154,14 @@ export async function hostMain(options) { postCallbackWhenEnabled({ ...callbackBody, error, status: 'ERROR' }); await lastCallbackRequest; throw exception; + } finally { + logger.emitter.off('message', addLogtoPlan); } } server.removeFiles(serverDirectory); log(HostMessage.REMOVE_SERVER_DIRECTORY, { url: serverDirectory.baseUrl }); - log(HostMessage.STOP_AGENT); await lastCallbackRequest; emitter.emit(HostMessage.STOP_RUNNER); diff --git a/src/host/types.js b/src/host/types.js index 07afa38..36a7ad5 100644 --- a/src/host/types.js +++ b/src/host/types.js @@ -40,6 +40,12 @@ * @typedef {AriaATCIShared.Log} AriaATCIHost.Log */ +/** + * @typedef AriaATCIHost.Logger + * @property {AriaATCIHost.Log} log + * @property {import("events").EventEmitter} emitter + */ + /** * @typedef {AriaATCIAgent.Log} AriaATCIHost.AgentLog */ From b49640d97164cbcb87c7ccdc629cb1de02344267 Mon Sep 17 00:00:00 2001 From: Chris Cuellar <58723+ChrisC@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:56:32 -0700 Subject: [PATCH 07/18] updates snapshot tests --- package.json | 1 + src/host/tests/agent.js | 171 ------------------ src/host/tests/snapshots/cli-run-plan.js.md | 105 ++++------- src/host/tests/snapshots/cli-run-plan.js.snap | Bin 1428 -> 1408 bytes src/host/tests/snapshots/messages.js.md | 6 +- src/host/tests/snapshots/messages.js.snap | Bin 1041 -> 1194 bytes 6 files changed, 40 insertions(+), 243 deletions(-) delete mode 100644 src/host/tests/agent.js diff --git a/package.json b/package.json index 3bceac3..b0fbd90 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "test": "npm run test:types && npm run test:unit", "test:types": "tsc", "test:unit": "ava", + "test:update": "ava --update-snapshots", "postinstall": "husky install" }, "lint-staged": { diff --git a/src/host/tests/agent.js b/src/host/tests/agent.js deleted file mode 100644 index 4c61fdb..0000000 --- a/src/host/tests/agent.js +++ /dev/null @@ -1,171 +0,0 @@ -/// - -import test from 'ava'; - -import { iterateEmitter } from '../../shared/iterate-emitter.js'; -import { startJob } from '../../shared/job.js'; -import { AgentMessage } from '../../agent/messages.js'; - -import { AgentController } from '../agent.js'; -import { createHostLogger, HostMessage } from '../messages.js'; - -test('new AgentController(options)', async t => { - t.timeout(60000); - const TEST_DEFINITIONS = []; - for (const tests of createTests()) { - for (const protocol of /**@type {('fork'|'developer')[]}*/ ([undefined, 'fork', 'developer'])) { - for (const config of [ - {}, - { debug: true }, - { verbose: [AgentMessage.START] }, - { - referenceBaseUrl: { - protocol: 'http:', - hostname: 'localhost', - port: 1234, - pathname: '/path', - toString() { - return `${this.protocol}//${this.hostname}:${this.port}${this.pathname}`; - }, - }, - }, - ]) { - TEST_DEFINITIONS.push({ - tests, - options: { protocol, config }, - }); - } - } - } - - t.log(`${TEST_DEFINITIONS.length} definitions`); - t.is(TEST_DEFINITIONS.length, 36); - - for (const testDefinition of TEST_DEFINITIONS) { - const { log, emitter } = createHostLogger(); - const logJob = startJob(async ({ cancelable }) => { - const logs = []; - for await (const log of cancelable(iterateEmitter(emitter, 'message', 'exit', 'error'))) { - logs.push(omitDates(log)); - } - return logs; - }); - - const controller = new AgentController({ - log, - ...(testDefinition.options.protocol && { - protocol: testDefinition.options.protocol, - }), - config: { - ...testDefinition.options.config, - mock: true, - mockOpenPage: 'skip', - }, - }); - - const agentLogJob = startJob(async ({ cancelable }) => { - for await (const message of cancelable(controller.logs())) { - log(HostMessage.AGENT_LOG, message); - } - }); - - await controller.start(); - - for (const test of testDefinition.tests) { - t.snapshot( - await controller.run(test), - `${snapshotPrefix(testDefinition)}: controller.run(${test.info.title})` - ); - } - - await controller.stop(); - await agentLogJob.cancel(); - const fullLog = await logJob.cancel(); - t.snapshot(fullLog, `${snapshotPrefix(testDefinition)}: log`); - } -}); - -/** - * @returns {AriaATCIData.CollectedTest[][]} - */ -function createTests() { - return [ - [], - [ - { - info: { testId: 1, title: 'test 1', task: 'test', references: [] }, - target: { - at: { key: 'at', name: 'At', raw: 'AT' }, - mode: 'reading', - referencePage: 'reference/index.html', - }, - instructions: { raw: '', user: [] }, - commands: [ - { - id: 'UP_ARROW', - keystroke: 'up arrow', - keypresses: [{ id: 'UP_ARROW', keystroke: 'up arrow' }], - }, - ], - assertions: [{ expectation: 'role up', priority: 1 }], - }, - ], - [ - { - info: { testId: 1, title: 'test 1', task: 'test', references: [] }, - target: { - at: { key: 'at', name: 'At', raw: 'AT' }, - mode: 'reading', - referencePage: 'reference/index.html', - }, - instructions: { raw: '', user: [] }, - commands: [ - { - id: 'UP_ARROW', - keystroke: 'up arrow', - keypresses: [{ id: 'UP_ARROW', keystroke: 'up arrow' }], - }, - ], - assertions: [{ expectation: 'role up', priority: 1 }], - }, - { - info: { testId: 2, title: 'test 2', task: 'interaction', references: [] }, - target: { - at: { key: 'at', name: 'At', raw: 'AT' }, - mode: 'interaction', - referencePage: 'reference/index.html', - }, - instructions: { raw: '', user: [] }, - commands: [ - { - id: 'UP_ARROW,DOWN_ARROW', - keystroke: 'up arrow, then down arrow', - keypresses: [ - { id: 'UP_ARROW', keystroke: 'up arrow' }, - { id: 'DOWN_ARROW', keystroke: 'down arrow' }, - ], - }, - ], - assertions: [{ expectation: 'role down', priority: 1 }], - }, - ], - ]; -} - -function snapshotPrefix({ tests, options }) { - return JSON.stringify({ tests: tests.map(test => test.info.testId), options }); -} - -function omitDates(obj) { - if (Array.isArray(obj)) { - return obj.map(omitDates); - } - if (typeof obj === 'object' && obj !== null) { - return Object.fromEntries( - Object.entries(obj) - .map(([key, value]) => (key === 'date' ? null : [key, omitDates(value)])) - .filter(Boolean) - ); - } - return obj; -} diff --git a/src/host/tests/snapshots/cli-run-plan.js.md b/src/host/tests/snapshots/cli-run-plan.js.md index 86dccb8..028747d 100644 --- a/src/host/tests/snapshots/cli-run-plan.js.md +++ b/src/host/tests/snapshots/cli-run-plan.js.md @@ -13,22 +13,17 @@ Generated by [AVA](https://avajs.dev). Reference server listening on 'http://localhost:8888'.␊ Plan 'unknown' with 2 tests and 3 files read from source 'fork'.␊ Reference available on 'http://localhost:8888/static␊ - Starting test agent.␊ - [Agent]: Starting...␊ - Agent running with protocol 'fork'.␊ - Starting test.␊ + Starting test #1 'test 1'.␊ [Server]: Serving '/static/index.html'.␊ - [Agent]: Open page: 'http://localhost:8888/static/index.html'.␊ - Starting test.␊ + Open page: 'http://localhost:8888/static/index.html'.␊ + Starting test #2 'test 2'.␊ [Server]: Serving '/static/index.html'.␊ - [Agent]: Open page: 'http://localhost:8888/static/index.html'.␊ + Open page: 'http://localhost:8888/static/index.html'.␊ Removing reference from 'http://localhost:8888/static␊ - Stopping test agent.␊ - [Agent]: Stopping...␊ Stopping reference server.␊ Stopping...␊ `, - stdout: `{"name":"unknown","tests":[{"filepath":"test-1.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/index.html'."}],"results":[{"testId":1,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW","output":"mocked output for UP_ARROW"}],"results":[{"command":"UP_ARROW","expectation":"role up","pass":true,"output":"mocked output for role up"}]}]},{"filepath":"test-2.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/index.html'."}],"results":[{"testId":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW,DOWN_ARROW","output":"mocked output for UP_ARROW,DOWN_ARROW"}],"results":[{"command":"UP_ARROW,DOWN_ARROW","expectation":"role down","pass":true,"output":"mocked output for role down"}]}]}],"log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/index.html'."},{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/index.html'."}]}␊ + stdout: `{"name":"unknown","tests":[{"filepath":"test-1.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/index.html"},"text":"Open page: 'http://localhost:8888/static/index.html'."}],"results":[{"testId":1,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW","output":"mocked output for UP_ARROW"}],"results":[{"command":"UP_ARROW","expectation":"role up","pass":true,"output":"mocked output for role up"}]}]},{"filepath":"test-2.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/index.html"},"text":"Open page: 'http://localhost:8888/static/index.html'."}],"results":[{"testId":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW,DOWN_ARROW","output":"mocked output for UP_ARROW,DOWN_ARROW"}],"results":[{"command":"UP_ARROW,DOWN_ARROW","expectation":"role down","pass":true,"output":"mocked output for role down"}]}]}],"log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/index.html"},"text":"Open page: 'http://localhost:8888/static/index.html'."},{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/index.html"},"text":"Open page: 'http://localhost:8888/static/index.html'."}]}␊ `, } @@ -41,22 +36,17 @@ Generated by [AVA](https://avajs.dev). Reference server listening on 'http://localhost:8888'.␊ Plan 'unknown' with 2 tests and 4 files read from source 'fork'.␊ Reference available on 'http://localhost:8888/static␊ - Starting test agent.␊ - [Agent]: Starting...␊ - Agent running with protocol 'fork'.␊ - Starting test.␊ + Starting test #1 'test 1'.␊ [Server]: Serving '/static/reference/index.html'.␊ - [Agent]: Open page: 'http://localhost:8888/static/reference/index.html'.␊ - Starting test.␊ + Open page: 'http://localhost:8888/static/reference/index.html'.␊ + Starting test #2 'test 2'.␊ [Server]: Serving '/static/reference/index.html'.␊ - [Agent]: Open page: 'http://localhost:8888/static/reference/index.html'.␊ + Open page: 'http://localhost:8888/static/reference/index.html'.␊ Removing reference from 'http://localhost:8888/static␊ - Stopping test agent.␊ - [Agent]: Stopping...␊ Stopping reference server.␊ Stopping...␊ `, - stdout: `{"name":"unknown","tests":[{"filepath":"test-1.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":1,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW","output":"mocked output for UP_ARROW"}],"results":[{"command":"UP_ARROW","expectation":"role up","pass":true,"output":"mocked output for role up"}]}]},{"filepath":"test-2.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW,DOWN_ARROW","output":"mocked output for UP_ARROW,DOWN_ARROW"}],"results":[{"command":"UP_ARROW,DOWN_ARROW","expectation":"role down","pass":true,"output":"mocked output for role down"}]}]}],"log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."},{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}]}␊ + stdout: `{"name":"unknown","tests":[{"filepath":"test-1.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":1,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW","output":"mocked output for UP_ARROW"}],"results":[{"command":"UP_ARROW","expectation":"role up","pass":true,"output":"mocked output for role up"}]}]},{"filepath":"test-2.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW,DOWN_ARROW","output":"mocked output for UP_ARROW,DOWN_ARROW"}],"results":[{"command":"UP_ARROW,DOWN_ARROW","expectation":"role down","pass":true,"output":"mocked output for role down"}]}]}],"log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."},{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}]}␊ `, } @@ -69,22 +59,17 @@ Generated by [AVA](https://avajs.dev). Reference server listening on 'http://localhost:8888'.␊ Plan 'unknown' with 2 tests and 4 files read from source 'fork'.␊ Reference available on 'http://localhost:8888/static␊ - Starting test agent.␊ - [Agent]: Starting...␊ - Agent running with protocol 'fork'.␊ - Starting test.␊ + Starting test #1 'test 1'.␊ [Server]: Serving '/static/reference/index.html'.␊ - [Agent]: Open page: 'http://localhost:8888/static/reference/index.html'.␊ - Starting test.␊ + Open page: 'http://localhost:8888/static/reference/index.html'.␊ + Starting test #2 'test 2'.␊ [Server]: Serving '/static/reference/index.html'.␊ - [Agent]: Open page: 'http://localhost:8888/static/reference/index.html'.␊ + Open page: 'http://localhost:8888/static/reference/index.html'.␊ Removing reference from 'http://localhost:8888/static␊ - Stopping test agent.␊ - [Agent]: Stopping...␊ Stopping reference server.␊ Stopping...␊ `, - stdout: `{"name":"unknown","tests":[{"filepath":"tests/test-1.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":1,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW","output":"mocked output for UP_ARROW"}],"results":[{"command":"UP_ARROW","expectation":"role up","pass":true,"output":"mocked output for role up"}]}]},{"filepath":"tests/test-2.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW,DOWN_ARROW","output":"mocked output for UP_ARROW,DOWN_ARROW"}],"results":[{"command":"UP_ARROW,DOWN_ARROW","expectation":"role down","pass":true,"output":"mocked output for role down"}]}]}],"log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."},{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}]}␊ + stdout: `{"name":"unknown","tests":[{"filepath":"tests/test-1.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":1,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW","output":"mocked output for UP_ARROW"}],"results":[{"command":"UP_ARROW","expectation":"role up","pass":true,"output":"mocked output for role up"}]}]},{"filepath":"tests/test-2.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW,DOWN_ARROW","output":"mocked output for UP_ARROW,DOWN_ARROW"}],"results":[{"command":"UP_ARROW,DOWN_ARROW","expectation":"role down","pass":true,"output":"mocked output for role down"}]}]}],"log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."},{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}]}␊ `, } @@ -97,18 +82,13 @@ Generated by [AVA](https://avajs.dev). Reference server listening on 'http://localhost:8888'.␊ Plan 'unknown' with 2 tests and 4 files read from source 'fork'.␊ Reference available on 'http://localhost:8888/static␊ - Starting test agent.␊ - [Agent]: Starting...␊ - Agent running with protocol 'fork'.␊ - Starting test.␊ + Starting test #1 'test 1'.␊ [Server]: Serving '/static/reference/index.html'.␊ - [Agent]: Open page: 'http://localhost:8888/static/reference/index.html'.␊ - Starting test.␊ + Open page: 'http://localhost:8888/static/reference/index.html'.␊ + Starting test #2 'test 2'.␊ [Server]: Serving '/static/reference/index.html'.␊ - [Agent]: Open page: 'http://localhost:8888/static/reference/index.html'.␊ + Open page: 'http://localhost:8888/static/reference/index.html'.␊ Removing reference from 'http://localhost:8888/static␊ - Stopping test agent.␊ - [Agent]: Stopping...␊ Stopping reference server.␊ Stopping...␊ `, @@ -132,7 +112,7 @@ Generated by [AVA](https://avajs.dev). body: '{"testCsvRow":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"status":"COMPLETED","responses":["mocked output for UP_ARROW,DOWN_ARROW"]}',␊ headers: { 'Content-Type': 'application/json', test: 'header:multiple:colon' }␊ }␊ - {"name":"unknown","tests":[{"filepath":"tests/test-1.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":1,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW","output":"mocked output for UP_ARROW"}],"results":[{"command":"UP_ARROW","expectation":"role up","pass":true,"output":"mocked output for role up"}]}]},{"filepath":"tests/test-2.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW,DOWN_ARROW","output":"mocked output for UP_ARROW,DOWN_ARROW"}],"results":[{"command":"UP_ARROW,DOWN_ARROW","expectation":"role down","pass":true,"output":"mocked output for role down"}]}]}],"log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."},{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}]}␊ + {"name":"unknown","tests":[{"filepath":"tests/test-1.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":1,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW","output":"mocked output for UP_ARROW"}],"results":[{"command":"UP_ARROW","expectation":"role up","pass":true,"output":"mocked output for role up"}]}]},{"filepath":"tests/test-2.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW,DOWN_ARROW","output":"mocked output for UP_ARROW,DOWN_ARROW"}],"results":[{"command":"UP_ARROW,DOWN_ARROW","expectation":"role down","pass":true,"output":"mocked output for role down"}]}]}],"log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."},{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}]}␊ `, } @@ -145,18 +125,13 @@ Generated by [AVA](https://avajs.dev). Reference server listening on 'http://localhost:8888'.␊ Plan 'unknown' with 2 tests and 4 files read from source 'fork'.␊ Reference available on 'http://localhost:8888/static␊ - Starting test agent.␊ - [Agent]: Starting...␊ - Agent running with protocol 'fork'.␊ - Starting test.␊ + Starting test #1 'test 1'.␊ [Server]: Serving '/static/reference/index.html'.␊ - [Agent]: Open page: 'http://localhost:8888/static/reference/index.html'.␊ - Starting test.␊ + Open page: 'http://localhost:8888/static/reference/index.html'.␊ + Starting test #2 'test 2'.␊ [Server]: Serving '/static/reference/index.html'.␊ - [Agent]: Open page: 'http://localhost:8888/static/reference/index.html'.␊ + Open page: 'http://localhost:8888/static/reference/index.html'.␊ Removing reference from 'http://localhost:8888/static␊ - Stopping test agent.␊ - [Agent]: Stopping...␊ Stopping reference server.␊ Stopping...␊ `, @@ -180,7 +155,7 @@ Generated by [AVA](https://avajs.dev). body: '{"testCsvRow":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"status":"COMPLETED","responses":["mocked output for UP_ARROW,DOWN_ARROW"]}',␊ headers: { 'Content-Type': 'application/json', test: 'header:multiple:colon' }␊ }␊ - {"name":"unknown","tests":[{"filepath":"tests/test-1.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":1,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW","output":"mocked output for UP_ARROW"}],"results":[{"command":"UP_ARROW","expectation":"role up","pass":true,"output":"mocked output for role up"}]}]},{"filepath":"tests/test-2.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW,DOWN_ARROW","output":"mocked output for UP_ARROW,DOWN_ARROW"}],"results":[{"command":"UP_ARROW,DOWN_ARROW","expectation":"role down","pass":true,"output":"mocked output for role down"}]}]}],"log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."},{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}]}␊ + {"name":"unknown","tests":[{"filepath":"tests/test-1.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":1,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW","output":"mocked output for UP_ARROW"}],"results":[{"command":"UP_ARROW","expectation":"role up","pass":true,"output":"mocked output for role up"}]}]},{"filepath":"tests/test-2.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW,DOWN_ARROW","output":"mocked output for UP_ARROW,DOWN_ARROW"}],"results":[{"command":"UP_ARROW,DOWN_ARROW","expectation":"role down","pass":true,"output":"mocked output for role down"}]}]}],"log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."},{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}]}␊ `, } @@ -193,22 +168,17 @@ Generated by [AVA](https://avajs.dev). Reference server listening on 'http://localhost:8888'.␊ Plan 'unknown' with 2 tests and 4 files read from source 'fork'.␊ Reference available on 'http://localhost:8888/static␊ - Starting test agent.␊ - [Agent]: Starting...␊ - Agent running with protocol 'fork'.␊ - Starting test.␊ + Starting test #1 'test 1'.␊ HTTP 418 response received when reporting result: 'a body'.␊ [Server]: Serving '/static/reference/index.html'.␊ - [Agent]: Open page: 'http://localhost:8888/static/reference/index.html'.␊ - Starting test.␊ + Open page: 'http://localhost:8888/static/reference/index.html'.␊ + Starting test #2 'test 2'.␊ HTTP 418 response received when reporting result: 'a body'.␊ HTTP 418 response received when reporting result: 'a body'.␊ [Server]: Serving '/static/reference/index.html'.␊ - [Agent]: Open page: 'http://localhost:8888/static/reference/index.html'.␊ + Open page: 'http://localhost:8888/static/reference/index.html'.␊ Removing reference from 'http://localhost:8888/static␊ - Stopping test agent.␊ HTTP 418 response received when reporting result: 'a body'.␊ - [Agent]: Stopping...␊ Stopping reference server.␊ Stopping...␊ `, @@ -232,7 +202,7 @@ Generated by [AVA](https://avajs.dev). body: '{"testCsvRow":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"status":"COMPLETED","responses":["mocked output for UP_ARROW,DOWN_ARROW"]}',␊ headers: { 'Content-Type': 'application/json', x: 'y' }␊ }␊ - {"name":"unknown","tests":[{"filepath":"tests/test-1.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":1,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW","output":"mocked output for UP_ARROW"}],"results":[{"command":"UP_ARROW","expectation":"role up","pass":true,"output":"mocked output for role up"}]}]},{"filepath":"tests/test-2.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW,DOWN_ARROW","output":"mocked output for UP_ARROW,DOWN_ARROW"}],"results":[{"command":"UP_ARROW,DOWN_ARROW","expectation":"role down","pass":true,"output":"mocked output for role down"}]}]}],"log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."},{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}]}␊ + {"name":"unknown","tests":[{"filepath":"tests/test-1.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":1,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW","output":"mocked output for UP_ARROW"}],"results":[{"command":"UP_ARROW","expectation":"role up","pass":true,"output":"mocked output for role up"}]}]},{"filepath":"tests/test-2.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW,DOWN_ARROW","output":"mocked output for UP_ARROW,DOWN_ARROW"}],"results":[{"command":"UP_ARROW,DOWN_ARROW","expectation":"role down","pass":true,"output":"mocked output for role down"}]}]}],"log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."},{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}]}␊ `, } @@ -245,22 +215,17 @@ Generated by [AVA](https://avajs.dev). Reference server listening on 'http://localhost:8888'.␊ Plan 'unknown' with 2 tests and 4 files read from source 'fork'.␊ Reference available on 'http://localhost:8888/static␊ - Starting test agent.␊ - [Agent]: Starting...␊ - Agent running with protocol 'fork'.␊ - Starting test.␊ + Starting test #1 'test 1'.␊ HTTP 418 response received when reporting result: 'Unknown error - unable to read response body.'.␊ [Server]: Serving '/static/reference/index.html'.␊ - [Agent]: Open page: 'http://localhost:8888/static/reference/index.html'.␊ - Starting test.␊ + Open page: 'http://localhost:8888/static/reference/index.html'.␊ + Starting test #2 'test 2'.␊ HTTP 418 response received when reporting result: 'Unknown error - unable to read response body.'.␊ HTTP 418 response received when reporting result: 'Unknown error - unable to read response body.'.␊ [Server]: Serving '/static/reference/index.html'.␊ - [Agent]: Open page: 'http://localhost:8888/static/reference/index.html'.␊ + Open page: 'http://localhost:8888/static/reference/index.html'.␊ Removing reference from 'http://localhost:8888/static␊ - Stopping test agent.␊ HTTP 418 response received when reporting result: 'Unknown error - unable to read response body.'.␊ - [Agent]: Stopping...␊ Stopping reference server.␊ Stopping...␊ `, @@ -284,6 +249,6 @@ Generated by [AVA](https://avajs.dev). body: '{"testCsvRow":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"status":"COMPLETED","responses":["mocked output for UP_ARROW,DOWN_ARROW"]}',␊ headers: { 'Content-Type': 'application/json', x: 'y' }␊ }␊ - {"name":"unknown","tests":[{"filepath":"tests/test-1.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":1,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW","output":"mocked output for UP_ARROW"}],"results":[{"command":"UP_ARROW","expectation":"role up","pass":true,"output":"mocked output for role up"}]}]},{"filepath":"tests/test-2.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW,DOWN_ARROW","output":"mocked output for UP_ARROW,DOWN_ARROW"}],"results":[{"command":"UP_ARROW,DOWN_ARROW","expectation":"role down","pass":true,"output":"mocked output for role down"}]}]}],"log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."},{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":{}},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}]}␊ + {"name":"unknown","tests":[{"filepath":"tests/test-1.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":1,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW","output":"mocked output for UP_ARROW"}],"results":[{"command":"UP_ARROW","expectation":"role up","pass":true,"output":"mocked output for role up"}]}]},{"filepath":"tests/test-2.json","log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}],"results":[{"testId":2,"capabilities":{"browserName":"mock","browserVersion":"1.0","atName":"mock","atVersion":"1.0","platformName":"mock"},"commands":[{"command":"UP_ARROW,DOWN_ARROW","output":"mocked output for UP_ARROW,DOWN_ARROW"}],"results":[{"command":"UP_ARROW,DOWN_ARROW","expectation":"role down","pass":true,"output":"mocked output for role down"}]}]}],"log":[{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."},{"data":{"type":"openPage","date":"2000-01-01T12:00:00.000Z","url":"http://localhost:8888/static/reference/index.html"},"text":"Open page: 'http://localhost:8888/static/reference/index.html'."}]}␊ `, } diff --git a/src/host/tests/snapshots/cli-run-plan.js.snap b/src/host/tests/snapshots/cli-run-plan.js.snap index b1aa4128f5873bedc16b2c369ce919770f5317a5..bf2cdb566d78e54af6277d64f00c36f26da09362 100644 GIT binary patch literal 1408 zcmV-`1%LWMRzVIOte zSKA1+0}Qb@w#W6115w09ueMSjqS`)3AE1|&+V^SC*uX;KO#*~~=@6p$7P%)>sjC}%&vZM87RuQn^|nGZAKqiibc2K?QD-yhd9 znNO9CPn3;v<27k=MHyahZEaVTsz`8;I?w30I+9V)elORTda}prOW}JBN7Eupr7U#ZMD1gJ*u_)u_4tz8{TLGVu7J6qM?RXmM z*xW(};)HRAu-8J{sBJrhp@85PY6sLsjD`V>qP1yorj3q^&#~>`hC|*zV1aSW?Phl1 zcr+0Dtc0}aq6Gb&97XQeO(ZUajn;2fu)P-P>K1n$uq*q-Lq0ww=FMY`x4JU0(I42D z`@mJ=(x}s5n6D_Cx8;fY{&=f+cJ<*aG4}~|LPI{NlfNEasvdTUYO4KtRJ!>W05 zsfzjaF}L8gc$hEguNf644n2(wL=mgzrOGdS(FcY2D-b?dz#H+zC>D$PVhO&rl3^B$ z@YUhb_h1nQ4j9}qO=?g0)#cD)swAtudQJ@p3!Q#wBA(|h)hy-ICiZc|c5H4FCW2`M zv;(O;jPv5cItFk155FS;vmphhTGET~81r#6%&%I&%IB~i+)+CSrb%5F7E$a>{{~(k zSAN*7R?9D;Axx7W@_rN2Lh(IYE+3Gk**Ir2c#tODxk0mLtl7?8MNX-NNyZ# z(4bd`pWOALFjlW9jO8qf+^TBSCQdnIt%VnOSfYA3|_ET_V9TJawm30Pkr(od}teGYb?ZXk)2`Nm9b5S-#1M zmttjQ#L9vSMGBZS3z&Hq&HP2p+{=Dk=xiqloqwdzkwRzrg-&iFp~DJN?kxNiOOM>? zmx~lVQuIjClllnWiJmTsR8K4%pbMvgn`g+Q2)u+L0_@T5Uo7jPe+4SVdoN;{F95RQhh z4XV}S!^7u?U#q>y+=8-#z1~EZNZX?x6fDozV3W|G5A6Gn-HdkBf;dLCTr@)>u~942 zh0WRa9bz`A1Fump+nZ+y3pwJ3dD|<$sC;`+JJ?sFbIGS36K{mgpsQ_3SCX!lpRRtLNOG1|0Iw#EA$7WW zDfr4*0l=CxhSXJxBrHi-lCV-zE|Rb$Vf{Y{tE(mbH!C1Ng+iitEE^8)Hed%!z^;Fj zu&cX1D|VsvRm84uYPAY_TG~May#NW&81Dr$Pj3_6q>EipjyjwGg)eIdN45M>ZMSxO^o8(x5zyI%#}{{EhI@29bp$ab zHavWC?+q~*;(F@pVs^3|$+JXAiI5T@B|=Jsln8lOgxtF$LdF&tZlHoL-sxj;5?{y5 zkN!@=%O@YqikE*#yo{;iIQAYvZeXe9QRqcpa2k6(Ha+?ZQ0S!bu4GCdjAz5Cng~Xb;_sz5dZ0qLmOzlK_=y961hE z2^JdL=5}-4sho`XgTv&aNy1rap20Iz==1zwrj_mq>hu=YbHMw@9dkI z_ujmj`F@mF?S?~}NBpPPMA*V1#CNb)vbl$SZc)KszG}6wz|ZeLTuHr?l3(fj>6J44 zU5DR4GO5%@>3bih?^PNvNK>TK!;h=0tEu#ZR63JNe*iX_kJBru^j&z(MT;=jf6RQJ z*%O!v+dDK2BU>eH!id)-h!b{97;Oa$&B+mu_Tt!Dplg z-jPQ;o{l=UuuvHZ!UadzYoSM|Z99Y`MsN$Y8Fdk-0fSleHf2Zp=)CwC+YW9x zTwq~0vjfM&i4Z;{o-ncp8}e`6M5AGaZHNV47)j`!�hH>I_{N8x6+U3lks*f)BD? z@6TJXy%y;jmT(zD-v9RE^Y|NL87o18HhaQFo za@%O;sU}W*IR=GH?Sj)_0dHhWxmYabizWD}mC9zZ2tNiieGL`?bD(RlCnxL*u)R{A zwO&1^F~S3<@3VCDNlP|o#E*uHqM!)eZ!nh5wnOeyx zLNgZQW>}oHfI~z;UAv=p5KNQ0F6_t1nf?R3-rxOpqgt&zgN~4YKM?&cq=lkq1Y@D0 z)!C?G2O?b`4k1WM=oO=|p#xufhB@>SEFc$7Ht5i+!*_0SwaW=w?eb!-c5bWkY-gH< zAMJ2?4U7*TQx2_YM^94_VVAHZ>Wj7Vxy5j!-ph{4h;odKIF6GM|IREUUf+g{SX(L? zF}xdRz1q(iXmLDAgxvThk#ZwG<4SleyYQHD-IWAcLJ4wS4a`l9oLiLRvgA>WEcrpn z5+zHNESZ!g)>N{D7nC^p|B93T>MMz&B#M$KSCuGT6l#>{9)%&C25uf9k0O{9reN5e zlrQi7rR0l}FG{{l%9r2X-5hM8&xmMR=xKOnnF#g09PBUywpRh2W)X6UuqasQKKQQZ zprt`uC-5BI6`TCHN;{!ikRb(dENa#Lot-B;pKHC)+=4=ev)@FgNZ+I$Y!Q*K!6~D| z7})n6yBVIa1$j&AxiArO3Bq2c3x~DsJH&+YgV(5+?PYH;gt=UK!@O-)p6-6RUEAK$ z!h6c69+z$$T%>dA2}^Q0`E@ccX*5fnj0&5ZDj7vaii{K)DKb)IbSq@UW56heh5lA7 zq*zF?&?F1}J{1dvPjUjO=cOht~yaYHjZ48O46vab|hZGMf9#TBCG(6PRYjizvdjEl(*O<48H#|4hDa`Gb;=lcN7d>6AbQ0@gvACY^6L3yf6+y zqqxTw*ho4vP8;lU=X1UUI(4FM3{?M|1ymn~&yP2@@{cQ9&l8NTGX;`3SeYxtUOm+d ihO{#UlDL{tfU5vk0j>gE1-J Snapshot 3 @@ -166,5 +168,5 @@ Generated by [AVA](https://avajs.dev). data: { type: 'startTest', }, - text: 'Starting test.', + text: 'Starting test #undefined \'undefined\'.', } diff --git a/src/host/tests/snapshots/messages.js.snap b/src/host/tests/snapshots/messages.js.snap index 7a44d3905028afe2f34da0f7f03e666c4521da01..f89222331327d4a58500d52e030628db81cca5f0 100644 GIT binary patch literal 1194 zcmV;b1XcS%RzVxQ! zak82;mYzI2-u>Qu@B8-6c%`uz@p@anb%Uxk6U%aD03`hYsdYK8MB->cNeNk(Wb-Luil2%b_wn zneWdj`npOl4$LVcRLGjuYE`GpzYkA;G@L5GE)`k_y42bDSavGev3=xD=L-rJ1|F@R93IZ+VQE{>8TXBD|j7#t0vzULXdiz1+!H1 z0zio$V?3a>kSQt{iTvb7UlG|}crB(em9?o;wNsCqVl4o73h@ToQV(0K)q!FaOa(^C zbTCeeHDm9bK>42m;CGV^QWVU*NoKimO>DJ~KPS3`e0VU8?fKXC= zP6>m3#P-YnjKM0MgZ8SMzP4Te0`L;&{kp5pv(4}xI&Z&(9BYkt&57Yk7KW$q8jtiy z7?H(@j&NLqM*$Uy=e~zTxAiI=J$F9|0$YHyp@4_DST;l++Q@d#!sMCl+HQX5YqQvIH?et^&6V4iG;!WcTIL<6 z0==1~K!^LAwO%ZSBP~<5S?Ue(rhBsl^l1&6ia+MW?VT*#j+w+*#LR5W<}e9=L=>;{ z2v-_hv=jBe1k`UK{?4v`DFy7WK;w@5H)3jhK6xxr{PwOYo@|o$Lh*fidt4*9=S1yl z7HSV)HktLyKIm#I@+W}w8N?rsulU$7_K3r~Dem3(`bVcyEN3ajnDu^L5ZR)E)%QaH zSasC*K11n@g-vMvpyO8hL;F(aKL^~e-Q5i7E!xAWy$q4^?C1o?0#@=xNGhVtq_{olc|?-)Z(XOwQ6H2=ZV!C#gLVqq zdX!m$bPIJ7|rAQVwcEXbf)bK(2$*YtagY=b#)snW~LRdRfL7s|F0jQ8Th zoQ=>>Gd}^KXVBiyFU~Me)iI|vUNg;WsuA@ub7vCkCO;GbS5An&Pys}9*_I7jCWvl zAutI&=okHf3d||-aFMf7ELfEnD9%^Ik&umtd0mCfFQEJb?JqP8J|BlRh~}+ITF>_y zs!NyVYn*UMMrqybg>1MXV`f!LOEfu+ey<)~D{E>+1xH` zyzk4JJhK=sVe(cA;Fun~8&(P@lPKKtKX_z}_yHLTXp_VhS>RC~W$ptIeNnTt%-lNS zd8PnIeGU&XKB0wdoGo?-VDQL7V>h^XvAcloSh?~bi7R{i=_nhUo;$rcEyR|O!1NVb z+R~N{Tup+`=FFDaoauwX6AN{QET%J?t(>`$#F?!ZO+5yCvF>>K{9uk3UBiM!=LPo# zfWC${wV)H|+=}|G>fI$5TDpDmVn-; zKx6aUthC)sqHUWd#=IKpjaeTiE1XGIU;)k-86Szp#4tnel`ZI%|PKc{Wqd( zd?tDrYmtm`GBJHk17VC!$O} Date: Tue, 30 Jul 2024 15:26:52 -0700 Subject: [PATCH 08/18] fixes types --- src/agent/mock-test-runner.js | 10 ++++++---- src/agent/types.js | 2 +- src/host/main.js | 26 +++++++++++++------------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/agent/mock-test-runner.js b/src/agent/mock-test-runner.js index 2c50ac4..6b7248f 100644 --- a/src/agent/mock-test-runner.js +++ b/src/agent/mock-test-runner.js @@ -62,12 +62,14 @@ export class MockTestRunner { /** * @param {AriaATCIData.CollectedTest} task - * @param {AriaATCIShared.BaseURL} baseUrl */ - async run(task, baseUrl) { - const base = `${baseUrl.protocol}://${baseUrl.hostname}:${baseUrl.port}${baseUrl.pathname}`; + async run(task) { + const base = `${this.baseUrl.protocol}://${this.baseUrl.hostname}:${this.baseUrl.port}${this.baseUrl.pathname}`; await this.openPage( - new URL(`${baseUrl.pathname ? `${baseUrl.pathname}/` : ''}${task.target.referencePage}`, base) + new URL( + `${this.baseUrl.pathname ? `${this.baseUrl.pathname}/` : ''}${task.target.referencePage}`, + base + ) ); const commandsOutput = []; diff --git a/src/agent/types.js b/src/agent/types.js index 14fbea6..d9c36ef 100644 --- a/src/agent/types.js +++ b/src/agent/types.js @@ -28,7 +28,7 @@ /** * @typedef AriaATCIAgent.TestRunner - * @property {function(AriaATCIData.Test, AriaATCIShared.BaseURL): Promise} run run a test + * @property {function(AriaATCIData.Test): Promise} run run a test */ /** diff --git a/src/host/main.js b/src/host/main.js index c3ab576..c14ba4b 100644 --- a/src/host/main.js +++ b/src/host/main.js @@ -7,7 +7,6 @@ import { EventEmitter } from 'events'; import { agentMockOptions } from '../agent/cli.js'; import { createRunner } from '../agent/create-test-runner.js'; -import { startJob } from '../shared/job.js'; import { HostMessage } from './messages.js'; import { @@ -42,11 +41,11 @@ const logUnsuccessfulHTTP = async (log, response) => { * @param {string} [options.callbackUrl] * @param {Record} [options.callbackHeader] * @param {typeof fetch} options.fetch - * @param options.agentMock - * @param options.agentMockOpenPage - * @param options.agentWebDriverUrl - * @param options.agentWebDriverBrowser - * @param options.agentAtDriverUrl + * @param {boolean} options.agentMock + * @param {'request' | 'skip'} options.agentMockOpenPage + * @param {AriaATCIShared.BaseURL} options.agentWebDriverUrl + * @param {AriaATCIAgent.Browser} options.agentWebDriverBrowser + * @param {AriaATCIShared.BaseURL} options.agentAtDriverUrl */ export async function hostMain(options) { const { @@ -56,7 +55,6 @@ export async function hostMain(options) { emitPlanResults, callbackUrl, callbackHeader, - fetch, agentMock, agentMockOpenPage, agentWebDriverUrl, @@ -108,11 +106,13 @@ export async function hostMain(options) { body.presentationNumber ?? body.testCsvRow ); lastCallbackRequest = lastCallbackRequest.then(() => - fetch(perTestUrl, { - method: 'post', - body: JSON.stringify(body), - headers, - }).then(logUnsuccessfulHTTP.bind(null, log)) + options + .fetch(perTestUrl, { + method: 'post', + body: JSON.stringify(body), + headers, + }) + .then(logUnsuccessfulHTTP.bind(null, log)) ); }; @@ -136,7 +136,7 @@ export async function hostMain(options) { try { postCallbackWhenEnabled({ ...callbackBody, status: 'RUNNING' }); - const result = await runner.run(testSource, serverDirectory.baseUrl); + const result = await runner.run(testSource); const { capabilities, commands } = result; From 9616fb2f2a74cf58b5867fbafcdeb89ca10992a3 Mon Sep 17 00:00:00 2001 From: Chris Cuellar <58723+ChrisC@users.noreply.github.com> Date: Wed, 31 Jul 2024 15:36:37 -0700 Subject: [PATCH 09/18] updates snapshots (take 2) --- src/agent/messages.js | 1 - src/host/tests/snapshots/messages.js.md | 4 +--- src/host/tests/snapshots/messages.js.snap | Bin 1194 -> 1069 bytes 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/agent/messages.js b/src/agent/messages.js index ad8a417..1940cea 100644 --- a/src/agent/messages.js +++ b/src/agent/messages.js @@ -35,7 +35,6 @@ export const AgentMessage = { export const AGENT_TEMPLATES = { [AgentMessage.START]: () => `Starting...`, - [AgentMessage.UNCAUGHT_ERROR]: ({ error }) => `Uncaught error: ${error.stack || error.message}`, [AgentMessage.WILL_STOP]: () => `Stopping...`, [AgentMessage.START_TEST]: ({ id, title }) => `Starting test #${id} '${title}'.`, [AgentMessage.OPEN_PAGE]: ({ url }) => `Open page: '${url}'.`, diff --git a/src/host/tests/snapshots/messages.js.md b/src/host/tests/snapshots/messages.js.md index 644afed..20a2bef 100644 --- a/src/host/tests/snapshots/messages.js.md +++ b/src/host/tests/snapshots/messages.js.md @@ -24,9 +24,7 @@ Generated by [AVA](https://avajs.dev). }, type: 'uncaughtError', }, - text: `Uncaught error: Error: Broken␊ - at file:///Users/bip/Dev/aria-at-automation-harness/src/host/tests/messages.js:19:69␊ - at process.processTicksAndRejections (node:internal/process/task_queues:95:5)`, + text: 'Uncaught error: Broken', } > Snapshot 3 diff --git a/src/host/tests/snapshots/messages.js.snap b/src/host/tests/snapshots/messages.js.snap index f89222331327d4a58500d52e030628db81cca5f0..8310ef8ad7915db1799fb4767ece821565102579 100644 GIT binary patch literal 1069 zcmV+|1k(FKRzV$s(#&T#}Yn1qC4p6nd!uB~${T z2su06-60cuWqT8HLLhPE>kj}CDsd^jz@fAfaH>=!P*rk3^w0xv;LaZaKif0IW|M3( za>z>7db~65`TgD-+dESoi+E*RUc5t9s3Ka4crBESG-RDCd3`1bh$5%{^1Zd5{-7fA zcfMx4XOBLmNGm^H3K;lW^l^B4HCumX71FHL z6{bRPF^CTdK2Dioz6U_}p*>w%oMnFB!kjmFoiuN3#?(jboxLd6hdgf=(riGHH{*ub zc9Ea-7OUyn2`VM2r4$9LCJxEps~QsCXsmEZic?_}Y2YL$e>w^JHH)BwCnCadSy8FV zcq&wN{594W5)&3czZynVVnIoOtAbBp$(y1=akaU}n9a`18%2X`dv7PwTUf-p0QM6S)wxuI-|YVOyMYE#b(>HBUtoI)&0ji` zxlVN`S^A$6b|a;?C1HM3M5gKoVDLygo4-)i0pV;5LQ(M%B@Fg0s(8ti;FY5%lIA8DLEQ>q0E?&fWEnYHboeFdzOMy10o3)-Sh9fOgcCpkO z;yw4p63~Y<))_Q`}GQ^*>Ifn9fp)E}Q*|AhJ#a>+fv-y3meON<0R{P7Fl1- nU9S3?ETGkp!HQc>yY{8d{SLT~+|vwnCxPlCr27lk9ufcmA>R3} literal 1194 zcmV;b1XcS%RzVxQ! zak82;mYzI2-u>Qu@B8-6c%`uz@p@anb%Uxk6U%aD03`hYsdYK8MB->cNeNk(Wb-Luil2%b_wn zneWdj`npOl4$LVcRLGjuYE`GpzYkA;G@L5GE)`k_y42bDSavGev3=xD=L-rJ1|F@R93IZ+VQE{>8TXBD|j7#t0vzULXdiz1+!H1 z0zio$V?3a>kSQt{iTvb7UlG|}crB(em9?o;wNsCqVl4o73h@ToQV(0K)q!FaOa(^C zbTCeeHDm9bK>42m;CGV^QWVU*NoKimO>DJ~KPS3`e0VU8?fKXC= zP6>m3#P-YnjKM0MgZ8SMzP4Te0`L;&{kp5pv(4}xI&Z&(9BYkt&57Yk7KW$q8jtiy z7?H(@j&NLqM*$Uy=e~zTxAiI=J$F9|0$YHyp@4_DST;l++Q@d#!sMCl+HQX5YqQvIH?et^&6V4iG;!WcTIL<6 z0==1~K!^LAwO%ZSBP~<5S?Ue(rhBsl^l1&6ia+MW?VT*#j+w+*#LR5W<}e9=L=>;{ z2v-_hv=jBe1k`UK{?4v`DFy7WK;w@5H)3jhK6xxr{PwOYo@|o$Lh*fidt4*9=S1yl z7HSV)HktLyKIm#I@+W}w8N?rsulU$7_K3r~Dem3(`bVcyEN3ajnDu^L5ZR)E)%QaH zSasC*K11n@g-vMvpyO8hL;F(aKL^~e-Q5i7E Date: Wed, 31 Jul 2024 16:49:07 -0700 Subject: [PATCH 10/18] removes agent files and naming scheme --- README.md | 6 +- bin/agent.js | 4 - src/agent/README.md | 58 --- src/agent/cli.js | 352 ----------------- src/agent/index.js | 17 - src/agent/main.js | 30 -- src/host/README.md | 51 +-- src/host/agent.js | 354 ------------------ src/host/cli-run-plan.js | 52 +-- src/host/main.js | 40 +- src/host/messages.js | 2 +- src/host/tests/cli-run-plan.js | 15 +- src/host/types.js | 14 +- src/{agent => runner}/at-driver.js | 0 .../create-safari-apple-script-driver.js | 0 .../browser-driver/create-web-driver.js | 0 .../browser-driver/create.js | 2 +- src/{agent => runner}/create-test-runner.js | 6 +- src/{agent => runner}/driver-test-runner.js | 4 +- src/{agent => runner}/messages.js | 2 +- src/{agent => runner}/mock-test-runner.js | 21 +- src/{agent => runner}/types.js | 22 +- 22 files changed, 80 insertions(+), 972 deletions(-) delete mode 100755 bin/agent.js delete mode 100644 src/agent/README.md delete mode 100644 src/agent/cli.js delete mode 100644 src/agent/index.js delete mode 100644 src/agent/main.js delete mode 100644 src/host/agent.js rename src/{agent => runner}/at-driver.js (100%) rename src/{agent => runner}/browser-driver/create-safari-apple-script-driver.js (100%) rename src/{agent => runner}/browser-driver/create-web-driver.js (100%) rename src/{agent => runner}/browser-driver/create.js (92%) rename src/{agent => runner}/create-test-runner.js (90%) rename src/{agent => runner}/driver-test-runner.js (98%) rename src/{agent => runner}/messages.js (98%) rename src/{agent => runner}/mock-test-runner.js (86%) rename src/{agent => runner}/types.js (71%) diff --git a/README.md b/README.md index aeaea77..d5a2593 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,10 @@ Firefox, execute the following command in a terminal: $ node aria-at-automation-harness/bin/host.js run-plan \ --plan-workingdir aria-at/build/tests/horizontal-slider \ '{reference/**,test-*-nvda.*}' \ - --agent-web-driver-url=http://127.0.0.1:4444 \ - --agent-at-driver-url=ws://127.0.0.1:4382/session \ + --web-driver-url=http://127.0.0.1:4444 \ + --at-driver-url=ws://127.0.0.1:4382/session \ --reference-hostname=127.0.0.1 \ - --agent-web-driver-browser=firefox + --web-driver-browser=firefox ``` ## [aria-at-automation](https://github.com/w3c/aria-at-automation) diff --git a/bin/agent.js b/bin/agent.js deleted file mode 100755 index e448461..0000000 --- a/bin/agent.js +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env node - -import { runCli } from '../src/agent/index.js'; -runCli(); diff --git a/src/agent/README.md b/src/agent/README.md deleted file mode 100644 index 6a4de10..0000000 --- a/src/agent/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# `src/agent` - -This directory implements the systems used by the `bin/agent.js` command line tool. - -At this time invoking this command must be done from a nodejs process with child_process.fork. A developer tool may be provided soon to read a single test file run `agent` and write the result to console output. - -```sh -$ bin/agent.js -agent.js - -Run tests from input - -Options: -... - -Error: Currently, this command may only be used when launched by a nodejs child_process.fork call. -``` - -Developing with `bin/agent.js` you may want to use the mock test runner. Calling `agent.js` with `--mock` will enable the mock test runner. The mock test runner will be removed in the near future and replaced with the ability to create a mock server that can be more tailored to individual mock use cases. - -## main command - -``` -$ bin/agent.js --help --show-hidden -agent.js - -Run tests from input - -Options: - --help Show help [boolean] - --version Show version number [boolean] - --quiet Disable all logging - --debug Enable all logging - --verbose Enable a subset of logging messages - --reference-base-url Url to append reference page listed in tests to - [string] [default: "http://localhost:8000"] - --web-driver-url [default: "http://localhost:4444"] - --web-driver-browser [choices: "chrome", "firefox"] [default: "firefox"] - --at-driver-url [default: "ws://localhost:4382"] - --mock [boolean] - --mock-open-page [choices: "request", "skip"] -``` - -Currently this command must be executed by a parent node process as a node fork child process. - -### `--verbose` options - -The main command's verbose level can be set with `--debug`, `--quiet`, or `--verbose`. `--verbose` takes a comma separate list of the following logging message types. - -- `start` -- `uncaughtError` -- `willStop` -- `startTest` -- `openPage` -- `invalidKeys` -- `pressKeys` -- `speechEvent` -- `noRunTestSetup` diff --git a/src/agent/cli.js b/src/agent/cli.js deleted file mode 100644 index 66f116e..0000000 --- a/src/agent/cli.js +++ /dev/null @@ -1,352 +0,0 @@ -/// - -/** - * @module agent - */ - -import yargs from 'yargs'; -import { hideBin } from 'yargs/helpers'; - -import { iterateEmitter } from '../shared/iterate-emitter.js'; - -import { createRunner } from './create-test-runner.js'; -import { agentMain } from './main.js'; -import { AgentMessage, createAgentLogger } from './messages.js'; -import { getTimesOption, timesArgs, timesOptionsConfig } from '../shared/times-option.js'; - -/** @param {yargs} args */ -export function buildAgentCliOptions(args = yargs) { - return args - .options({ - quiet: { - conflicts: ['debug', 'verbose'], - describe: 'Disable all logging', - }, - debug: { - conflicts: ['quiet', 'verbose'], - describe: 'Enable all logging', - }, - verbose: { - coerce(arg) { - if (!arg) { - return; - } - const messageValues = Object.values(AgentMessage); - const verbosity = arg.split(','); - for (const name of verbosity) { - if (!messageValues.includes(name)) { - throw new Error( - `--verbose must be a comma separated list including: ${messageValues.join(', ')}` - ); - } - } - return verbosity; - }, - conflicts: ['debug', 'quiet'], - describe: 'Enable a subset of logging messages', - nargs: 1, - }, - 'reference-base-url': { - description: 'Url to append reference page listed in tests to', - coerce(arg) { - return new URL(arg); - }, - default: 'http://localhost:8000', - }, - 'web-driver-url': { - coerce(arg) { - return new URL(arg); - }, - default: 'http://localhost:4444', - }, - 'web-driver-browser': { - choices: ['chrome', 'firefox', 'safari'], - default: 'firefox', - }, - 'at-driver-url': { - coerce(arg) { - return new URL(arg); - }, - default: 'ws://localhost:4382', - }, - mock: { - type: 'boolean', - hidden: true, - }, - 'mock-open-page': { - choices: ['request', 'skip'], - hidden: true, - }, - ...timesOptionsConfig, - }) - .showHidden('show-hidden'); -} - -/** - * @param {AriaATCIAgent.CliOptions} options - * @returns {string[]} - */ -export function agentCliArgsFromOptionsMap(options) { - const args = []; - for (const key of Object.keys(options)) { - const value = options[key]; - switch (key) { - case 'debug': - if (value) { - args.push('--debug'); - } else if (value === false) { - args.push('--debug=false'); - } - break; - case 'quiet': - if (value) { - args.push('--quiet'); - } else if (value === false) { - args.push('--quiet=false'); - } - break; - case 'verbose': - args.push('--verbose', value.join(',')); - break; - case 'referenceBaseUrl': - args.push('--reference-base-url', value.toString()); - break; - case 'webDriverUrl': - args.push('--web-driver-url', value.toString()); - break; - case 'webDriverBrowser': - args.push('--web-driver-browser', value.toString()); - break; - case 'atDriverUrl': - args.push('--at-driver-url', value.toString()); - break; - case 'mock': - if (value) { - args.push('--mock'); - } else if (value === false) { - args.push('--mock=false'); - } - break; - case 'mockOpenPage': - args.push(`--mock-open-page=${value}`); - break; - case 'timesOption': - args.push(...timesArgs(value)); - break; - default: - throw new Error(`unknown agent cli argument ${key}`); - } - } - return args; -} - -/** - * @param {AriaATCIAgent.CliOptions} options - * @returns {AriaATCIAgent.CliOptions} - */ -export function pickAgentCliOptions({ - debug, - quiet, - verbose, - referenceBaseUrl, - webDriverUrl, - webDriverBrowser, - atDriverUrl, - mock, - mockOpenPage, - timesOption, -}) { - return { - ...(debug === undefined ? {} : { debug }), - ...(quiet === undefined ? {} : { quiet }), - ...(verbose === undefined ? {} : { verbose }), - ...(referenceBaseUrl === undefined ? {} : { referenceBaseUrl }), - ...(webDriverUrl === undefined ? {} : { webDriverUrl }), - ...(webDriverBrowser === undefined ? {} : { webDriverBrowser }), - ...(atDriverUrl === undefined ? {} : { atDriverUrl }), - ...(mock === undefined ? {} : { mock }), - ...(mockOpenPage === undefined ? {} : { mockOpenPage }), - timesOption, - }; -} - -/** - * @param {object} options - * @param {import("events").EventEmitter} options.signals - * @param {function(*): void} [options.send] - * @param {import("events").EventEmitter} options.stdin - * @param {import("events").EventEmitter} options.stdout - * @param {import("events").EventEmitter} options.stderr - */ -export async function createAgentCliParser({ signals, send, stdin, stdout, stderr }) { - return /** @type {yargs} */ (await yargs()) - .middleware(argv => { - argv.signals = signals; - argv.send = send; - argv.stdin = stdin; - argv.stdout = stdout; - argv.stderr = stderr; - }) - .command('$0', 'Run tests from input', buildAgentCliOptions, stopAfterMain, [ - agentVerboseMiddleware, - agentAbortMiddleware, - agentLoggerMiddleware, - agentTestsMiddleware, - agentReportMiddleware, - agentRunnerMiddleware, - ]); -} - -/** - * @param {object} options - * @param {object} options.argv - * @param {import("events").EventEmitter} options.signals - * @param {function(*): void} [options.send] - * @param {import("events").EventEmitter} options.stdin - * @param {import("events").EventEmitter} options.stdout - * @param {import("events").EventEmitter} options.stderr - */ -export async function parseAgentCli({ argv, ...parserConfiguration }) { - return await (await createAgentCliParser(parserConfiguration)).parse(hideBin(argv)); -} - -/** - * Summarize cli options as mock options for creating a test runner. - * @param {AriaATCIAgent.CliOptions} cliOptions - * @returns {AriaATCIAgent.MockOptions} - */ -export function agentMockOptions(cliOptions) { - let { mock, mockOpenPage } = pickAgentCliOptions(cliOptions); - if (mock === undefined && mockOpenPage) { - mock = true; - } - if (mock) { - return { openPage: mockOpenPage ? mockOpenPage : 'request' }; - } - return undefined; -} - -async function stopAfterMain(argv) { - await agentMain(argv); - await argv.stop(); -} - -/** - * Build and assign a test runner based on passed arguments. - * @param {object} argv - * @param {AriaATCIAgent.Log} argv.log - * @param {AriaATCIShared.BaseURL} argv.referenceBaseUrl - * @param {boolean} [argv.mock] - * @param {AriaATCIAgent.TestRunner} argv.runner - * @param {AriaATCIAgent.Browser} [argv.webDriverBrowser] - * @param {AriaATCIShared.BaseURL} argv.webDriverUrl - * @param {AriaATCIShared.BaseURL} argv.atDriverUrl - * @param {Promise} argv.abortSignal - */ -async function agentRunnerMiddleware(argv) { - argv.runner = await createRunner({ - log: argv.log, - baseUrl: argv.referenceBaseUrl, - mock: agentMockOptions(argv), - webDriverUrl: argv.webDriverUrl, - webDriverBrowser: argv.webDriverBrowser, - atDriverUrl: argv.atDriverUrl, - abortSignal: argv.abortSignal, - timesOption: getTimesOption(argv), - }); -} - -/** - * Build and assign a test runner based on passed arguments. - * @param {object} argv - * @param {boolean} argv.debug - * @param {boolean} argv.quiet - * @param {string[]} argv.verbose - * @param {string[]} argv.verbosity - */ -async function agentVerboseMiddleware(argv) { - if (argv.debug) { - argv.verbosity = Object.values(AgentMessage); - } else if (argv.quiet) { - argv.verbosity = []; - } else { - argv.verbosity = - argv.verbose && argv.verbose.length - ? argv.verbose - : [AgentMessage.START, AgentMessage.UNCAUGHT_ERROR, AgentMessage.WILL_STOP]; - } -} - -async function agentAbortMiddleware(argv) { - argv.abortSignal = new Promise(resolve => { - argv.stop = resolve; - argv.signals.once('SIGINT', () => resolve()); - process.once('beforeExit', () => resolve()); - }); -} - -/** - * Build and assign main loop arguments based on passed protocol and other arguments. - * @param {object} argv - * @param {function(*): void} argv.send - * @param {AriaATCIAgent.Log} argv.log - * @param {string[]} argv.verbosity - */ -export function agentLoggerMiddleware(argv) { - if (typeof argv.send !== 'function') { - throw new Error( - `Currently, this command may only be used when launched by a nodejs child_process.fork call.` - ); - } - - const logger = createAgentLogger(); - argv.log = logger.log; - - const { send, verbosity } = argv; - logger.emitter.on('message', message => { - if (verbosity.includes(message.data.type)) { - send({ - type: 'log', - data: message, - }); - } - }); -} - -/** - * Build and assign main loop arguments based on passed protocol and other arguments. - * @param {object} argv - * @param {import("events").EventEmitter} argv.signals - * @param {AriaATCIAgent.TestIterable} argv.tests - */ -export function agentTestsMiddleware(argv) { - const { signals } = argv; - argv.tests = (async function* () { - for await (const message of iterateEmitter(signals, 'message', 'SIGINT')) { - if (message.type === 'task') { - yield message.data; - } else if (message.type === 'stop') { - break; - } - } - })(); -} - -/** - * Build and assign main loop arguments based on passed protocol and other arguments. - * @param {object} argv - * @param {function(*): void} argv.send - * @param {AriaATCIAgent.ReportResult} argv.reportResult - */ -export function agentReportMiddleware(argv) { - if (typeof argv.send !== 'function') { - throw new Error( - `Currently, this command may only be used when launched by a nodejs child_process.fork call.` - ); - } - - const { send } = argv; - argv.reportResult = async function (result) { - send({ type: 'result', data: result }); - }; -} diff --git a/src/agent/index.js b/src/agent/index.js deleted file mode 100644 index 32145dc..0000000 --- a/src/agent/index.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @module agent - */ - -import { parseAgentCli } from './cli.js'; - -export async function runCli(argv = process.argv) { - const { stdin, stdout, stderr } = process; - return await parseAgentCli({ - argv, - signals: process, - send: process.send ? process.send.bind(process) : null, - stdin, - stdout, - stderr, - }); -} diff --git a/src/agent/main.js b/src/agent/main.js deleted file mode 100644 index 2ff3085..0000000 --- a/src/agent/main.js +++ /dev/null @@ -1,30 +0,0 @@ -/// - -/** - * @module agent - */ - -import { AgentMessage } from './messages.js'; - -/** - * Run agent's main application loop, waiting for tests, running them, and reporting results. - * @param {object} args - * @param {AriaATCIAgent.TestRunner} args.runner - * @param {AriaATCIAgent.Log} args.log - * @param {AriaATCIAgent.TestIterable} args.tests - * @param {AriaATCIAgent.ReportResult} args.reportResult - */ -export async function agentMain({ runner, log, tests, reportResult }) { - try { - log(AgentMessage.START); - // Wait for a test. - for await (const test of tests) { - // Perform the test and report result. - await reportResult(await runner.run(test)); - } - } catch (error) { - log(AgentMessage.UNCAUGHT_ERROR, { error }); - } finally { - log(AgentMessage.WILL_STOP); - } -} diff --git a/src/host/README.md b/src/host/README.md index 868787f..d05de6a 100644 --- a/src/host/README.md +++ b/src/host/README.md @@ -2,7 +2,7 @@ This directory implements the systems used by the `bin/host.js` command line tool. -The `bin/host.js` tool has two commands. The `run-plan` command operates a server and `bin/agent.js` instance to run test plans and the `read-plan` command reads files from disk and packages them for the `run-plan` command. +The `bin/host.js` tool has two commands. The `run-plan` command operates a server to run test plans and the `read-plan` command reads files from disk and packages them for the `run-plan` command. A short invocation of the `run-plan` command can be made with a list of files or file globs that make up a test plan. A test plan should contain tests for a single assistive technology to be tested. If for example all the reference files and test files are in two directories this command could be executed. @@ -15,7 +15,7 @@ Removing reference from 'http://localhost:52147/gtmoyv'. Stopping... ``` -Developing `bin/host.js` you may want to use the mock test runner in `bin/agent.js`. Calling `host.js` with `--agent-mock` will enable the mock test runner. +Developing `bin/host.js` you may want to use the mock test runner. Calling `host.js` with `--agent-mock` will enable the mock test runner. ```sh $ bin/host.js run-plan --agent-mock reference/** at/** >result.json @@ -26,54 +26,17 @@ The mock test runner will be removed in the near future and replaced with the ab ## "main" command -The `host` loads test plans, serves their files from a http server, runs each test through an `agent` instance, and reports the collected results for each test plan. +The `host` loads test plans, serves their files from a http server, runs each test, and reports the collected results for each test plan. 1. Start a server listening on a port 1. Read a test plan from disk or input stream 1. Add test plan files to a subdirectory on the server -1. Start an `agent` instance -1. Run each test in the test plan through the `agent` instance -1. Stop the `agent` instance +1. Run each test in the test plan 1. Emit the results of the test in a json format 1. If reading plans from stream, repeat from step 2 1. Stop the server 1. Gracefully exit -``` -$ bin/host.js run-plan --help --show-hidden -host.js run-plan [plan-files..] - -Run test plans - -Positionals: - plan-files Files in a test plan [array] [default: []] - -Options: - --help Show help [boolean] - --version Show version number [boolean] - --quiet Disable all logging - --debug Enable all logging - --verbose Enable a subset of logging messages - --tests-match Files matching pattern in a test plan will be test - ed [string] [default: "{,**/}test*.json"] - --reference-hostname [default: "localhost"] - --plan-workingdir Directory "plan-files" are relative to - [default: "."] - --plan-protocol [choices: "fork", "developer"] [default: "fork"] - --agent-web-driver-url [default: "http://localhost:4444"] - --agent-web-driver-browser [choices: "chrome", "firefox"] [default: "firefox"] - --agent-at-driver-url [default: "http://localhost:4382"] - --agent-protocol [choices: "fork", "developer"] [default: "fork"] - --agent-quiet Disable all logging - --agent-debug Enable all logging - --agent-verbose Enable a subset of logging messages - --agent-mock [boolean] - --agent-mock-open-page [choices: "request", "skip"] - --callback-url URL to POST test results to as they complete - --callback-header Header to send with callback request - --show-hidden Show hidden options [boolean] -``` - ### Loading a test plan `bin/host.js` can load a test plan through the `read-plan` command (or developer @@ -81,10 +44,6 @@ interface) with `src/host/plan-from.js`. For convenience the `run-plan` command takes arguments prefixed with `plan` that map to arguments that can be passed to `read-plan`, to read a plan. -### `bin/agent.js` communication - -The host while managing an agent instance can operate it through the `bin/agent.js` tool or `src/agent/main.js` developer interface. - ### `--verbose` options The main command's verbose level can be set with `--debug`, `--quiet`, or `--verbose`. `--verbose` takes a comma separate list of the following logging message types. @@ -116,5 +75,3 @@ Options: --version Show version number [boolean] --workingdir Directory to read files from [string] [default: "."] ``` - -Currently this command must be executed by a parent node process as a node fork child process. diff --git a/src/host/agent.js b/src/host/agent.js deleted file mode 100644 index 82ec12d..0000000 --- a/src/host/agent.js +++ /dev/null @@ -1,354 +0,0 @@ -/// -/// -/// - -/** - * @module host - */ - -import * as child_process from 'child_process'; -import { EventEmitter } from 'events'; -import { constants as osConstants } from 'os'; -import * as path from 'path'; -import { fileURLToPath, URL } from 'url'; - -import { iterateEmitter } from '../shared/iterate-emitter.js'; -import { processExited, collectProcessPipe } from '../shared/process-util.js'; - -import { agentCliArgsFromOptionsMap, agentMockOptions } from '../agent/cli.js'; -import { createRunner } from '../agent/create-test-runner.js'; -import { agentMain } from '../agent/main.js'; -import { AgentMessage, createAgentLogger } from '../agent/messages.js'; - -import { HostMessage } from './messages.js'; - -const { - signals: { SIGINT }, -} = osConstants; - -export class AgentController { - /** - * @param {object} options - * @param {AriaATCIHost.Log} options.log - * @param {'fork' | 'developer'} [options.protocol] - * @param {AriaATCIAgent.CliOptions} [options.config] - */ - constructor({ config = {}, ...otherOptions }) { - this._options = { - ...this._defaultOptions(), - ...otherOptions, - config: this._modifyConfig(config), - }; - - /** @type {AriaATCIAgent.CliOptions} */ - this._activeConfig = null; - /** @type {AgentProtocol} */ - this._activeProtocol = null; - - this._logEmitter = new EventEmitter(); - } - - _defaultOptions() { - return { protocol: 'fork' }; - } - - /** - * @param {AriaATCIAgent.CliOptions} config - * @returns {AriaATCIAgent.CliOptions} - */ - _modifyConfig(config) { - return { - debug: config.quiet === undefined && config.verbose === undefined ? true : undefined, - ...config, - }; - } - - /** - * @param {AriaATCIData.Test} test - * @returns {Promise} - */ - async run(test) { - return await this._activeProtocol.run(test); - } - - /** - * @returns {AsyncGenerator} - */ - async *logs() { - if (this._activeProtocol) { - yield* this._activeProtocol.logs(); - } - for await (const instance of iterateEmitter(this._logEmitter, 'log')) { - yield* instance.logs(); - } - } - - /** - * @param {AriaATCIAgent.CliOptions} [cliOptions] - */ - async start(cliOptions) { - try { - const { log, protocol, config } = this._options; - const mergedOptions = { ...config, ...cliOptions }; - this._activeConfig = mergedOptions; - - const Protocol = AGENT_PROTOCOL[protocol]; - this._activeProtocol = new Protocol(); - const ready = this._activeProtocol.start(mergedOptions); - this._logEmitter.emit('log', this._activeProtocol); - await ready; - log(HostMessage.AGENT_PROTOCOL, { protocol: Protocol.protocolName }); - } catch (error) { - this._activeProtocol = null; - throw new Error(`Agent failed to start.\n${error.stack ? error.stack : error.toString()}`); - } - } - - async stop() { - await this._activeProtocol.stop(); - this._activeProtocol = null; - } -} - -class AgentProtocol { - static get protocolName() { - return 'unknown'; - } - - /** - * Start a copy of src/agent and run tests in it. - */ - constructor() { - /** @type {Promise<{code: number, signal: number}> | null} */ - this.exited = null; - /** @type {Promise | null} */ - this.ready = null; - } - - /** - * @param {AriaATCIData.Test} test - * @returns {Promise} - */ - async run(test) { - const { testId } = test.info; - this._sendTest(test); - for await (const result of this._results()) { - if (result.testId === testId) { - return result; - } - } - throw new Error('test result not received'); - } - - /** - * Iterate process log messages as they are received. - * @returns {AsyncGenerator} - */ - async *logs() { - throw new Error(`${this.constructor.name}.logs() not implemented`); - } - - /** - * Start the agent process. - * @param {AriaATCIAgent.CliOptions} options - */ - async start(options) { - throw new Error(`${this.constructor.name}.start() not implemented`); - } - - /** - * Stop the agent process. - */ - async stop() { - throw new Error(`${this.constructor.name}.stop() not implemented`); - } - - /** - * Send a test to the process. - * @param {AriaATCIData.Test} test - */ - async _sendTest(test) { - throw new Error(`${this.constructor.name}._sendTest() not implemented`); - } - - /** - * Iterate results from the agent process as they are received. - * @returns {AsyncGenerator} - */ - async *_results() { - throw new Error(`${this.constructor.name}._results() not implemented`); - } -} - -class AgentForkProtocol extends AgentProtocol { - static get protocolName() { - return 'fork'; - } - - /** - * Start a copy of src/agent with child_process.fork and run tests in it. - */ - constructor() { - super(); - /** @type {child_process.ChildProcess | null} */ - this._processFork = null; - } - - async *logs() { - for await (const message of this._messages()) { - if (message.type === 'log') { - yield message.data; - } - } - } - - /** - * @param {AriaATCIAgent.CliOptions} options - */ - async start(options) { - const agentPath = path.resolve( - path.dirname(fileURLToPath(import.meta.url)), - '../../bin/agent.js' - ); - - const agentProcess = (this._processFork = child_process.fork( - agentPath, - agentCliArgsFromOptionsMap(options), - { stdio: 'pipe', serialization: 'advanced' } - )); - - const stderrJob = collectProcessPipe(agentProcess.stderr); - this.exited = processExited(agentProcess); - this.ready = (async () => { - for await (const log of this.logs()) { - if (log.data.type === AgentMessage.START) { - await stderrJob.cancel(); - return; - } - } - const stderrOutput = await stderrJob.cancel(); - throw new Error(`Agent fork exited before it was ready.\n${stderrOutput}`); - })(); - - await this.ready; - } - - async stop() { - if (this._processFork) { - this._processFork.send({ type: 'stop' }); - try { - await Promise.race([ - this.exited, - new Promise(resolve => setTimeout(resolve, 1000)).then(() => { - throw new Error('AgentProtocol: graceful stop timeout'); - }), - ]); - } catch (_) { - this._processFork.kill(SIGINT); - } - } - await this.exited; - - this._processFork = null; - this.exited = null; - this.ready = null; - } - - async _sendTest(test) { - this._processFork.send({ type: 'task', data: test }); - } - - async *_messages() { - yield* iterateEmitter(this._processFork, 'message', 'exit'); - } - - async *_results() { - for await (const message of this._messages()) { - if (message.type === 'result') { - yield message.data; - } - } - } -} - -class AgentDeveloperProtocol extends AgentProtocol { - static get protocolName() { - return 'developer'; - } - - /** - * Start a copy of src/agent with the js api and run tests in it. - */ - constructor() { - super(); - this._testEmitter = null; - this._logEmitter = null; - this._resultEmitter = null; - } - - async _sendTest(test) { - this._testEmitter.emit('message', test); - } - - _results() { - return iterateEmitter(this._resultEmitter, 'result', 'stop'); - } - - async *logs() { - yield* iterateEmitter(this._logEmitter, 'message', 'stop'); - } - - /** - * @param {AriaATCIAgent.CliOptions} options - */ - async start(options) { - const { log, emitter: logEmitter } = createAgentLogger(); - this._testEmitter = new EventEmitter(); - this._logEmitter = logEmitter; - this._resultEmitter = new EventEmitter(); - - const abortSignal = new Promise(resolve => { - this._testEmitter.once('stop', () => resolve()); - }); - this.exited = agentMain({ - runner: await createRunner({ - abortSignal, - baseUrl: options.referenceBaseUrl || new URL('http://localhost:4400'), - log, - mock: agentMockOptions(options), - atDriverUrl: options.atDriverUrl, - webDriverBrowser: options.webDriverBrowser, - webDriverUrl: options.webDriverUrl, - timesOption: options.timesOption, - }), - log, - tests: iterateEmitter(this._testEmitter, 'message', 'stop'), - reportResult: async result => { - this._resultEmitter.emit('result', result); - }, - }) - .then(() => { - this.stop(); - }) - .then(() => ({ code: 0, signal: null })); - this.ready = Promise.resolve(); - - await this.ready; - } - - async stop() { - this._testEmitter.emit('stop'); - this._logEmitter.emit('stop'); - this._resultEmitter.emit('stop'); - - await this.exited; - - this.exited = null; - this.ready = null; - } -} - -const AGENT_PROTOCOL = { - fork: AgentForkProtocol, - developer: AgentDeveloperProtocol, -}; diff --git a/src/host/cli-run-plan.js b/src/host/cli-run-plan.js index 1937bad..c1f7172 100644 --- a/src/host/cli-run-plan.js +++ b/src/host/cli-run-plan.js @@ -7,7 +7,7 @@ import { Readable } from 'stream'; import fetch, { Response } from 'node-fetch'; import yargs from 'yargs'; -import { AgentMessage } from '../agent/messages.js'; +import { AgentMessage } from '../runner/messages.js'; import { hostMain } from './main.js'; import { HostMessage, createHostLogger } from './messages.js'; @@ -75,65 +75,27 @@ export const builder = (args = yargs) => default: 'fork', hidden: true, }, - 'agent-web-driver-url': { + 'web-driver-url': { coerce(arg) { return new URL(arg); }, default: 'http://localhost:4444', }, - 'agent-web-driver-browser': { + 'web-driver-browser': { choices: ['chrome', 'firefox', 'safari'], default: 'firefox', }, - 'agent-at-driver-url': { + 'at-driver-url': { coerce(arg) { return new URL(arg); }, default: 'http://localhost:4382', }, - 'agent-protocol': { - choices: ['fork', 'developer'], - default: 'fork', - hidden: true, - }, - 'agent-quiet': { - conflicts: ['agent-debug', 'agent-verbose'], - describe: 'Disable all logging', - hidden: true, - }, - 'agent-debug': { - conflicts: ['agent-quiet', 'agent-verbose'], - describe: 'Enable all logging', - hidden: true, - }, - 'agent-verbose': { - coerce(arg) { - if (!arg) { - return; - } - const messageValues = Object.values(AgentMessage); - const verbosity = arg.split(','); - for (const name of verbosity) { - if (!messageValues.includes(name)) { - throw new Error( - `--verbose must be a comma separated list including: ${Object.values( - AgentMessage - ).join(', ')}` - ); - } - } - return verbosity; - }, - conflicts: ['agent-debug', 'agent-quiet'], - describe: 'Enable a subset of logging messages', - nargs: 1, - hidden: true, - }, - 'agent-mock': { + 'runner-mock': { type: 'boolean', hidden: true, }, - 'agent-mock-open-page': { + 'runner-mock-open-page': { choices: ['request', 'skip'], hidden: true, }, @@ -200,7 +162,7 @@ function mainMiddleware(argv) { function mainFetchMiddleware(argv) { if (!argv.fetch) { - if (!argv.agentMock) { + if (!argv.runnerMock) { argv.fetch = fetch; } else { argv.fetch = (url, ...params) => diff --git a/src/host/main.js b/src/host/main.js index c14ba4b..8c5562d 100644 --- a/src/host/main.js +++ b/src/host/main.js @@ -5,8 +5,7 @@ */ import { EventEmitter } from 'events'; -import { agentMockOptions } from '../agent/cli.js'; -import { createRunner } from '../agent/create-test-runner.js'; +import { createRunner } from '../runner/create-test-runner.js'; import { HostMessage } from './messages.js'; import { @@ -16,7 +15,8 @@ import { addTestResultToTestPlan, } from './plan-object.js'; import { getTimesOption } from '../shared/times-option.js'; -import { AGENT_TEMPLATES } from '../agent/messages.js'; +import { AGENT_TEMPLATES } from '../runner/messages.js'; +import { runnerMockOptions } from '../runner/mock-test-runner.js'; /** * @param {AriaATCIHost.Log} log @@ -36,16 +36,16 @@ const logUnsuccessfulHTTP = async (log, response) => { * @param {AriaATCIHost.Logger} options.logger * @param {AsyncIterable} options.plans * @param {AriaATCIHost.ReferenceFileServer} options.server - * @param {AriaATCIAgent.TestRunner} options.runner + * @param {AriaATCIRunner.TestRunner} options.runner * @param {AriaATCIHost.EmitPlanResults} options.emitPlanResults * @param {string} [options.callbackUrl] * @param {Record} [options.callbackHeader] * @param {typeof fetch} options.fetch - * @param {boolean} options.agentMock - * @param {'request' | 'skip'} options.agentMockOpenPage - * @param {AriaATCIShared.BaseURL} options.agentWebDriverUrl - * @param {AriaATCIAgent.Browser} options.agentWebDriverBrowser - * @param {AriaATCIShared.BaseURL} options.agentAtDriverUrl + * @param {boolean} options.runnerMock + * @param {'request' | 'skip'} options.runnerMockOpenPage + * @param {AriaATCIShared.BaseURL} options.webDriverUrl + * @param {AriaATCIRunner.Browser} options.webDriverBrowser + * @param {AriaATCIShared.BaseURL} options.atDriverUrl */ export async function hostMain(options) { const { @@ -55,11 +55,11 @@ export async function hostMain(options) { emitPlanResults, callbackUrl, callbackHeader, - agentMock, - agentMockOpenPage, - agentWebDriverUrl, - agentWebDriverBrowser, - agentAtDriverUrl, + runnerMock, + runnerMockOpenPage, + webDriverUrl, + webDriverBrowser, + atDriverUrl, } = options; const { log } = logger; log(HostMessage.START); @@ -83,13 +83,13 @@ export async function hostMain(options) { }), timesOption, baseUrl: serverDirectory.baseUrl, - mock: agentMockOptions({ - mock: agentMock, - mockOpenPage: agentMockOpenPage, + mock: runnerMockOptions({ + mock: runnerMock, + mockOpenPage: runnerMockOpenPage, }), - webDriverUrl: agentWebDriverUrl, - webDriverBrowser: agentWebDriverBrowser, - atDriverUrl: agentAtDriverUrl, + webDriverUrl, + webDriverBrowser, + atDriverUrl, }); let lastCallbackRequest = Promise.resolve(); diff --git a/src/host/messages.js b/src/host/messages.js index 43ab280..2c3c4b3 100644 --- a/src/host/messages.js +++ b/src/host/messages.js @@ -4,7 +4,7 @@ * @module host */ -import { AGENT_TEMPLATES } from '../agent/messages.js'; +import { AGENT_TEMPLATES } from '../runner/messages.js'; import { createSharedLogger } from '../shared/messages.js'; /** @enum {AriaATCIHost.HostLogType} */ diff --git a/src/host/tests/cli-run-plan.js b/src/host/tests/cli-run-plan.js index 3a870f3..01b8e30 100644 --- a/src/host/tests/cli-run-plan.js +++ b/src/host/tests/cli-run-plan.js @@ -3,14 +3,13 @@ import * as path from 'path'; import { fileURLToPath } from 'url'; import test from 'ava'; -import { HostMessage } from '../messages.js'; test('plan1', async t => { t.snapshot( await spawnRunPlan([ '--plan-workingdir=fixtures/host-bin/plan1', '"**"', - '--agent-mock', + '--runner-mock', '--debug', ]) ); @@ -21,7 +20,7 @@ test('plan2', async t => { await spawnRunPlan([ '--plan-workingdir=fixtures/host-bin/plan2', '"**"', - '--agent-mock', + '--runner-mock', '--debug', ]) ); @@ -32,7 +31,7 @@ test('plan3', async t => { await spawnRunPlan([ '--plan-workingdir=fixtures/host-bin/plan3', '"**"', - '--agent-mock', + '--runner-mock', '--debug', ]) ); @@ -43,7 +42,7 @@ test('plan3 with callback no url param', async t => { await spawnRunPlan([ '--plan-workingdir=fixtures/host-bin/plan3', '"**"', - '--agent-mock', + '--runner-mock', '--debug', '--callback-url=http://callback.url/', '--callback-header=test:header:multiple:colon', @@ -56,7 +55,7 @@ test('plan3 with callback', async t => { await spawnRunPlan([ '--plan-workingdir=fixtures/host-bin/plan3', '"**"', - '--agent-mock', + '--runner-mock', '--debug', '--callback-url=http://callback.url/:testRowNumber', '--callback-header=test:header:multiple:colon', @@ -69,7 +68,7 @@ test('plan3 with callback request which fails', async t => { await spawnRunPlan([ '--plan-workingdir=fixtures/host-bin/plan3', '"**"', - '--agent-mock', + '--runner-mock', '--debug', '--callback-url=http://example.com/?TEST-STATUS=418', '--callback-header=x:y', @@ -82,7 +81,7 @@ test('plan3 with callback request which fails with a faulty response body', asyn await spawnRunPlan([ '--plan-workingdir=fixtures/host-bin/plan3', '"**"', - '--agent-mock', + '--runner-mock', '--debug', '--callback-url="http://example.com/?TEST-STATUS=418&TEST-BAD-BODY"', '--callback-header=x:y', diff --git a/src/host/types.js b/src/host/types.js index 36a7ad5..ed52bc7 100644 --- a/src/host/types.js +++ b/src/host/types.js @@ -1,7 +1,7 @@ /// /// /// -/// +/// /** * @namespace AriaATCIHost @@ -46,10 +46,6 @@ * @property {import("events").EventEmitter} emitter */ -/** - * @typedef {AriaATCIAgent.Log} AriaATCIHost.AgentLog - */ - /** * @typedef AriaATCIHost.TestPlan * @property {string} name @@ -84,14 +80,6 @@ * @property {AriaATCIShared.BaseURL} baseUrl */ -/** - * @typedef AriaATCIHost.Agent - * @property {function(AriaATCIData.Test): Promise} run - * @property {function(): AsyncGenerator} logs - * @property {function(AriaATCIAgent.CliOptions): Promise} start - * @property {function(): Promise} stop - */ - /** * @callback AriaATCIHost.EmitPlanResults * @param {AriaATCIHost.TestPlan} plan diff --git a/src/agent/at-driver.js b/src/runner/at-driver.js similarity index 100% rename from src/agent/at-driver.js rename to src/runner/at-driver.js diff --git a/src/agent/browser-driver/create-safari-apple-script-driver.js b/src/runner/browser-driver/create-safari-apple-script-driver.js similarity index 100% rename from src/agent/browser-driver/create-safari-apple-script-driver.js rename to src/runner/browser-driver/create-safari-apple-script-driver.js diff --git a/src/agent/browser-driver/create-web-driver.js b/src/runner/browser-driver/create-web-driver.js similarity index 100% rename from src/agent/browser-driver/create-web-driver.js rename to src/runner/browser-driver/create-web-driver.js diff --git a/src/agent/browser-driver/create.js b/src/runner/browser-driver/create.js similarity index 92% rename from src/agent/browser-driver/create.js rename to src/runner/browser-driver/create.js index 0192a55..28944c6 100644 --- a/src/agent/browser-driver/create.js +++ b/src/runner/browser-driver/create.js @@ -4,7 +4,7 @@ import createSafariAppleScriptDriver from './create-safari-apple-script-driver.j /** * @param {object} options * @param {{toString: function(): string}} options.url - * @param {AriaATCIAgent.Browser} [options.browser] + * @param {AriaATCIRunner.Browser} [options.browser] * @param {Promise} options.abortSignal * @param {AriaATCIShared.timesOption} options.timesOption * diff --git a/src/agent/create-test-runner.js b/src/runner/create-test-runner.js similarity index 90% rename from src/agent/create-test-runner.js rename to src/runner/create-test-runner.js index de6a3eb..57a1796 100644 --- a/src/agent/create-test-runner.js +++ b/src/runner/create-test-runner.js @@ -17,11 +17,11 @@ import { AgentMessage } from './messages.js'; * @param {AriaATCIShared.BaseURL} options.baseUrl * @param {AriaATCIHost.Log} options.log * @param {Promise} options.abortSignal - * @param {AriaATCIAgent.MockOptions} [options.mock] - * @param {AriaATCIAgent.Browser} [options.webDriverBrowser] + * @param {AriaATCIRunner.MockOptions} [options.mock] + * @param {AriaATCIRunner.Browser} [options.webDriverBrowser] * @param {AriaATCIShared.timesOption} options.timesOption * @param {{toString: function(): string}} options.webDriverUrl - * @returns {Promise} + * @returns {Promise} */ export async function createRunner(options) { const { abortSignal, log, timesOption } = options; diff --git a/src/agent/driver-test-runner.js b/src/runner/driver-test-runner.js similarity index 98% rename from src/agent/driver-test-runner.js rename to src/runner/driver-test-runner.js index a2fca33..4871958 100644 --- a/src/agent/driver-test-runner.js +++ b/src/runner/driver-test-runner.js @@ -57,7 +57,7 @@ export class DriverTestRunner { } /** - * @param {import('./at-driver').ATKeySequence} sequence + * @param {import('./at-driver.js').ATKeySequence} sequence */ async sendKeys(sequence) { await this.log(AgentMessage.PRESS_KEYS, { keys: sequence }); @@ -65,7 +65,7 @@ export class DriverTestRunner { } /** - * @param {import('./at-driver').ATKeySequence} sequence + * @param {import('./at-driver.js').ATKeySequence} sequence * @param {string} desiredResponse */ async pressKeysToToggleSetting(sequence, desiredResponse) { diff --git a/src/agent/messages.js b/src/runner/messages.js similarity index 98% rename from src/agent/messages.js rename to src/runner/messages.js index 1940cea..4a533d4 100644 --- a/src/agent/messages.js +++ b/src/runner/messages.js @@ -7,7 +7,7 @@ import { createSharedLogger } from '../shared/messages.js'; -/** @enum {AriaATCIAgent.Message} */ +/** @enum {AriaATCIRunner.Message} */ export const AgentMessage = { /** @type {'start'} */ START: 'start', diff --git a/src/agent/mock-test-runner.js b/src/runner/mock-test-runner.js similarity index 86% rename from src/agent/mock-test-runner.js rename to src/runner/mock-test-runner.js index 6b7248f..8f66049 100644 --- a/src/agent/mock-test-runner.js +++ b/src/runner/mock-test-runner.js @@ -11,14 +11,14 @@ import { AgentMessage } from './messages.js'; import { validateKeysFromCommand } from './driver-test-runner.js'; /** - * @implements {AriaATCIAgent.TestRunner} + * @implements {AriaATCIRunner.TestRunner} */ export class MockTestRunner { /** * @param {object} options * @param {AriaATCIShared.BaseURL} options.baseUrl * @param {AriaATCIHost.Log} options.log - * @param {AriaATCIAgent.MockOptions} options.mock + * @param {AriaATCIRunner.MockOptions} options.mock */ constructor({ baseUrl, log, mock: config }) { this.baseUrl = baseUrl; @@ -129,3 +129,20 @@ export class MockTestRunner { }; } } + +/** + * Summarize cli options as mock options for creating a test runner. + * @param {object} options + * @param {boolean} options.mock + * @param {'request' | 'skip'} options.mockOpenPage + * @returns {AriaATCIRunner.MockOptions} + */ +export function runnerMockOptions({ mock, mockOpenPage }) { + if (mock === undefined && mockOpenPage) { + mock = true; + } + if (mock) { + return { openPage: mockOpenPage ? mockOpenPage : 'request' }; + } + return undefined; +} diff --git a/src/agent/types.js b/src/runner/types.js similarity index 71% rename from src/agent/types.js rename to src/runner/types.js index d9c36ef..5b3c87e 100644 --- a/src/agent/types.js +++ b/src/runner/types.js @@ -1,7 +1,7 @@ /// /// -/** @namespace AriaATCIAgent */ +/** @namespace AriaATCIRunner */ /** * @typedef {'start' @@ -15,47 +15,47 @@ * | 'noRunTestSetup' * | 'atDriverComms' * | 'capabilities' - * } AriaATCIAgent.Message + * } AriaATCIRunner.Message */ /** - * @typedef {AriaATCIShared.Log} AriaATCIAgent.Log + * @typedef {AriaATCIShared.Log} AriaATCIRunner.Log */ /** - * @typedef {AsyncIterable} AriaATCIAgent.TestIterable + * @typedef {AsyncIterable} AriaATCIRunner.TestIterable */ /** - * @typedef AriaATCIAgent.TestRunner + * @typedef AriaATCIRunner.TestRunner * @property {function(AriaATCIData.Test): Promise} run run a test */ /** - * @callback AriaATCIAgent.ReportResult + * @callback AriaATCIRunner.ReportResult * @param {AriaATCIData.TestResult} result * @returns {Promise} */ /** - * @typedef AriaATCIAgent.MockOptions + * @typedef AriaATCIRunner.MockOptions * @property {'request' | 'skip'} [openPage] */ /** - * @typedef {'chrome' | 'firefox' | 'safari'} AriaATCIAgent.Browser + * @typedef {'chrome' | 'firefox' | 'safari'} AriaATCIRunner.Browser */ /** - * @typedef AriaATCIAgent.CliOptions + * @typedef AriaATCIRunner.CliOptions * @property {boolean} [debug] * @property {boolean} [quiet] - * @property {AriaATCIAgent.Message[]} [verbose] + * @property {AriaATCIRunner.Message[]} [verbose] * @property {AriaATCIShared.BaseURL} [referenceBaseUrl] * @property {boolean} [mock] * @property {'request' | 'skip'} [mockOpenPage] * @property {AriaATCIShared.BaseURL} [webDriverUrl] - * @property {AriaATCIAgent.Browser} [webDriverBrowser] + * @property {AriaATCIRunner.Browser} [webDriverBrowser] * @property {AriaATCIShared.BaseURL} [atDriverUrl] * @property {AriaATCIShared.timesOption} [timesOption] */ From 04c94eecc52037d5aa16729564f655ce0c6f9432 Mon Sep 17 00:00:00 2001 From: Chris Cuellar <58723+ChrisC@users.noreply.github.com> Date: Thu, 1 Aug 2024 08:44:16 -0700 Subject: [PATCH 11/18] updates log messages --- src/host/cli-run-plan.js | 8 ++++---- src/host/main.js | 4 ++-- src/host/messages.js | 4 ++-- src/runner/at-driver.js | 12 ++++++------ src/runner/create-test-runner.js | 1 - src/runner/driver-test-runner.js | 20 +++++++++---------- src/runner/messages.js | 33 +++++++++++++------------------- src/runner/mock-test-runner.js | 6 +++--- 8 files changed, 40 insertions(+), 48 deletions(-) diff --git a/src/host/cli-run-plan.js b/src/host/cli-run-plan.js index c1f7172..da70201 100644 --- a/src/host/cli-run-plan.js +++ b/src/host/cli-run-plan.js @@ -7,7 +7,7 @@ import { Readable } from 'stream'; import fetch, { Response } from 'node-fetch'; import yargs from 'yargs'; -import { AgentMessage } from '../runner/messages.js'; +import { RunnerMessage } from '../runner/messages.js'; import { hostMain } from './main.js'; import { HostMessage, createHostLogger } from './messages.js'; @@ -130,7 +130,7 @@ async function verboseMiddleware(argv) { let verbosity; if (debug) { - verbosity = Object.values({ ...HostMessage, ...AgentMessage }); + verbosity = Object.values({ ...HostMessage, ...RunnerMessage }); } else if (quiet) { verbosity = []; } else { @@ -143,8 +143,8 @@ async function verboseMiddleware(argv) { HostMessage.SERVER_LISTENING, HostMessage.ADD_SERVER_DIRECTORY, HostMessage.REMOVE_SERVER_DIRECTORY, - AgentMessage.OPEN_PAGE, - AgentMessage.UNCAUGHT_ERROR, + HostMessage.UNCAUGHT_ERROR, + RunnerMessage.OPEN_PAGE, ]; } diff --git a/src/host/main.js b/src/host/main.js index 8c5562d..6031bce 100644 --- a/src/host/main.js +++ b/src/host/main.js @@ -15,7 +15,7 @@ import { addTestResultToTestPlan, } from './plan-object.js'; import { getTimesOption } from '../shared/times-option.js'; -import { AGENT_TEMPLATES } from '../runner/messages.js'; +import { RUNNER_TEMPLATES } from '../runner/messages.js'; import { runnerMockOptions } from '../runner/mock-test-runner.js'; /** @@ -126,7 +126,7 @@ export async function hostMain(options) { log(HostMessage.START_TEST, { id: testSource.info.testId, title: testSource.info.title }); const addLogtoPlan = message => { - if (Object.keys(AGENT_TEMPLATES).includes(message.data.type)) { + if (Object.keys(RUNNER_TEMPLATES).includes(message.data.type)) { plan = addLogToTestPlan(plan, message); plan = addTestLogToTestPlan(plan, test); } diff --git a/src/host/messages.js b/src/host/messages.js index 2c3c4b3..d39df88 100644 --- a/src/host/messages.js +++ b/src/host/messages.js @@ -4,7 +4,7 @@ * @module host */ -import { AGENT_TEMPLATES } from '../runner/messages.js'; +import { RUNNER_TEMPLATES } from '../runner/messages.js'; import { createSharedLogger } from '../shared/messages.js'; /** @enum {AriaATCIHost.HostLogType} */ @@ -76,6 +76,6 @@ export const HOST_TEMPLATES = { * @param {*} messages * @returns {{log: AriaATCIHost.Log, emitter: import("events").EventEmitter}} */ -export function createHostLogger(messages = { ...HOST_TEMPLATES, ...AGENT_TEMPLATES }) { +export function createHostLogger(messages = { ...HOST_TEMPLATES, ...RUNNER_TEMPLATES }) { return createSharedLogger(messages); } diff --git a/src/runner/at-driver.js b/src/runner/at-driver.js index deae8ed..7e5161c 100644 --- a/src/runner/at-driver.js +++ b/src/runner/at-driver.js @@ -1,7 +1,7 @@ import ws from 'ws'; import { iterateEmitter } from '../shared/iterate-emitter.js'; -import { AgentMessage } from './messages.js'; +import { RunnerMessage } from './messages.js'; /** * @param {object} options @@ -20,7 +20,7 @@ export async function createATDriver({ } = {}) { if (!abortSignal) process.exit(1); const url = `ws://${hostname}:${port}${pathname}`; - log(AgentMessage.AT_DRIVER_COMMS, { direction: 'connect', message: url }); + log(RunnerMessage.AT_DRIVER_COMMS, { direction: 'connect', message: url }); const socket = new ws(url); const driver = new ATDriver({ socket, log }); await driver.ready; @@ -47,7 +47,7 @@ export class ATDriver { this.closed = new Promise(resolve => socket.once('close', () => { this.hasClosed = true; - this.log(AgentMessage.AT_DRIVER_COMMS, { direction: 'closed' }); + this.log(RunnerMessage.AT_DRIVER_COMMS, { direction: 'closed' }); resolve(); }) ); @@ -60,7 +60,7 @@ export class ATDriver { } async quit() { - this.log(AgentMessage.AT_DRIVER_COMMS, { direction: 'close' }); + this.log(RunnerMessage.AT_DRIVER_COMMS, { direction: 'close' }); this.socket.close(); await this.closed; } @@ -69,7 +69,7 @@ export class ATDriver { if (this.hasClosed) throw new Error('AT-Driver connection unexpectedly closed'); for await (const rawMessage of iterateEmitter(this.socket, 'message', 'close', 'error')) { const message = rawMessage.toString(); - this.log(AgentMessage.AT_DRIVER_COMMS, { direction: 'inbound', message }); + this.log(RunnerMessage.AT_DRIVER_COMMS, { direction: 'inbound', message }); yield JSON.parse(message); } } @@ -77,7 +77,7 @@ export class ATDriver { async _send(command) { const id = this._nextId++; const rawMessage = JSON.stringify({ id, ...command }); - this.log(AgentMessage.AT_DRIVER_COMMS, { direction: 'outbound', message: rawMessage }); + this.log(RunnerMessage.AT_DRIVER_COMMS, { direction: 'outbound', message: rawMessage }); await new Promise((resolve, reject) => { this.socket.send(rawMessage, error => { if (error) reject(error); diff --git a/src/runner/create-test-runner.js b/src/runner/create-test-runner.js index 57a1796..4d72573 100644 --- a/src/runner/create-test-runner.js +++ b/src/runner/create-test-runner.js @@ -9,7 +9,6 @@ import { MockTestRunner } from './mock-test-runner.js'; import { DriverTestRunner } from './driver-test-runner.js'; import { createBrowserDriver } from './browser-driver/create.js'; import { createATDriver } from './at-driver.js'; -import { AgentMessage } from './messages.js'; /** * @param {object} options diff --git a/src/runner/driver-test-runner.js b/src/runner/driver-test-runner.js index 4871958..a50a93c 100644 --- a/src/runner/driver-test-runner.js +++ b/src/runner/driver-test-runner.js @@ -5,7 +5,7 @@ import { startJob } from '../shared/job.js'; import { ATDriver, ATKey, webDriverCodePoints } from './at-driver.js'; -import { AgentMessage } from './messages.js'; +import { RunnerMessage } from './messages.js'; /** * @module agent @@ -41,7 +41,7 @@ export class DriverTestRunner { * @param {string} options.referencePage */ async openPage({ url, referencePage }) { - await this.log(AgentMessage.OPEN_PAGE, { url }); + await this.log(RunnerMessage.OPEN_PAGE, { url }); await this.browserDriver.navigate(url.toString()); await this.browserDriver.documentReady(); @@ -52,7 +52,7 @@ export class DriverTestRunner { this.timesOption.testSetup ); } catch ({}) { - await this.log(AgentMessage.NO_RUN_TEST_SETUP, { referencePage }); + await this.log(RunnerMessage.NO_RUN_TEST_SETUP, { referencePage }); } } @@ -60,7 +60,7 @@ export class DriverTestRunner { * @param {import('./at-driver.js').ATKeySequence} sequence */ async sendKeys(sequence) { - await this.log(AgentMessage.PRESS_KEYS, { keys: sequence }); + await this.log(RunnerMessage.PRESS_KEYS, { keys: sequence }); await this.atDriver.sendKeys(sequence); } @@ -181,11 +181,11 @@ export class DriverTestRunner { */ async run(test) { const capabilities = await this.collectedCapabilities; - await this.log(AgentMessage.CAPABILITIES, { capabilities }); + await this.log(RunnerMessage.CAPABILITIES, { capabilities }); - await this.log(AgentMessage.START_TEST, { id: test.info.testId, title: test.info.task }); + await this.log(RunnerMessage.START_TEST, { id: test.info.testId, title: test.info.task }); - await this.log(AgentMessage.OPEN_PAGE, { url: 'about:blank' }); + await this.log(RunnerMessage.OPEN_PAGE, { url: 'about:blank' }); await this.browserDriver.navigate('about:blank'); const commandsOutput = []; @@ -215,7 +215,7 @@ export class DriverTestRunner { ); await this._collectSpeech(this.timesOption.afterNav, async () => { - await this.log(AgentMessage.OPEN_PAGE, { url: 'about:blank' }); + await this.log(RunnerMessage.OPEN_PAGE, { url: 'about:blank' }); await this.browserDriver.navigate('about:blank'); }); @@ -232,7 +232,7 @@ export class DriverTestRunner { }); } } else { - await this.log(AgentMessage.INVALID_KEYS, { command, errors }); + await this.log(RunnerMessage.INVALID_KEYS, { command, errors }); commandsOutput.push({ command: command.id, @@ -270,7 +270,7 @@ export class DriverTestRunner { const speechJob = startJob(async signal => { for await (const speech of signal.cancelable(this.atDriver.speeches())) { spoken.push(speech); - this.log(AgentMessage.SPEECH_EVENT, { spokenText: speech }); + this.log(RunnerMessage.SPEECH_EVENT, { spokenText: speech }); } }); diff --git a/src/runner/messages.js b/src/runner/messages.js index 4a533d4..a015664 100644 --- a/src/runner/messages.js +++ b/src/runner/messages.js @@ -2,19 +2,13 @@ /// /** - * @module agent + * @module runner */ import { createSharedLogger } from '../shared/messages.js'; /** @enum {AriaATCIRunner.Message} */ -export const AgentMessage = { - /** @type {'start'} */ - START: 'start', - /** @type {'uncaughtError'} */ - UNCAUGHT_ERROR: 'uncaughtError', - /** @type {'willStop'} */ - WILL_STOP: 'willStop', +export const RunnerMessage = { /** @type {'startTest'} */ START_TEST: 'startTest', /** @type {'openPage'} */ @@ -33,22 +27,21 @@ export const AgentMessage = { CAPABILITIES: 'capabilities', }; -export const AGENT_TEMPLATES = { - [AgentMessage.START]: () => `Starting...`, - [AgentMessage.WILL_STOP]: () => `Stopping...`, - [AgentMessage.START_TEST]: ({ id, title }) => `Starting test #${id} '${title}'.`, - [AgentMessage.OPEN_PAGE]: ({ url }) => `Open page: '${url}'.`, - [AgentMessage.INVALID_KEYS]: ({ command, errors }) => +export const RUNNER_TEMPLATES = { + [RunnerMessage.START_TEST]: ({ id, title }) => `Starting test #${id} '${title}'.`, + [RunnerMessage.OPEN_PAGE]: ({ url }) => `Open page: '${url}'.`, + [RunnerMessage.INVALID_KEYS]: ({ command, errors }) => `Keys in '${command.id}' have issues:\n${errors.map(error => `- ${error}`).join('\n')}`, - [AgentMessage.PRESS_KEYS]: ({ keys }) => `Press keys: '${keys.toString()}'.`, - [AgentMessage.SPEECH_EVENT]: ({ spokenText }) => `Speech event: '${spokenText}'.`, - [AgentMessage.NO_RUN_TEST_SETUP]: ({ referencePage }) => + [RunnerMessage.PRESS_KEYS]: ({ keys }) => `Press keys: '${keys.toString()}'.`, + [RunnerMessage.SPEECH_EVENT]: ({ spokenText }) => `Speech event: '${spokenText}'.`, + [RunnerMessage.NO_RUN_TEST_SETUP]: ({ referencePage }) => `Test reference, ${referencePage}, does not have a Run Test Setup button.`, - [AgentMessage.AT_DRIVER_COMMS]: ({ direction, message }) => `AT-Driver: ${direction}: ${message}`, - [AgentMessage.CAPABILITIES]: ({ capabilities }) => + [RunnerMessage.AT_DRIVER_COMMS]: ({ direction, message }) => + `AT-Driver: ${direction}: ${message}`, + [RunnerMessage.CAPABILITIES]: ({ capabilities }) => `Capabilities: ${JSON.stringify(capabilities)}`, }; -export function createAgentLogger(messages = AGENT_TEMPLATES) { +export function createRunnerLogger(messages = RUNNER_TEMPLATES) { return createSharedLogger(messages); } diff --git a/src/runner/mock-test-runner.js b/src/runner/mock-test-runner.js index 8f66049..31254fe 100644 --- a/src/runner/mock-test-runner.js +++ b/src/runner/mock-test-runner.js @@ -7,7 +7,7 @@ */ import { request } from 'http'; -import { AgentMessage } from './messages.js'; +import { RunnerMessage } from './messages.js'; import { validateKeysFromCommand } from './driver-test-runner.js'; /** @@ -49,7 +49,7 @@ export class MockTestRunner { ); } - this.log(AgentMessage.OPEN_PAGE, { url }); + this.log(RunnerMessage.OPEN_PAGE, { url }); } /** @@ -95,7 +95,7 @@ export class MockTestRunner { }); } } else { - await this.log(AgentMessage.INVALID_KEYS, { command, errors }); + await this.log(RunnerMessage.INVALID_KEYS, { command, errors }); commandsOutput.push({ command: command.id, From d9a2019211a558f6880e6700712e860eb12ddbcb Mon Sep 17 00:00:00 2001 From: Chris Cuellar <58723+ChrisC@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:33:23 -0700 Subject: [PATCH 12/18] coerces server baseUrl into JS URL --- src/host/main.js | 2 +- src/runner/create-test-runner.js | 2 +- src/runner/driver-test-runner.js | 6 ++---- src/runner/mock-test-runner.js | 5 ++--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/host/main.js b/src/host/main.js index 6031bce..6092f48 100644 --- a/src/host/main.js +++ b/src/host/main.js @@ -82,7 +82,7 @@ export async function hostMain(options) { emitter.on(HostMessage.STOP_RUNNER, () => resolve()); }), timesOption, - baseUrl: serverDirectory.baseUrl, + baseUrl: new URL(serverDirectory.baseUrl.toString()), mock: runnerMockOptions({ mock: runnerMock, mockOpenPage: runnerMockOpenPage, diff --git a/src/runner/create-test-runner.js b/src/runner/create-test-runner.js index 4d72573..4dde0d4 100644 --- a/src/runner/create-test-runner.js +++ b/src/runner/create-test-runner.js @@ -13,7 +13,7 @@ import { createATDriver } from './at-driver.js'; /** * @param {object} options * @param {{hostname: string, port: number | string, pathname: string}} options.atDriverUrl - * @param {AriaATCIShared.BaseURL} options.baseUrl + * @param {URL} options.baseUrl * @param {AriaATCIHost.Log} options.log * @param {Promise} options.abortSignal * @param {AriaATCIRunner.MockOptions} [options.mock] diff --git a/src/runner/driver-test-runner.js b/src/runner/driver-test-runner.js index a50a93c..c438a1d 100644 --- a/src/runner/driver-test-runner.js +++ b/src/runner/driver-test-runner.js @@ -14,7 +14,7 @@ import { RunnerMessage } from './messages.js'; export class DriverTestRunner { /** * @param {object} options - * @param {AriaATCIShared.BaseURL} options.baseUrl + * @param {URL} options.baseUrl * @param {AriaATCIHost.Log} options.log * @param {BrowserDriver} options.browserDriver * @param {ATDriver} options.atDriver @@ -288,10 +288,8 @@ export class DriverTestRunner { } _appendBaseUrl(pathname) { - // protocol ends with a ':' and pathname starts with a '/' - const base = `${this.baseUrl.protocol}://${this.baseUrl.hostname}:${this.baseUrl.port}${this.baseUrl.pathname}`; const newPath = `${this.baseUrl.pathname ? `${this.baseUrl.pathname}/` : ''}${pathname}`; - return new URL(newPath, base); + return new URL(newPath, this.baseUrl.toString()); } } diff --git a/src/runner/mock-test-runner.js b/src/runner/mock-test-runner.js index 31254fe..d93c891 100644 --- a/src/runner/mock-test-runner.js +++ b/src/runner/mock-test-runner.js @@ -16,7 +16,7 @@ import { validateKeysFromCommand } from './driver-test-runner.js'; export class MockTestRunner { /** * @param {object} options - * @param {AriaATCIShared.BaseURL} options.baseUrl + * @param {URL} options.baseUrl * @param {AriaATCIHost.Log} options.log * @param {AriaATCIRunner.MockOptions} options.mock */ @@ -64,11 +64,10 @@ export class MockTestRunner { * @param {AriaATCIData.CollectedTest} task */ async run(task) { - const base = `${this.baseUrl.protocol}://${this.baseUrl.hostname}:${this.baseUrl.port}${this.baseUrl.pathname}`; await this.openPage( new URL( `${this.baseUrl.pathname ? `${this.baseUrl.pathname}/` : ''}${task.target.referencePage}`, - base + this.baseUrl.toString() ) ); From aa92906463e2dd1f6387bd0489d9f239e99db136 Mon Sep 17 00:00:00 2001 From: Chris Cuellar <58723+ChrisC@users.noreply.github.com> Date: Thu, 8 Aug 2024 11:22:48 -0700 Subject: [PATCH 13/18] Update src/host/README.md Co-authored-by: jugglinmike --- src/host/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/host/README.md b/src/host/README.md index d05de6a..d80e2ff 100644 --- a/src/host/README.md +++ b/src/host/README.md @@ -15,10 +15,10 @@ Removing reference from 'http://localhost:52147/gtmoyv'. Stopping... ``` -Developing `bin/host.js` you may want to use the mock test runner. Calling `host.js` with `--agent-mock` will enable the mock test runner. +Developing `bin/host.js` you may want to use the mock test runner. Calling `host.js` with `--runner-mock` will enable the mock test runner. ```sh -$ bin/host.js run-plan --agent-mock reference/** at/** >result.json +$ bin/host.js run-plan --runner-mock reference/** at/** >result.json ... ``` From 1410bd10b436303de3b56801044698f4d31e474c Mon Sep 17 00:00:00 2001 From: Chris Cuellar <58723+ChrisC@users.noreply.github.com> Date: Thu, 8 Aug 2024 14:09:44 -0700 Subject: [PATCH 14/18] leaks promise resolver instead of event emitter to stop drivers. --- src/host/main.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/host/main.js b/src/host/main.js index 6092f48..bf7dea9 100644 --- a/src/host/main.js +++ b/src/host/main.js @@ -75,12 +75,13 @@ export async function hostMain(options) { const timesOption = getTimesOption(options); - const emitter = new EventEmitter(); + let stopDrivers = v => {}; + const abortSignal = new Promise(resolve => { + stopDrivers = resolve; + }); const runner = await createRunner({ log, - abortSignal: new Promise(resolve => { - emitter.on(HostMessage.STOP_RUNNER, () => resolve()); - }), + abortSignal, timesOption, baseUrl: new URL(serverDirectory.baseUrl.toString()), mock: runnerMockOptions({ @@ -164,7 +165,7 @@ export async function hostMain(options) { await lastCallbackRequest; - emitter.emit(HostMessage.STOP_RUNNER); + stopDrivers(); await emitPlanResults(plan); } From d98cd581122e414ee64e79a7771df1e2935471c2 Mon Sep 17 00:00:00 2001 From: Chris Cuellar <58723+ChrisC@users.noreply.github.com> Date: Thu, 8 Aug 2024 14:12:21 -0700 Subject: [PATCH 15/18] [cleanup] removes additional agent logs --- src/host/messages.js | 17 -------- src/host/tests/messages.js | 7 +--- src/host/tests/snapshots/messages.js.md | 47 ---------------------- src/host/tests/snapshots/messages.js.snap | Bin 1069 -> 894 bytes src/host/types.js | 5 --- 5 files changed, 1 insertion(+), 75 deletions(-) diff --git a/src/host/messages.js b/src/host/messages.js index d39df88..e824a41 100644 --- a/src/host/messages.js +++ b/src/host/messages.js @@ -29,18 +29,6 @@ export const HostMessage = { REMOVE_SERVER_DIRECTORY: 'removeServerDirectory', /** @type {'serverLog'} */ SERVER_LOG: 'serverLog', - /** @type {'startAgent'} */ - START_AGENT: 'startAgent', - /** @type {'agentProtocol'} */ - AGENT_PROTOCOL: 'agentProtocol', - /** @type {'stopAgent'} */ - STOP_AGENT: 'stopAgent', - /** @type {'stopRunner'} */ - STOP_RUNNER: 'stopRunner', - /** @type {'agentLog'} */ - AGENT_LOG: 'agentLog', - /** @type {'agentCrashed'} */ - AGENT_CRASHED: 'agentCrashed', /** @type {'startTest'} */ START_TEST: 'startTest', /** @type {'reportingError'} */ @@ -61,11 +49,6 @@ export const HOST_TEMPLATES = { [HostMessage.ADD_SERVER_DIRECTORY]: ({ url }) => `Reference available on '${url}'.`, [HostMessage.REMOVE_SERVER_DIRECTORY]: ({ url }) => `Removing reference from '${url}'.`, [HostMessage.SERVER_LOG]: ({ text }) => `[Server]: ${text}`, - [HostMessage.START_AGENT]: () => `Starting test agent.`, - [HostMessage.AGENT_PROTOCOL]: ({ protocol }) => `Agent running with protocol '${protocol}'.`, - [HostMessage.STOP_AGENT]: () => `Stopping test agent.`, - [HostMessage.AGENT_LOG]: ({ text }) => `[Agent]: ${text}`, - [HostMessage.AGENT_CRASHED]: () => `Agent crashed.`, [HostMessage.START_TEST]: () => `Starting test.`, [HostMessage.TEST_ERROR]: ({ error }) => `Test Error ${error}`, [HostMessage.REPORTING_ERROR]: ({ status, body }) => diff --git a/src/host/tests/messages.js b/src/host/tests/messages.js index 0b4c4e7..6067994 100644 --- a/src/host/tests/messages.js +++ b/src/host/tests/messages.js @@ -3,7 +3,7 @@ import test from 'ava'; import { HostMessage, createHostLogger } from '../messages.js'; test('log', async t => { - t.plan(16); + t.plan(11); const { log, emitter } = createHostLogger(); const logAndResolveMessage = async (type, more) => { const message = await new Promise(resolve => { @@ -59,10 +59,5 @@ test('log', async t => { t.snapshot( await logAndResolveMessage(HostMessage.SERVER_LOG, { text: `Served file 'test.json'.` }) ); - t.snapshot(await logAndResolveMessage(HostMessage.START_AGENT)); - t.snapshot(await logAndResolveMessage(HostMessage.AGENT_PROTOCOL, { protocol: 'fork' })); - t.snapshot(await logAndResolveMessage(HostMessage.STOP_AGENT)); - t.snapshot(await logAndResolveMessage(HostMessage.AGENT_LOG, { text: 'Starting test.' })); - t.snapshot(await logAndResolveMessage(HostMessage.AGENT_CRASHED)); t.snapshot(await logAndResolveMessage(HostMessage.START_TEST)); }); diff --git a/src/host/tests/snapshots/messages.js.md b/src/host/tests/snapshots/messages.js.md index 20a2bef..9b133cd 100644 --- a/src/host/tests/snapshots/messages.js.md +++ b/src/host/tests/snapshots/messages.js.md @@ -115,53 +115,6 @@ Generated by [AVA](https://avajs.dev). > Snapshot 11 - { - data: { - type: 'startAgent', - }, - text: 'Starting test agent.', - } - -> Snapshot 12 - - { - data: { - protocol: 'fork', - type: 'agentProtocol', - }, - text: 'Agent running with protocol \'fork\'.', - } - -> Snapshot 13 - - { - data: { - type: 'stopAgent', - }, - text: 'Stopping test agent.', - } - -> Snapshot 14 - - { - data: { - text: 'Starting test.', - type: 'agentLog', - }, - text: '[Agent]: Starting test.', - } - -> Snapshot 15 - - { - data: { - type: 'agentCrashed', - }, - text: 'Agent crashed.', - } - -> Snapshot 16 - { data: { type: 'startTest', diff --git a/src/host/tests/snapshots/messages.js.snap b/src/host/tests/snapshots/messages.js.snap index 8310ef8ad7915db1799fb4767ece821565102579..ac32f575953d93d5ec81b8c796084c7c46150680 100644 GIT binary patch literal 894 zcmV-^1A+WORzVP!FOUbX=pD(Re10K(lr$CLmh5D4W;1CSg48j;?S>pnu z3&fGgFCfuNh>zQoQ^@Nz$Z?sk73ZFc2R*Ky96+&Qq-jTxiv|#Jxh{d#5b6G?Sx-Al zgmYX7AQFm=XOa)QY7$y5@32XdiiG82EiA3mm7((Z-+1N4Cf^d;G7A;XUjvDTS z8`v>noVRSk4MwnOK;g_ssguo#mVeXYO_mbEu|!|t7v*gc63f>E&;E=y>fl7J8hy(I)!m5NRhx-5aC=TtG+t{?s>YMaIB#O_%P&_kL z$IP%TE{Nljrr_S95asO12%IO_E>bSC$3~Bz7%5{>RQ}Yz0NQs5eS1&FTJ<5N;IH`T zlFC4h!}JQXW!KNa;&?rp-l*%4;dV`iq@dG+$=ri#zYJDnuH*!4ufn2^Yr9|q`8?01WRyX@j9!~AZ@)?l6LBu1< za*(-2kVeW3HBx2_7B9D}4Bkm)1|uo65=NOrw^To7vxXd)^8TQ%7nylZz59ax8j`+) zSa0hF+8l47IZAWoy1Y%C7Q8L)!C~zdYYbN$ljJQ2D5Qg->QU?!$s(#&T#}Yn1qC4p6nd!uB~${T z2su06-60cuWqT8HLLhPE>kj}CDsd^jz@fAfaH>=!P*rk3^w0xv;LaZaKif0IW|M3( za>z>7db~65`TgD-+dESoi+E*RUc5t9s3Ka4crBESG-RDCd3`1bh$5%{^1Zd5{-7fA zcfMx4XOBLmNGm^H3K;lW^l^B4HCumX71FHL z6{bRPF^CTdK2Dioz6U_}p*>w%oMnFB!kjmFoiuN3#?(jboxLd6hdgf=(riGHH{*ub zc9Ea-7OUyn2`VM2r4$9LCJxEps~QsCXsmEZic?_}Y2YL$e>w^JHH)BwCnCadSy8FV zcq&wN{594W5)&3czZynVVnIoOtAbBp$(y1=akaU}n9a`18%2X`dv7PwTUf-p0QM6S)wxuI-|YVOyMYE#b(>HBUtoI)&0ji` zxlVN`S^A$6b|a;?C1HM3M5gKoVDLygo4-)i0pV;5LQ(M%B@Fg0s(8ti;FY5%lIA8DLEQ>q0E?&fWEnYHboeFdzOMy10o3)-Sh9fOgcCpkO z;yw4p63~Y<))_Q`}GQ^*>Ifn9fp)E}Q*|AhJ#a>+fv-y3meON<0R{P7Fl1- nU9S3?ETGkp!HQc>yY{8d{SLT~+|vwnCxPlCr27lk9ufcmA>R3} diff --git a/src/host/types.js b/src/host/types.js index ed52bc7..dcc7fe1 100644 --- a/src/host/types.js +++ b/src/host/types.js @@ -18,11 +18,6 @@ * | 'addServerDirectory' * | 'removeServerDirectory' * | 'serverLog' - * | 'startAgent' - * | 'agentProtocol' - * | 'stopAgent' - * | 'agentLog' - * | 'agentCrashed' * | 'startTest' * | 'reportingError' * | 'testError' From 019a729d68db3392c45dea01105e584e5961a6fd Mon Sep 17 00:00:00 2001 From: Chris Cuellar <58723+ChrisC@users.noreply.github.com> Date: Thu, 8 Aug 2024 15:36:46 -0700 Subject: [PATCH 16/18] [minor] add logs when drivers are stopped --- src/host/main.js | 3 ++- src/host/messages.js | 3 +++ src/host/types.js | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/host/main.js b/src/host/main.js index bf7dea9..731c378 100644 --- a/src/host/main.js +++ b/src/host/main.js @@ -75,7 +75,8 @@ export async function hostMain(options) { const timesOption = getTimesOption(options); - let stopDrivers = v => {}; + let stopDrivers = any => log(HostMessage.STOP_DRIVERS); + const abortSignal = new Promise(resolve => { stopDrivers = resolve; }); diff --git a/src/host/messages.js b/src/host/messages.js index e824a41..3baa2fd 100644 --- a/src/host/messages.js +++ b/src/host/messages.js @@ -23,6 +23,8 @@ export const HostMessage = { SERVER_LISTENING: 'serverListening', /** @type {'stopServer'} */ STOP_SERVER: 'stopServer', + /** @type {'stopDrivers'} */ + STOP_DRIVERS: 'stopDrivers', /** @type {'addServerDirectory'} */ ADD_SERVER_DIRECTORY: 'addServerDirectory', /** @type {'removeServerDirectory'} */ @@ -46,6 +48,7 @@ export const HOST_TEMPLATES = { [HostMessage.START_SERVER]: () => `Starting reference server.`, [HostMessage.SERVER_LISTENING]: ({ url }) => `Reference server listening on '${url}'.`, [HostMessage.STOP_SERVER]: () => `Stopping reference server.`, + [HostMessage.STOP_DRIVERS]: () => `Stopping drivers.`, [HostMessage.ADD_SERVER_DIRECTORY]: ({ url }) => `Reference available on '${url}'.`, [HostMessage.REMOVE_SERVER_DIRECTORY]: ({ url }) => `Removing reference from '${url}'.`, [HostMessage.SERVER_LOG]: ({ text }) => `[Server]: ${text}`, diff --git a/src/host/types.js b/src/host/types.js index dcc7fe1..0b8fba3 100644 --- a/src/host/types.js +++ b/src/host/types.js @@ -15,6 +15,7 @@ * | 'planRead' * | 'serverListening' * | 'stopServer' + * | 'stopDrivers' * | 'addServerDirectory' * | 'removeServerDirectory' * | 'serverLog' From 75b5aa1218c59bcd51a49880d890761d5a47474e Mon Sep 17 00:00:00 2001 From: Chris Cuellar <58723+ChrisC@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:15:24 -0700 Subject: [PATCH 17/18] removes mock runner config options --- src/host/cli-run-plan.js | 4 --- src/host/main.js | 9 +---- src/runner/create-test-runner.js | 4 +-- src/runner/mock-test-runner.js | 61 +++++++++++--------------------- src/runner/types.js | 6 ---- 5 files changed, 23 insertions(+), 61 deletions(-) diff --git a/src/host/cli-run-plan.js b/src/host/cli-run-plan.js index da70201..095f65b 100644 --- a/src/host/cli-run-plan.js +++ b/src/host/cli-run-plan.js @@ -95,10 +95,6 @@ export const builder = (args = yargs) => type: 'boolean', hidden: true, }, - 'runner-mock-open-page': { - choices: ['request', 'skip'], - hidden: true, - }, 'callback-url': { describe: 'URL to POST test results to as they complete', }, diff --git a/src/host/main.js b/src/host/main.js index 731c378..13245a0 100644 --- a/src/host/main.js +++ b/src/host/main.js @@ -4,7 +4,6 @@ * @module host */ -import { EventEmitter } from 'events'; import { createRunner } from '../runner/create-test-runner.js'; import { HostMessage } from './messages.js'; @@ -16,7 +15,6 @@ import { } from './plan-object.js'; import { getTimesOption } from '../shared/times-option.js'; import { RUNNER_TEMPLATES } from '../runner/messages.js'; -import { runnerMockOptions } from '../runner/mock-test-runner.js'; /** * @param {AriaATCIHost.Log} log @@ -42,7 +40,6 @@ const logUnsuccessfulHTTP = async (log, response) => { * @param {Record} [options.callbackHeader] * @param {typeof fetch} options.fetch * @param {boolean} options.runnerMock - * @param {'request' | 'skip'} options.runnerMockOpenPage * @param {AriaATCIShared.BaseURL} options.webDriverUrl * @param {AriaATCIRunner.Browser} options.webDriverBrowser * @param {AriaATCIShared.BaseURL} options.atDriverUrl @@ -56,7 +53,6 @@ export async function hostMain(options) { callbackUrl, callbackHeader, runnerMock, - runnerMockOpenPage, webDriverUrl, webDriverBrowser, atDriverUrl, @@ -85,10 +81,7 @@ export async function hostMain(options) { abortSignal, timesOption, baseUrl: new URL(serverDirectory.baseUrl.toString()), - mock: runnerMockOptions({ - mock: runnerMock, - mockOpenPage: runnerMockOpenPage, - }), + mock: runnerMock, webDriverUrl, webDriverBrowser, atDriverUrl, diff --git a/src/runner/create-test-runner.js b/src/runner/create-test-runner.js index 4dde0d4..6c07b7a 100644 --- a/src/runner/create-test-runner.js +++ b/src/runner/create-test-runner.js @@ -16,7 +16,7 @@ import { createATDriver } from './at-driver.js'; * @param {URL} options.baseUrl * @param {AriaATCIHost.Log} options.log * @param {Promise} options.abortSignal - * @param {AriaATCIRunner.MockOptions} [options.mock] + * @param {boolean} [options.mock] * @param {AriaATCIRunner.Browser} [options.webDriverBrowser] * @param {AriaATCIShared.timesOption} options.timesOption * @param {{toString: function(): string}} options.webDriverUrl @@ -26,7 +26,7 @@ export async function createRunner(options) { const { abortSignal, log, timesOption } = options; if (options.mock) { - return new MockTestRunner({ mock: options.mock, ...options }); + return new MockTestRunner(options); } await new Promise(resolve => setTimeout(resolve, 1000)); diff --git a/src/runner/mock-test-runner.js b/src/runner/mock-test-runner.js index d93c891..35af8cb 100644 --- a/src/runner/mock-test-runner.js +++ b/src/runner/mock-test-runner.js @@ -18,36 +18,32 @@ export class MockTestRunner { * @param {object} options * @param {URL} options.baseUrl * @param {AriaATCIHost.Log} options.log - * @param {AriaATCIRunner.MockOptions} options.mock */ - constructor({ baseUrl, log, mock: config }) { + constructor({ baseUrl, log }) { this.baseUrl = baseUrl; this.log = log; - this.config = config; } async openPage(url) { - if (this.config.openPage === 'request') { - await new Promise((resolve, reject) => - request(url.toString(), res => { - try { - res - .on('data', () => {}) - .on('error', reject) - .setEncoding('utf8') - .on('end', () => { - res.statusCode < 400 - ? resolve() - : reject(new Error(`request returned ${res.statusCode}`)); - }); - } catch (e) { - reject(e); - } - }) - .on('error', reject) - .end() - ); - } + await new Promise((resolve, reject) => + request(url.toString(), res => { + try { + res + .on('data', () => {}) + .on('error', reject) + .setEncoding('utf8') + .on('end', () => { + res.statusCode < 400 + ? resolve() + : reject(new Error(`request returned ${res.statusCode}`)); + }); + } catch (e) { + reject(e); + } + }) + .on('error', reject) + .end() + ); this.log(RunnerMessage.OPEN_PAGE, { url }); } @@ -128,20 +124,3 @@ export class MockTestRunner { }; } } - -/** - * Summarize cli options as mock options for creating a test runner. - * @param {object} options - * @param {boolean} options.mock - * @param {'request' | 'skip'} options.mockOpenPage - * @returns {AriaATCIRunner.MockOptions} - */ -export function runnerMockOptions({ mock, mockOpenPage }) { - if (mock === undefined && mockOpenPage) { - mock = true; - } - if (mock) { - return { openPage: mockOpenPage ? mockOpenPage : 'request' }; - } - return undefined; -} diff --git a/src/runner/types.js b/src/runner/types.js index 5b3c87e..07e0ebc 100644 --- a/src/runner/types.js +++ b/src/runner/types.js @@ -37,11 +37,6 @@ * @returns {Promise} */ -/** - * @typedef AriaATCIRunner.MockOptions - * @property {'request' | 'skip'} [openPage] - */ - /** * @typedef {'chrome' | 'firefox' | 'safari'} AriaATCIRunner.Browser */ @@ -53,7 +48,6 @@ * @property {AriaATCIRunner.Message[]} [verbose] * @property {AriaATCIShared.BaseURL} [referenceBaseUrl] * @property {boolean} [mock] - * @property {'request' | 'skip'} [mockOpenPage] * @property {AriaATCIShared.BaseURL} [webDriverUrl] * @property {AriaATCIRunner.Browser} [webDriverBrowser] * @property {AriaATCIShared.BaseURL} [atDriverUrl] From 1658da96ed7e17bea552d3c68af5fb8abda907ef Mon Sep 17 00:00:00 2001 From: Chris Cuellar <58723+ChrisC@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:53:37 -0700 Subject: [PATCH 18/18] =?UTF-8?q?adds=20STOP=5FDRIVER=20logs=20(?= =?UTF-8?q?=F0=9F=8E=AC=20take=202)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/host/main.js | 9 ++++++--- src/host/tests/snapshots/cli-run-plan.js.md | 7 +++++++ src/host/tests/snapshots/cli-run-plan.js.snap | Bin 1408 -> 1415 bytes 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/host/main.js b/src/host/main.js index 13245a0..e541640 100644 --- a/src/host/main.js +++ b/src/host/main.js @@ -71,11 +71,14 @@ export async function hostMain(options) { const timesOption = getTimesOption(options); - let stopDrivers = any => log(HostMessage.STOP_DRIVERS); - + let stopDrivers = any => {}; const abortSignal = new Promise(resolve => { - stopDrivers = resolve; + stopDrivers = () => { + log(HostMessage.STOP_DRIVERS); + resolve(); + }; }); + const runner = await createRunner({ log, abortSignal, diff --git a/src/host/tests/snapshots/cli-run-plan.js.md b/src/host/tests/snapshots/cli-run-plan.js.md index 028747d..0ac34f4 100644 --- a/src/host/tests/snapshots/cli-run-plan.js.md +++ b/src/host/tests/snapshots/cli-run-plan.js.md @@ -20,6 +20,7 @@ Generated by [AVA](https://avajs.dev). [Server]: Serving '/static/index.html'.␊ Open page: 'http://localhost:8888/static/index.html'.␊ Removing reference from 'http://localhost:8888/static␊ + Stopping drivers.␊ Stopping reference server.␊ Stopping...␊ `, @@ -43,6 +44,7 @@ Generated by [AVA](https://avajs.dev). [Server]: Serving '/static/reference/index.html'.␊ Open page: 'http://localhost:8888/static/reference/index.html'.␊ Removing reference from 'http://localhost:8888/static␊ + Stopping drivers.␊ Stopping reference server.␊ Stopping...␊ `, @@ -66,6 +68,7 @@ Generated by [AVA](https://avajs.dev). [Server]: Serving '/static/reference/index.html'.␊ Open page: 'http://localhost:8888/static/reference/index.html'.␊ Removing reference from 'http://localhost:8888/static␊ + Stopping drivers.␊ Stopping reference server.␊ Stopping...␊ `, @@ -89,6 +92,7 @@ Generated by [AVA](https://avajs.dev). [Server]: Serving '/static/reference/index.html'.␊ Open page: 'http://localhost:8888/static/reference/index.html'.␊ Removing reference from 'http://localhost:8888/static␊ + Stopping drivers.␊ Stopping reference server.␊ Stopping...␊ `, @@ -132,6 +136,7 @@ Generated by [AVA](https://avajs.dev). [Server]: Serving '/static/reference/index.html'.␊ Open page: 'http://localhost:8888/static/reference/index.html'.␊ Removing reference from 'http://localhost:8888/static␊ + Stopping drivers.␊ Stopping reference server.␊ Stopping...␊ `, @@ -179,6 +184,7 @@ Generated by [AVA](https://avajs.dev). Open page: 'http://localhost:8888/static/reference/index.html'.␊ Removing reference from 'http://localhost:8888/static␊ HTTP 418 response received when reporting result: 'a body'.␊ + Stopping drivers.␊ Stopping reference server.␊ Stopping...␊ `, @@ -226,6 +232,7 @@ Generated by [AVA](https://avajs.dev). Open page: 'http://localhost:8888/static/reference/index.html'.␊ Removing reference from 'http://localhost:8888/static␊ HTTP 418 response received when reporting result: 'Unknown error - unable to read response body.'.␊ + Stopping drivers.␊ Stopping reference server.␊ Stopping...␊ `, diff --git a/src/host/tests/snapshots/cli-run-plan.js.snap b/src/host/tests/snapshots/cli-run-plan.js.snap index bf2cdb566d78e54af6277d64f00c36f26da09362..5a15f78fb611179d4b740741a8f37174ebe02147 100644 GIT binary patch literal 1415 zcmV;21$g>FRzVCx5^fAc31uJ8y6JsebA9^jC7sNlc6bsQ}4tB1|y+{Zcj(H?5c7W`df*`*Q6yh?fh|dbv36w%4thE?Ney8^tra2(;h%I7Y<>p|GMQn`d<-+c3pOJo3XTGL5*X;j z6&++DLAc-u2M&6Q+O9`9Vgx&=&8Uw!jTp>gv?)6>hUdk{*!6JJBk!KD#03^^D?czi zo(O$eK}P&gf$&nDde`0Iu z6W54O<3ZVZyy9ry7AG2pvX{eLu#KA+CG5(2UsTC#NXZ-;i9zQ4{oqUwuupVb@2|XG z(Bn1N?SnI2u6T$=2dZUZv0}dFR5tPGVcbBbwQis3;xv?FP>9Gb1O!?@jV!Us<#MrH zfp5KH+2t~PO(^;iT13o)26qgc-jjB91@ssz?0T7*8*LO|&^W4$xNPzSd%M?bU--S3Rc}Fl7I&XE=tJHx=H-xhULK0iWDD2B9l$K!* zy#$NMjgt*J^cwI}xSkZ&;w6POpGi^Js=nMAB|nBc+@30zhfm2GCpjNR$(y)KoH>n5 zCP*Pu);4C2p{r~PH=^E5^J{HLUkl0I3KK82B_4=*VJ zH1m5cI|8VmE=mR|8Kh)T<~_KOL0uH|d8ikJgn$QW7bP z66sBTbCBZS5Yg(O7xAfOBh^$H3R`12lJCJDLfsM|Pu}K3+VNtBZv0=a%I1D|v6`!#sd9fOW zc+F&}<6gE8$F&=J#BNa!s!=cBo2Cmhx%AHCwpo3#`~7x(drOaRs*na;nsIQGG-_ll z$X53AWLDy6k~|rfHq%NOMPG`(6n!cBQuL+h>yGrrQ{XFwx3(2;Dc;H=Z~Zos2(2st zaEZ-@#&o? z;ys$4Ii?sBB zUMOaH6Q=;@ziGhvB z+)+a@B^dr=5^{JFzi+H>6*sC|uQH6r6FHJOAet#Ck00te!{&(`$z0ATh*l7-AbQ@? VMM1QJ=mm%9{{ey21N|CP007A?qwD|x literal 1408 zcmV-`1%LWMRzVIOte zSKA1+0}Qb@w#W6115w09ueMSjqS`)3AE1|&+V^SC*uX;KO#*~~=@6p$7P%)>sjC}%&vZM87RuQn^|nGZAKqiibc2K?QD-yhd9 znNO9CPn3;v<27k=MHyahZEaVTsz`8;I?w30I+9V)elORTda}prOW}JBN7Eupr7U#ZMD1gJ*u_)u_4tz8{TLGVu7J6qM?RXmM z*xW(};)HRAu-8J{sBJrhp@85PY6sLsjD`V>qP1yorj3q^&#~>`hC|*zV1aSW?Phl1 zcr+0Dtc0}aq6Gb&97XQeO(ZUajn;2fu)P-P>K1n$uq*q-Lq0ww=FMY`x4JU0(I42D z`@mJ=(x}s5n6D_Cx8;fY{&=f+cJ<*aG4}~|LPI{NlfNEasvdTUYO4KtRJ!>W05 zsfzjaF}L8gc$hEguNf644n2(wL=mgzrOGdS(FcY2D-b?dz#H+zC>D$PVhO&rl3^B$ z@YUhb_h1nQ4j9}qO=?g0)#cD)swAtudQJ@p3!Q#wBA(|h)hy-ICiZc|c5H4FCW2`M zv;(O;jPv5cItFk155FS;vmphhTGET~81r#6%&%I&%IB~i+)+CSrb%5F7E$a>{{~(k zSAN*7R?9D;Axx7W@_rN2Lh(IYE+3Gk**Ir2c#tODxk0mLtl7?8MNX-NNyZ# z(4bd`pWOALFjlW9jO8qf+^TBSCQdnIt%VnOSfYA3|_ET_V9TJawm30Pkr(od}teGYb?ZXk)2`Nm9b5S-#1M zmttjQ#L9vSMGBZS3z&Hq&HP2p+{=Dk=xiqloqwdzkwRzrg-&iFp~DJN?kxNiOOM>? zmx~lVQuIjClllnWiJmTsR8K4%pbMvgn`g+Q2)u+L0_@T5Uo7jPe+4SVdoN;{F95RQhh z4XV}S!^7u?U#q>y+=8-#z1~EZNZX?x6fDozV3W|G5A6Gn-HdkBf;dLCTr@)>u~942 zh0WRa9bz`A1Fump+nZ+y3pwJ3dD|<$sC;`+JJ?sFbIGS36K{mgpsQ_3SCX!lpRRtLNOG1|0Iw#EA$7WW zDfr4*0l=CxhSXJxBrHi-lCV-zE|Rb$Vf{Y{tE(mbH!C1Ng+iitEE^8)Hed%!z^;Fj zu&cX1D|VsvRm84uYPAY_TG~May#NW&81Dr$Pj3_6q>EipjyjwGg)eIdN45M>ZMSxO^o8(x5zyI%#}{{EhI@29bp$ab zHavWC?+q~*;(F@pVs^3|$+JXAiI5T@B|=Jsln8lOgxtF$LdF&tZlHoL-sxj;5?{y5 zkN!@=%O@YqikE*#yo{;iIQAYvZeXe9QRqcpa2k6(Ha+?ZQ0S!bu4GCdjA