fix(core): update

This commit is contained in:
Philipp Kunz 2020-07-07 23:09:17 +00:00
parent 023176258a
commit 30284b770c
2 changed files with 41 additions and 36 deletions

View File

@ -113,7 +113,7 @@ export class TapParser {
* returns all tests that threw an error
*/
public getErrorTests() {
return this.testStore.filter(tapTestArg => {
return this.testStore.filter((tapTestArg) => {
return !tapTestArg.testOk;
});
}
@ -140,49 +140,54 @@ export class TapParser {
* handles a tap process
* @param childProcessArg
*/
async handleTapProcess(childProcessArg: ChildProcess) {
public async handleTapProcess(childProcessArg: ChildProcess) {
const done = plugins.smartpromise.defer();
childProcessArg.stdout.on('data', data => {
childProcessArg.stdout.on('data', (data) => {
this._processLog(data);
});
childProcessArg.stderr.on('data', data => {
childProcessArg.stderr.on('data', (data) => {
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'
)}`
);
}
childProcessArg.on('exit', async () => {
await this._evaluateResult();
done.resolve();
});
await done.promise;
}
public handleTapLog(tapLog: string) {
public async handleTapLog(tapLog: string) {
this._processLog(tapLog);
await this._evaluateResult();
}
private async _evaluateResult() {
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'
)}`
);
}
}
}

View File

@ -48,6 +48,8 @@ export class TsTest {
break;
}
tapCombinator.addTapParser(tapParser);
console.log(cs(`^`.repeat(16), 'cyan'));
console.log(''); // force new line
}
tapCombinator.evaluate();
}
@ -67,8 +69,6 @@ export class TsTest {
`tsrun ${fileNameArg}${tsrunOptions}`
);
await tapParser.handleTapProcess(execResultStreaming.childProcess);
console.log(cs(`^`.repeat(16), 'cyan'));
console.log(''); // force new line
return tapParser;
}