Compare commits

..

8 Commits

Author SHA1 Message Date
ef5efc0a93 1.0.87 2024-03-07 13:10:58 +01:00
f305547116 fix(core): update 2024-03-07 13:10:57 +01:00
033a0a806c 1.0.86 2024-01-19 20:59:02 +01:00
7f87c24ad8 fix(core): update 2024-01-19 20:59:01 +01:00
ac08bdffe5 1.0.85 2023-11-10 12:44:08 +01:00
eb64cb4f71 fix(core): update 2023-11-10 12:44:08 +01:00
3b56c6ce9f 1.0.84 2023-11-09 21:06:07 +01:00
722d777f80 fix(core): update 2023-11-09 21:06:06 +01:00
6 changed files with 445 additions and 330 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@git.zone/tstest", "name": "@git.zone/tstest",
"version": "1.0.83", "version": "1.0.87",
"private": false, "private": false,
"description": "a test utility to run tests that match test/**/*.ts", "description": "a test utility to run tests that match test/**/*.ts",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -20,24 +20,24 @@
"buildDocs": "tsdoc" "buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@git.zone/tsbuild": "^2.1.70", "@git.zone/tsbuild": "^2.1.72",
"@types/node": "^20.9.0" "@types/node": "^20.11.25"
}, },
"dependencies": { "dependencies": {
"@api.global/typedserver": "^3.0.9", "@api.global/typedserver": "^3.0.27",
"@git.zone/tsbundle": "^2.0.10", "@git.zone/tsbundle": "^2.0.15",
"@git.zone/tsrun": "^1.2.46", "@git.zone/tsrun": "^1.2.46",
"@push.rocks/consolecolor": "^2.0.1", "@push.rocks/consolecolor": "^2.0.1",
"@push.rocks/smartbrowser": "^2.0.6", "@push.rocks/smartbrowser": "^2.0.6",
"@push.rocks/smartdelay": "^3.0.5", "@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/smartfile": "^11.0.0", "@push.rocks/smartfile": "^11.0.4",
"@push.rocks/smartlog": "^3.0.3", "@push.rocks/smartlog": "^3.0.3",
"@push.rocks/smartpromise": "^4.0.3", "@push.rocks/smartpromise": "^4.0.3",
"@push.rocks/smartshell": "^3.0.3", "@push.rocks/smartshell": "^3.0.3",
"@push.rocks/tapbundle": "^5.0.15", "@push.rocks/tapbundle": "^5.0.15",
"@types/ws": "^8.5.9", "@types/ws": "^8.5.10",
"figures": "^6.0.1", "figures": "^6.1.0",
"ws": "^8.14.2" "ws": "^8.16.0"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

730
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@git.zone/tstest', name: '@git.zone/tstest',
version: '1.0.83', version: '1.0.87',
description: 'a test utility to run tests that match test/**/*.ts' description: 'a test utility to run tests that match test/**/*.ts'
} }

View File

@ -18,6 +18,8 @@ export class TapParser {
testStatusRegex = /(ok|not\sok)\s([0-9]+)\s-\s(.*)\s#\stime=(.*)ms$/; testStatusRegex = /(ok|not\sok)\s([0-9]+)\s-\s(.*)\s#\stime=(.*)ms$/;
activeTapTestResult: TapTestResult; activeTapTestResult: TapTestResult;
pretaskRegex = /^::__PRETASK:(.*)$/;
/** /**
* the constructor for TapParser * the constructor for TapParser
*/ */
@ -49,6 +51,12 @@ export class TapParser {
// initiating first TapResult // initiating first TapResult
this._getNewTapTestResult(); 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)) { } else if (this.testStatusRegex.test(logLine)) {
logLineIsTapProtocol = true; logLineIsTapProtocol = true;
const regexResult = this.testStatusRegex.exec(logLine); const regexResult = this.testStatusRegex.exec(logLine);
@ -149,7 +157,7 @@ export class TapParser {
this._processLog(data); this._processLog(data);
}); });
childProcessArg.on('exit', async () => { childProcessArg.on('exit', async () => {
await this._evaluateResult(); await this.evaluateFinalResult();
done.resolve(); done.resolve();
}); });
await done.promise; await done.promise;
@ -157,10 +165,9 @@ export class TapParser {
public async handleTapLog(tapLog: string) { public async handleTapLog(tapLog: string) {
this._processLog(tapLog); this._processLog(tapLog);
await this._evaluateResult();
} }
private async _evaluateResult() { public async evaluateFinalResult() {
this.receivedTests = this.testStore.length; this.receivedTests = this.testStore.length;
// check wether all tests ran // check wether all tests ran

View File

@ -130,10 +130,11 @@ export class TsTest {
await server.start(); await server.start();
// lets handle realtime comms // lets handle realtime comms
const tapParser = new TapParser(fileNameArg + ':chrome');
const wss = new plugins.ws.WebSocketServer({ port: 8080 }); const wss = new plugins.ws.WebSocketServer({ port: 8080 });
wss.on('connection', (ws) => { wss.on('connection', (ws) => {
ws.on('message', (message) => { ws.on('message', (message) => {
console.log(message.toString()); tapParser.handleTapLog(message.toString());
}); });
}); });
@ -173,10 +174,10 @@ export class TsTest {
// Execute the exported test function // Execute the exported test function
await testModule.runTest(); await testModule.runTest();
} else { } else {
originalError('Test module does not export runTest function.'); console.error('Test module does not export runTest function.');
} }
} catch (err) { } catch (err) {
originalError(err); console.error(err);
} }
return logStore.join('\n'); return logStore.join('\n');
@ -188,10 +189,8 @@ export class TsTest {
console.log( console.log(
`${cs('=> ', 'blue')} Stopped ${cs(fileNameArg, 'orange')} chromium instance and server.` `${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 // lets create the tap parser
const tapParser = new TapParser(fileNameArg + ':chrome'); await tapParser.evaluateFinalResult();
tapParser.handleTapLog(evaluation);
return tapParser; return tapParser;
} }

View File

@ -2,6 +2,7 @@ import * as plugins from './tstest.plugins.js';
import { coloredString as cs } from '@push.rocks/consolecolor'; import { coloredString as cs } from '@push.rocks/consolecolor';
export const TapPrefix = cs(`::TAP::`, 'pink', 'black'); 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 TapErrorPrefix = cs(` !!!TAP PROTOCOL ERROR!!! `, 'red', 'black');
export const TsTestPrefix = cs(`**TSTEST**`, 'pink', 'black'); export const TsTestPrefix = cs(`**TSTEST**`, 'pink', 'black');