diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index b19953e..b21ae65 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@git.zone/tstest', - version: '1.0.83', + version: '1.0.84', description: 'a test utility to run tests that match test/**/*.ts' } diff --git a/ts/tstest.classes.tap.parser.ts b/ts/tstest.classes.tap.parser.ts index 92c0fb3..b540dd0 100644 --- a/ts/tstest.classes.tap.parser.ts +++ b/ts/tstest.classes.tap.parser.ts @@ -18,6 +18,8 @@ export class TapParser { testStatusRegex = /(ok|not\sok)\s([0-9]+)\s-\s(.*)\s#\stime=(.*)ms$/; activeTapTestResult: TapTestResult; + pretaskRegex = /^::__PRETASK:(.*)$/; + /** * the constructor for TapParser */ @@ -49,6 +51,12 @@ export class TapParser { // initiating first TapResult this._getNewTapTestResult(); + } else if (this.pretaskRegex.test(logLine)) { + logLineIsTapProtocol = true; + const pretaskContentMatch = this.pretaskRegex.exec(logLine); + if (pretaskContentMatch && pretaskContentMatch[1]) { + console.log(`${logPrefixes.TapPretaskPrefix} Pretask ->${pretaskContentMatch[1]}: Success.`); + } } else if (this.testStatusRegex.test(logLine)) { logLineIsTapProtocol = true; const regexResult = this.testStatusRegex.exec(logLine); @@ -149,7 +157,7 @@ export class TapParser { this._processLog(data); }); childProcessArg.on('exit', async () => { - await this._evaluateResult(); + await this.evaluateFinalResult(); done.resolve(); }); await done.promise; @@ -157,10 +165,9 @@ export class TapParser { public async handleTapLog(tapLog: string) { this._processLog(tapLog); - await this._evaluateResult(); } - private async _evaluateResult() { + public async evaluateFinalResult() { this.receivedTests = this.testStore.length; // check wether all tests ran diff --git a/ts/tstest.classes.tstest.ts b/ts/tstest.classes.tstest.ts index f044e53..69ed44d 100644 --- a/ts/tstest.classes.tstest.ts +++ b/ts/tstest.classes.tstest.ts @@ -130,10 +130,11 @@ export class TsTest { await server.start(); // lets handle realtime comms + const tapParser = new TapParser(fileNameArg + ':chrome'); const wss = new plugins.ws.WebSocketServer({ port: 8080 }); wss.on('connection', (ws) => { ws.on('message', (message) => { - console.log(message.toString()); + tapParser.handleTapLog(message.toString()); }); }); @@ -188,10 +189,8 @@ export class TsTest { console.log( `${cs('=> ', 'blue')} Stopped ${cs(fileNameArg, 'orange')} chromium instance and server.` ); - console.log(`${cs('=> ', 'blue')} See the result captured from the chromium execution:`); // lets create the tap parser - const tapParser = new TapParser(fileNameArg + ':chrome'); - tapParser.handleTapLog(evaluation); + await tapParser.evaluateFinalResult(); return tapParser; } diff --git a/ts/tstest.logprefixes.ts b/ts/tstest.logprefixes.ts index 3ca13b0..6abe4aa 100644 --- a/ts/tstest.logprefixes.ts +++ b/ts/tstest.logprefixes.ts @@ -2,6 +2,7 @@ import * as plugins from './tstest.plugins.js'; import { coloredString as cs } from '@push.rocks/consolecolor'; export const TapPrefix = cs(`::TAP::`, 'pink', 'black'); +export const TapPretaskPrefix = cs(`::PRETASK::`, 'cyan', 'black'); export const TapErrorPrefix = cs(` !!!TAP PROTOCOL ERROR!!! `, 'red', 'black'); export const TsTestPrefix = cs(`**TSTEST**`, 'pink', 'black');