Compare commits

...

6 Commits

Author SHA1 Message Date
df3f1ea9d6 1.0.13 2018-08-08 22:51:21 +02:00
d749476d0c fix(update dependencies): update 2018-08-08 22:51:20 +02:00
4456cd68d0 1.0.12 2018-08-05 23:20:32 +02:00
8f61b5648f fix(log): improve log output 2018-08-05 23:20:32 +02:00
5e1b378ac6 1.0.11 2018-08-05 22:58:53 +02:00
a0ed5c7a16 fix(test result): now failing and succeeding correctly 2018-08-05 22:58:52 +02:00
6 changed files with 156 additions and 68 deletions

81
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@gitzone/tstest",
"version": "1.0.10",
"version": "1.0.13",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -18,7 +18,6 @@
"version": "2.0.21",
"resolved": "https://registry.npmjs.org/@gitzone/tsbuild/-/tsbuild-2.0.21.tgz",
"integrity": "sha512-MAKfqnhf+42twSzXziRoBCu+sW61+2Rvc5qXxpEb594Fpnsj28cZ1VIEckSmiAkoBSiCnoU+2/qea2ycwWMBTg==",
"dev": true,
"requires": {
"@pushrocks/smartfile": "^6.0.3",
"@pushrocks/smartlog": "^2.0.1",
@ -28,13 +27,21 @@
}
},
"@gitzone/tsrun": {
"version": "1.1.9",
"resolved": "https://registry.npmjs.org/@gitzone/tsrun/-/tsrun-1.1.9.tgz",
"integrity": "sha512-MbCLj4hSK5nY6cMqT0OxY0BrXffmiC1Rjbzan8CmEpB8OttaAJT+zsJErJWhI+pk4s75Te73PyhHYaJAXUoJhw==",
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/@gitzone/tsrun/-/tsrun-1.1.11.tgz",
"integrity": "sha512-LkWEmEDyG1px40sDWSgC3STw54VbVAGq828eZsfhYkKlpJa+HzLP0LG5Q31mwjSUFWlCf4AU4MFOD9xbUXTahA==",
"requires": {
"@pushrocks/smartfile": "^6.0.3",
"@gitzone/tsbuild": "^2.0.21",
"@pushrocks/smartfile": "^6.0.6",
"ts-node": "^7.0.0",
"typescript": "^2.9.1"
"typescript": "^3.0.1"
},
"dependencies": {
"typescript": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.1.tgz",
"integrity": "sha512-zQIMOmC+372pC/CCVLqnQ0zSBiY7HHodU7mpQdjiZddek4GMj31I3dUJ7gAs9o65X7mnRma6OokOkc6f9jjfBg=="
}
}
},
"@pushrocks/consolecolor": {
@ -55,18 +62,18 @@
}
},
"@pushrocks/smartfile": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/@pushrocks/smartfile/-/smartfile-6.0.3.tgz",
"integrity": "sha512-oYnLQzY/R6kVNerbWY4WwnPvdxXldrzMPWcB9j0aAdSDSqGwBEO1/ZFTQuNzN5MmPopoYmJrc06ZmI6dm4OJmw==",
"version": "6.0.6",
"resolved": "https://registry.npmjs.org/@pushrocks/smartfile/-/smartfile-6.0.6.tgz",
"integrity": "sha512-vA1+yS6n0kuBZ+Bl30rxOCYvgIj0mo9g303cUpOZR0I781iQVWHcBKRC05FaGDxJD1HuYdvbSK+7vlrzZjVcMw==",
"requires": {
"@pushrocks/smartpath": "^4.0.1",
"@pushrocks/smartpromise": "^2.0.5",
"@pushrocks/smartrequest": "^1.0.15",
"@types/fs-extra": "^5.0.3",
"@pushrocks/smartrequest": "^1.1.12",
"@types/fs-extra": "^5.0.4",
"@types/vinyl": "^2.0.2",
"fs-extra": "^6.0.1",
"fs-extra": "^7.0.0",
"glob": "^7.1.2",
"js-yaml": "^3.10.0",
"smartpath": "^3.2.8",
"vinyl-file": "^3.0.0"
}
},
@ -86,8 +93,7 @@
"@pushrocks/smartpath": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@pushrocks/smartpath/-/smartpath-4.0.1.tgz",
"integrity": "sha512-MaI0+uLQPCr2V3WGnbdgb0pWa9xkWyrP4qYcbsHIjeismGLbn9s3jmP/HIXU8LkgzRgaVb+BJxmZJHOwl32DyA==",
"dev": true
"integrity": "sha512-MaI0+uLQPCr2V3WGnbdgb0pWa9xkWyrP4qYcbsHIjeismGLbn9s3jmP/HIXU8LkgzRgaVb+BJxmZJHOwl32DyA=="
},
"@pushrocks/smartpromise": {
"version": "2.0.5",
@ -105,9 +111,9 @@
}
},
"@pushrocks/smartshell": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/@pushrocks/smartshell/-/smartshell-2.0.5.tgz",
"integrity": "sha512-bMmh46jfJxQ7F46bdujmBR8BqPeEFxBqdXab7885v0kaXASIf9+1BMPKfXiPsDrrR8z/2j2cG/Wgh/0+DDD9hQ==",
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/@pushrocks/smartshell/-/smartshell-2.0.6.tgz",
"integrity": "sha512-D48KB3DDqLfMjOXGEutqJi+v3Z4RcWacu5BJXxUwrecvd6oetbKobfmNGxeHSQPmNGb7U3ISfKwV6c5T5EZkJg==",
"requires": {
"@pushrocks/smartpromise": "^2.0.5",
"@types/which": "^1.3.1",
@ -173,9 +179,9 @@
}
},
"@types/node": {
"version": "10.5.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.5.tgz",
"integrity": "sha512-6Qnb1gXbp3g1JX9QVJj3A6ORzc9XCyhokxUKaoonHgNXcQhmk8adhotxfkeK8El9TnFeUuH72yI6jQ5nDJKS6w=="
"version": "10.5.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.7.tgz",
"integrity": "sha512-VkKcfuitP+Nc/TaTFH0B8qNmn+6NbI6crLkQonbedViVz7O2w8QV/GERPlkJ4bg42VGHiEWa31CoTOPs1q6z1w=="
},
"@types/vinyl": {
"version": "2.0.2",
@ -445,9 +451,9 @@
}
},
"fs-extra": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz",
"integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==",
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.0.tgz",
"integrity": "sha512-EglNDLRpmaTWiD/qraZn6HREAEAHJcJOmxNEYwq6xeMKnVMAy3GUcFB+wXt2C6k4CNvB/mP1y/U3dzvKKj5OtQ==",
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^4.0.0",
@ -498,14 +504,6 @@
"function-bind": "^1.1.1"
}
},
"home": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/home/-/home-1.0.1.tgz",
"integrity": "sha1-lqQjzrSbmDeP9e886uBZpVf53TU=",
"requires": {
"os-homedir": "^1.0.1"
}
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
@ -674,11 +672,6 @@
"wrappy": "1"
}
},
"os-homedir": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M="
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
@ -749,15 +742,6 @@
"chai-string": "^1.4.0"
}
},
"smartpath": {
"version": "3.2.8",
"resolved": "https://registry.npmjs.org/smartpath/-/smartpath-3.2.8.tgz",
"integrity": "sha1-SDS9OouuIpW6rK26I8h6UBlS+UA=",
"requires": {
"home": "^1.0.1",
"typings-global": "^1.0.14"
}
},
"smartq": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/smartq/-/smartq-1.1.8.tgz",
@ -848,7 +832,8 @@
"typings-global": {
"version": "1.0.28",
"resolved": "https://registry.npmjs.org/typings-global/-/typings-global-1.0.28.tgz",
"integrity": "sha512-6VOwJWEY2971HOMHu/7sURzUXiD4/LiMJPsMAOqkHHAtS3MVpLFE5gzTiHilsH9KY5VE1mBQirWIgWFsDuo90A=="
"integrity": "sha512-6VOwJWEY2971HOMHu/7sURzUXiD4/LiMJPsMAOqkHHAtS3MVpLFE5gzTiHilsH9KY5VE1mBQirWIgWFsDuo90A==",
"dev": true
},
"universalify": {
"version": "0.1.2",

View File

@ -1,6 +1,6 @@
{
"name": "@gitzone/tstest",
"version": "1.0.10",
"version": "1.0.13",
"private": false,
"description": "a test utility to run tests that match test/**/*.ts",
"main": "dist/index.js",
@ -23,12 +23,12 @@
"@pushrocks/tapbundle": "^3.0.1"
},
"dependencies": {
"@gitzone/tsrun": "^1.1.9",
"@gitzone/tsrun": "^1.1.11",
"@pushrocks/consolecolor": "^2.0.1",
"@pushrocks/smartfile": "^6.0.3",
"@pushrocks/smartfile": "^6.0.6",
"@pushrocks/smartlog": "^2.0.1",
"@pushrocks/smartpromise": "^2.0.5",
"@pushrocks/smartshell": "^2.0.5",
"@pushrocks/smartshell": "^2.0.6",
"@types/figures": "^2.0.0",
"figures": "^2.0.0"
}

View File

@ -1,5 +1,7 @@
import * as plugins from './tstest.plugins';
import * as paths from './tstest.paths';
import * as logPrefixes from './tstest.logprefixes';
import { coloredString as cs } from '@pushrocks/consolecolor';
import { TestDirectory } from './tstest.classes.testdirectory';
@ -15,9 +17,9 @@ export class TsTest {
async run() {
const fileNamesToRun: string[] = await this.testDir.getTestFilePathArray();
console.log(`Found ${fileNamesToRun.length} Testfile(s):`);
console.log(`${logPrefixes.TsTestPrefix} Found ${fileNamesToRun.length} Testfile(s):`);
for (const fileName of fileNamesToRun) {
console.log(cs(fileName, 'orange'));
console.log(`${logPrefixes.TsTestPrefix} ${cs(fileName, 'orange')}`);
}
console.log('-'.repeat(16));
console.log(''); // force new line
@ -30,7 +32,7 @@ export class TsTest {
for (const fileName of fileNamesToRun) {
console.log(`${cs('=> ', 'blue')} Running ${cs(fileName, 'orange')}`);
console.log(cs(`=`.repeat(16), 'cyan'));
const tapParser = new TapParser();
const tapParser = new TapParser(fileName);
const execResultStreaming = await smartshellInstance.execStreamingSilent(`tsrun ${fileName}`);
await tapParser.handleTapProcess(execResultStreaming.childProcess);
console.log(cs(`^`.repeat(16), 'cyan'));

View File

@ -1,3 +1,7 @@
import * as plugins from './tstest.plugins';
import { coloredString as cs } from '@pushrocks/consolecolor';
export const TapPrefix = plugins.consolecolor.coloredString(`:::TAP:::`, 'pink', 'black');
export const TapPrefix = cs(`::TAP::`, 'pink', 'black');
export const TapErrorPrefix = cs(` !!!TAP PROTOCOL ERROR!!! `, 'red', 'black');
export const TsTestPrefix = cs(`**TSTEST**`, 'pink', 'black');

View File

@ -5,6 +5,7 @@ import * as plugins from './tstest.plugins';
import { coloredString as cs } from '@pushrocks/consolecolor';
import { TapParser } from './tstest.tap.parser';
import * as logPrefixes from './tstest.logprefixes';
export class TapCombinator {
tapParserStore: TapParser[] = [];
@ -13,8 +14,35 @@ export class TapCombinator {
}
evaluate() {
console.log(`Ran ${this.tapParserStore.length} Testfiles!`);
console.log(`${logPrefixes.TsTestPrefix} Ran ${this.tapParserStore.length} Testfiles!`);
console.log(`${logPrefixes.TsTestPrefix} Here are the overall results:`);
let failGlobal = false; // determine wether tstest should fail
for (const tapParser of this.tapParserStore) {
if(tapParser.getErrorTests().length === 0) {
console.log(
logPrefixes.TsTestPrefix +
cs(` ${tapParser.fileName} ${plugins.figures.tick}`, 'green') +
' | ' +
cs(` all tests completed successfully!`, 'blue')
)
} else {
console.log(
logPrefixes.TsTestPrefix +
cs(` ${tapParser.fileName} ${plugins.figures.cross}`, 'red') +
' | ' +
cs(` Errors ocurred, please check for the logs!`, 'blue')
);
failGlobal = true;
}
}
console.log(cs('-'.repeat(16), 'cyan'));
console.log(cs('*'.repeat(16), 'cyan'));
console.log(cs('-'.repeat(16), 'cyan'));
if(!failGlobal) {
console.log(cs('Ending with code 0: TESTS ARE PASSING!', 'green'));
} else {
console.log(cs('Ending with code 1: TESTS ARE FAILING!', 'red'));
}
}
}

View File

@ -9,16 +9,23 @@ import { TapTestResult } from './tstest.tap.testresult';
import * as logPrefixes from './tstest.logprefixes';
export class TapParser {
resultStore: TapTestResult[] = [];
testStore: TapTestResult[] = [];
expectedTestsRegex = /([0-9]*)\.\.([0-9]*)/;
expectedTests: number;
receivedTests: number;
testStatusRegex = /(ok|not\sok)\s([0-9]+)\s-\s(.*)\s#\stime=(.*)ms$/;
activeTapTestResult: TapTestResult;
/**
* the constructor for TapParser
*/
constructor(public fileName: string) {}
private _getNewTapTestResult() {
this.activeTapTestResult = new TapTestResult(this.resultStore.length + 1);
this.activeTapTestResult = new TapTestResult(this.testStore.length + 1);
}
private _processLog(logChunk: Buffer | string) {
@ -37,7 +44,12 @@ export class TapParser {
logLineIsTapProtocol = true;
const regexResult = this.expectedTestsRegex.exec(logLine);
this.expectedTests = parseInt(regexResult[2]);
console.log(`:::TAP::: Expecting ${this.expectedTests} tests!`);
console.log(
`${logPrefixes.TapPrefix} ${cs(
`Expecting ${this.expectedTests} tests!`,
'blue'
)}`
);
// initiating first TapResult
this._getNewTapTestResult();
@ -57,23 +69,27 @@ export class TapParser {
// test for protocol error
if (testId !== this.activeTapTestResult.id) {
console.log(`:::TAP PROTOCOL ERROR::: Something is strange! Test Ids are not equal!`);
console.log(
`${
logPrefixes.TapErrorPrefix
} Something is strange! Test Ids are not equal!`
);
}
this.activeTapTestResult.setTestResult(testOk);
if (testOk) {
console.log(
logPrefixes.TapPrefix,
` ${cs(`T${testId} ${plugins.figures.tick}`, 'green')} | ` +
cs(testSubject, 'blue') +
` | ${cs(`${testDuration} milliseconds`, 'orange')}`
`${cs(`T${testId} ${plugins.figures.tick}`, 'green')} | ` +
cs(testSubject, 'blue') +
` | ${cs(`${testDuration} ms`, 'orange')}`
);
} else {
console.log(
logPrefixes.TapPrefix,
` ${cs(`T${testId} ${plugins.figures.cross}`, 'red')} | ` +
cs(testSubject, 'blue') +
` | ${cs(`${testDuration} milliseconds`, 'orange')}`
`${cs(`T${testId} ${plugins.figures.cross}`, 'red')} | ` +
cs(testSubject, 'blue') +
` | ${cs(`${testDuration} ms`, 'orange')}`
);
}
}
@ -86,12 +102,28 @@ export class TapParser {
}
if (this.activeTapTestResult && this.activeTapTestResult.testSettled) {
this.resultStore.push(this.activeTapTestResult);
this.testStore.push(this.activeTapTestResult);
this._getNewTapTestResult();
}
}
}
/**
* returns all tests that are not completed
*/
getUncompletedTests() {
// TODO:
}
/**
* returns all tests that threw an error
*/
getErrorTests() {
return this.testStore.filter(tapTestArg => {
return !tapTestArg.testOk;
});
}
async handleTapProcess(childProcessArg: ChildProcess) {
const done = plugins.smartpromise.defer();
childProcessArg.stdout.on('data', data => {
@ -101,6 +133,43 @@ export class TapParser {
this._processLog(data);
});
childProcessArg.on('exit', () => {
this.receivedTests = this.testStore.length;
// check wether all tests ran
if (this.expectedTests === this.receivedTests) {
console.log(
`${logPrefixes.TapPrefix} ${cs(
`${this.receivedTests} out of ${
this.expectedTests
} Tests completed!`,
'green'
)}`
);
} else {
console.log(
`${logPrefixes.TapErrorPrefix} ${cs(
`Only ${this.receivedTests} out of ${
this.expectedTests
} completed!`,
'red'
)}`
);
}
if (this.getErrorTests().length === 0) {
console.log(
`${logPrefixes.TapPrefix} ${cs(
`All tests are successfull!!!`,
'green'
)}`
);
} else {
console.log(
`${logPrefixes.TapPrefix} ${cs(
`${this.getErrorTests().length} tests threw an error!!!`,
'red'
)}`
);
}
done.resolve();
});
await done.promise;