tstest/ts/tstest.classes.tap.combinator.ts

47 lines
1.6 KiB
TypeScript
Raw Normal View History

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';
import { TapParser } from './tstest.classes.tap.parser';
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() {
console.log(`${logPrefixes.TsTestPrefix} RESULTS FOR ${this.tapParserStore.length} TESTFILE(S):`);
let failGlobal = false; // determine wether tstest should fail
2018-08-04 12:23:07 +00:00
for (const tapParser of this.tapParserStore) {
if (tapParser.getErrorTests().length === 0) {
let overviewString =
logPrefixes.TsTestPrefix +
cs(` ${tapParser.fileName} ${plugins.figures.tick}`, 'green') +
` ${plugins.figures.pointer} ` +
tapParser.getTestOverviewAsString();
console.log(overviewString);
} else {
let overviewString =
logPrefixes.TsTestPrefix +
cs(` ${tapParser.fileName} ${plugins.figures.cross}`, 'red') +
` ${plugins.figures.pointer} ` +
tapParser.getTestOverviewAsString();
console.log(overviewString);
failGlobal = true;
}
}
console.log(cs(plugins.figures.hamburger.repeat(48), 'cyan'));
if (!failGlobal) {
console.log(cs('FINAL RESULT: SUCCESS!', 'green'));
} else {
console.log(cs('FINAL RESULT: FAIL!', 'red'));
process.exit(1);
2018-08-04 12:23:07 +00:00
}
2018-08-03 17:18:42 +00:00
}
}