Compare commits

...

2 Commits

Author SHA1 Message Date
953a4e4b72 1.0.8 2018-08-04 19:23:17 +02:00
e7192800ea fix(improve log output): update 2018-08-04 19:23:17 +02:00
4 changed files with 23 additions and 6 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/tstest",
"version": "1.0.7",
"version": "1.0.8",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@gitzone/tstest",
"version": "1.0.7",
"version": "1.0.8",
"private": false,
"description": "a test utility to run tests that match test/**/*.ts",
"main": "dist/index.js",

View File

@ -20,6 +20,7 @@ export class TsTest {
console.log(cs(fileName, 'orange'));
}
console.log('-'.repeat(16));
console.log(''); // force new line
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash',
pathDirectories: [paths.binDirectory],
@ -28,10 +29,12 @@ export class TsTest {
const tapCombinator = new TapCombinator(); // lets create the TapCombinator
for (const fileName of fileNamesToRun) {
console.log(`${cs('=> ', 'blue')} Running ${cs(fileName, 'orange')}`);
console.log(`=`.repeat(16));
console.log(cs(`=`.repeat(16), 'cyan'));
const tapParser = new TapParser();
const execResultStreaming = await smartshellInstance.execStreamingSilent(`tsrun ${fileName}`);
await tapParser.handleTapProcess(execResultStreaming.childProcess);
console.log(cs(`^`.repeat(16), 'cyan'));
console.log(''); // force new line
tapCombinator.addTapParser(tapParser);
}
tapCombinator.evaluate();

View File

@ -6,6 +6,7 @@ import { coloredString as cs } from '@pushrocks/consolecolor';
// ============
import * as plugins from './tstest.plugins';
import { TapTestResult } from './tstest.tap.testresult';
import * as logPrefixes from './tstest.logprefixes';
export class TapParser {
resultStore: TapTestResult[] = [];
@ -13,7 +14,7 @@ export class TapParser {
expectedTestsRegex = /([0-9]*)\.\.([0-9]*)/;
expectedTests: number;
testStatusRegex = /(ok|not\sok)\s([0-9]+)\s-\s/;
testStatusRegex = /(ok|not\sok)\s([0-9]+)\s-\s(.*)\s#\stime=(.*)ms$/;
activeTapTestResult: TapTestResult;
private _getNewTapTestResult() {
@ -51,6 +52,9 @@ export class TapParser {
return false;
})();
const testSubject = regexResult[3];
const testDuration = parseInt(regexResult[4]);
// test for protocol error
if (testId !== this.activeTapTestResult.id) {
console.log(`:::TAP PROTOCOL ERROR::: Something is strange! Test Ids are not equal!`);
@ -58,9 +62,19 @@ export class TapParser {
this.activeTapTestResult.setTestResult(testOk);
if (testOk) {
console.log(cs(`:::TAP::: Success: Test ${testId} is ok!`, 'green', 'black'));
console.log(
logPrefixes.TapPrefix,
` ${cs(`Test ${testId} -> Success!`, 'green')} | ` +
cs(testSubject, 'blue') +
` | ${cs(`${testDuration} milliseconds`, 'orange')}`
);
} else {
console.log(cs(`:::TAP::: Error: Test ${testId} is NOT ok!`, 'green', 'black'));
console.log(
logPrefixes.TapPrefix,
` ${cs(`Test ${testId} -> Error!`, 'red')} | ` +
cs(testSubject, 'blue') +
` | ${cs(`${testDuration} milliseconds`, 'orange')}`
);
}
}