-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
303 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
function dynamicMinimalReporter (eventbus, logger) { | ||
/** | ||
* @typedef {Object} ClientState | ||
* @property {string} clientId | ||
* @property {string} displayName | ||
* @property {string} status | ||
* @property {null|string} lastline | ||
* @property {Array} failures | ||
*/ | ||
|
||
/** @type {Object<string,ClientState[]> */ | ||
const clientsByFile = Object.create(null); | ||
/** @type {Object<string,ClientState> */ | ||
const clientsById = Object.create(null); | ||
|
||
let screen = ''; | ||
|
||
function render () { | ||
const icons = { waiting: '⢎', progress: '⠧', success: '✔', failure: '✘' }; | ||
let str = ''; | ||
for (const testFile in clientsByFile) { | ||
str += `\nRunning ${testFile}\n`; | ||
for (const client of clientsByFile[testFile]) { | ||
str += `* ${client.displayName} ${icons[client.status]} ${client.lastline || ''}\n`; | ||
} | ||
} | ||
|
||
if (screen) { | ||
const oldHeight = screen.split('\n').length; | ||
for (let i = 1; i < oldHeight; i++) { | ||
process.stdout.write('\x1b[A\x1b[K'); | ||
} | ||
} | ||
|
||
process.stdout.write(str); | ||
screen = str; | ||
} | ||
|
||
eventbus.on('clientcreate', (event) => { | ||
const client = { | ||
clientId: event.clientId, | ||
displayName: event.displayName, | ||
status: 'waiting', | ||
lastline: null, | ||
failures: [] | ||
}; | ||
|
||
clientsByFile[event.testFile] ??= []; | ||
clientsByFile[event.testFile].push(client); | ||
clientsById[event.clientId] = client; | ||
render(); | ||
}); | ||
|
||
eventbus.on('clientonline', (event) => { | ||
clientsById[event.clientId].status = 'progress'; | ||
render(); | ||
}); | ||
|
||
eventbus.on('clientsample', (event) => { | ||
clientsById[event.clientId].lastline = event.line; | ||
render(); | ||
}); | ||
|
||
eventbus.on('clientend', (event) => { | ||
clientsById[event.clientId].status = 'failure'; | ||
clientsById[event.clientId].lastline = event.reason; | ||
render(); | ||
}); | ||
} | ||
|
||
function flatMinimalReporter (eventbus) { | ||
eventbus.on('createclient', (client) => { | ||
console.log(`Running ${client.testFile}`); | ||
console.log(`* ${client.displayName}`); | ||
}); | ||
} | ||
|
||
const isTTY = process.stdout.isTTY && process.env.TERM !== 'dumb'; | ||
const minimal = isTTY ? dynamicMinimalReporter : flatMinimalReporter; | ||
|
||
export default { minimal }; | ||
|
||
// TODO: Default: TAP where each browser is 1 virtual test in case of success. | ||
// TODO: Verbose: TAP forwarded, test names prepended with [browsername]. | ||
// TODO: Failures are shown either way, with prepended names. | ||
// TODO: On "runEnd", report wall-clock runtime | ||
// Default: No-op, as overall TAP line as single test (above) can contain runtime | ||
// Verbose: Output comment indicatinh browser done, and test runtime. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.