2018-08-03 17:18:42 +00:00
|
|
|
// ============
|
|
|
|
// combines different tap test files to an overall result
|
|
|
|
// ============
|
2022-03-12 23:30:32 +00:00
|
|
|
import * as plugins from './tstest.plugins.js';
|
2018-08-04 12:23:07 +00:00
|
|
|
import { coloredString as cs } from '@pushrocks/consolecolor';
|
|
|
|
|
2022-03-12 23:30:32 +00:00
|
|
|
import { TapParser } from './tstest.classes.tap.parser.js';
|
|
|
|
import * as logPrefixes from './tstest.logprefixes.js';
|
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-12-06 00:03:48 +00:00
|
|
|
console.log(
|
|
|
|
`${logPrefixes.TsTestPrefix} RESULTS FOR ${this.tapParserStore.length} TESTFILE(S):`
|
|
|
|
);
|
2018-08-13 21:58:50 +00:00
|
|
|
|
2018-08-05 20:58:52 +00:00
|
|
|
let failGlobal = false; // determine wether tstest should fail
|
2018-08-04 12:23:07 +00:00
|
|
|
for (const tapParser of this.tapParserStore) {
|
2020-07-11 15:52:31 +00:00
|
|
|
if (!tapParser.expectedTests) {
|
|
|
|
failGlobal = true;
|
|
|
|
let overviewString =
|
|
|
|
logPrefixes.TsTestPrefix +
|
|
|
|
cs(` ${tapParser.fileName} ${plugins.figures.cross}`, 'red') +
|
|
|
|
` ${plugins.figures.pointer} ` +
|
|
|
|
`does not specify tests!`;
|
|
|
|
console.log(overviewString);
|
2020-07-12 00:47:41 +00:00
|
|
|
} else if (tapParser.expectedTests !== tapParser.receivedTests) {
|
|
|
|
failGlobal = true;
|
|
|
|
let overviewString =
|
|
|
|
logPrefixes.TsTestPrefix +
|
|
|
|
cs(` ${tapParser.fileName} ${plugins.figures.cross}`, 'red') +
|
|
|
|
` ${plugins.figures.pointer} ` +
|
|
|
|
tapParser.getTestOverviewAsString() +
|
|
|
|
`did not execute all specified tests!`;
|
|
|
|
console.log(overviewString);
|
2020-07-11 15:52:31 +00:00
|
|
|
} else if (tapParser.getErrorTests().length === 0) {
|
2018-08-13 21:58:50 +00:00
|
|
|
let overviewString =
|
2018-08-05 20:58:52 +00:00
|
|
|
logPrefixes.TsTestPrefix +
|
|
|
|
cs(` ${tapParser.fileName} ${plugins.figures.tick}`, 'green') +
|
2018-08-13 21:58:50 +00:00
|
|
|
` ${plugins.figures.pointer} ` +
|
|
|
|
tapParser.getTestOverviewAsString();
|
|
|
|
console.log(overviewString);
|
2018-08-05 20:58:52 +00:00
|
|
|
} else {
|
2020-07-11 15:52:31 +00:00
|
|
|
failGlobal = true;
|
2018-08-13 21:58:50 +00:00
|
|
|
let overviewString =
|
2018-08-05 20:58:52 +00:00
|
|
|
logPrefixes.TsTestPrefix +
|
|
|
|
cs(` ${tapParser.fileName} ${plugins.figures.cross}`, 'red') +
|
2018-08-13 21:58:50 +00:00
|
|
|
` ${plugins.figures.pointer} ` +
|
|
|
|
tapParser.getTestOverviewAsString();
|
|
|
|
console.log(overviewString);
|
2018-08-05 20:58:52 +00:00
|
|
|
}
|
|
|
|
}
|
2018-08-13 21:58:50 +00:00
|
|
|
console.log(cs(plugins.figures.hamburger.repeat(48), 'cyan'));
|
|
|
|
if (!failGlobal) {
|
|
|
|
console.log(cs('FINAL RESULT: SUCCESS!', 'green'));
|
2018-08-05 20:58:52 +00:00
|
|
|
} else {
|
2018-08-13 21:58:50 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|