2018-08-03 17:18:42 +00:00
|
|
|
// ============
|
|
|
|
// combines different tap test files to an overall result
|
|
|
|
// ============
|
|
|
|
import * as plugins from './tstest.plugins';
|
2018-08-04 12:23:07 +00:00
|
|
|
import { coloredString as cs } from '@pushrocks/consolecolor';
|
|
|
|
|
2018-08-03 17:18:42 +00:00
|
|
|
import { TapParser } from './tstest.tap.parser';
|
2018-08-05 20:58:52 +00:00
|
|
|
import * as logPrefixes from './tstest.logprefixes';
|
2018-08-03 17:18:42 +00:00
|
|
|
|
|
|
|
export class TapCombinator {
|
2018-08-04 12:23:07 +00:00
|
|
|
tapParserStore: TapParser[] = [];
|
2018-08-03 17:18:42 +00:00
|
|
|
addTapParser(tapParserArg: TapParser) {
|
2018-08-04 12:23:07 +00:00
|
|
|
this.tapParserStore.push(tapParserArg);
|
|
|
|
}
|
|
|
|
|
|
|
|
evaluate() {
|
2018-08-05 20:58:52 +00:00
|
|
|
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
|
2018-08-04 12:23:07 +00:00
|
|
|
for (const tapParser of this.tapParserStore) {
|
2018-08-05 20:58:52 +00:00
|
|
|
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'));
|
2018-08-04 12:23:07 +00:00
|
|
|
}
|
2018-08-03 17:18:42 +00:00
|
|
|
}
|
|
|
|
}
|