diff --git a/contribute.md b/contribute.md new file mode 100644 index 0000000..dc4c9a7 --- /dev/null +++ b/contribute.md @@ -0,0 +1,3 @@ +# How to contribute + +Start with `tstest.classes.tstest.ts` to understand whats happening \ No newline at end of file diff --git a/ts/tstest.tap.combinator.ts b/ts/tstest.classes.tap.combinator.ts similarity index 51% rename from ts/tstest.tap.combinator.ts rename to ts/tstest.classes.tap.combinator.ts index 2b33a86..f62c07f 100644 --- a/ts/tstest.tap.combinator.ts +++ b/ts/tstest.classes.tap.combinator.ts @@ -4,7 +4,7 @@ import * as plugins from './tstest.plugins'; import { coloredString as cs } from '@pushrocks/consolecolor'; -import { TapParser } from './tstest.tap.parser'; +import { TapParser } from './tstest.classes.tap.parser'; import * as logPrefixes from './tstest.logprefixes'; export class TapCombinator { @@ -14,35 +14,33 @@ export class TapCombinator { } evaluate() { - console.log(`${logPrefixes.TsTestPrefix} Ran ${this.tapParserStore.length} Testfiles!`); - console.log(`${logPrefixes.TsTestPrefix} Here are the overall results:`); - + console.log(`${logPrefixes.TsTestPrefix} RESULTS FOR ${this.tapParserStore.length} TESTFILE(S):`); + let failGlobal = false; // determine wether tstest should fail for (const tapParser of this.tapParserStore) { - if(tapParser.getErrorTests().length === 0) { - console.log( + if (tapParser.getErrorTests().length === 0) { + let overviewString = logPrefixes.TsTestPrefix + cs(` ${tapParser.fileName} ${plugins.figures.tick}`, 'green') + - ' | ' + - cs(` all tests completed successfully!`, 'blue') - ) + ` ${plugins.figures.pointer} ` + + tapParser.getTestOverviewAsString(); + console.log(overviewString); } else { - console.log( + let overviewString = logPrefixes.TsTestPrefix + cs(` ${tapParser.fileName} ${plugins.figures.cross}`, 'red') + - ' | ' + - cs(` Errors ocurred, please check for the logs!`, 'blue') - ); + ` ${plugins.figures.pointer} ` + + tapParser.getTestOverviewAsString(); + console.log(overviewString); 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')); + console.log(cs(plugins.figures.hamburger.repeat(48), 'cyan')); + if (!failGlobal) { + console.log(cs('FINAL RESULT: SUCCESS!', 'green')); } else { - console.log(cs('Ending with code 1: TESTS ARE FAILING!', 'red')); + console.log(cs('FINAL RESULT: FAIL!', 'red')); + process.exit(1); } } } diff --git a/ts/tstest.tap.parser.ts b/ts/tstest.classes.tap.parser.ts similarity index 87% rename from ts/tstest.tap.parser.ts rename to ts/tstest.classes.tap.parser.ts index c8bd7bf..596cb19 100644 --- a/ts/tstest.tap.parser.ts +++ b/ts/tstest.classes.tap.parser.ts @@ -5,13 +5,13 @@ import { coloredString as cs } from '@pushrocks/consolecolor'; // combines different tap test files to an overall result // ============ import * as plugins from './tstest.plugins'; -import { TapTestResult } from './tstest.tap.testresult'; +import { TapTestResult } from './tstest.classes.tap.testresult'; import * as logPrefixes from './tstest.logprefixes'; export class TapParser { testStore: TapTestResult[] = []; - expectedTestsRegex = /([0-9]*)\.\.([0-9]*)/; + expectedTestsRegex = /([0-9]*)\.\.([0-9]*)$/; expectedTests: number; receivedTests: number; @@ -80,14 +80,14 @@ export class TapParser { if (testOk) { console.log( logPrefixes.TapPrefix, - `${cs(`T${testId} ${plugins.figures.tick}`, 'green')} | ` + + `${cs(`T${testId} ${plugins.figures.tick}`, 'green')} ${plugins.figures.arrowRight} ` + cs(testSubject, 'blue') + ` | ${cs(`${testDuration} ms`, 'orange')}` ); } else { console.log( logPrefixes.TapPrefix, - `${cs(`T${testId} ${plugins.figures.cross}`, 'red')} | ` + + `${cs(`T${testId} ${plugins.figures.cross}`, 'red')} ${plugins.figures.arrowRight} ` + cs(testSubject, 'blue') + ` | ${cs(`${testDuration} ms`, 'orange')}` ); @@ -124,6 +124,28 @@ export class TapParser { }); } + /** + * returns a test overview as string + */ + getTestOverviewAsString() { + let overviewString = '' + for(let test of this.testStore) { + if(overviewString !== '') { + overviewString += ' | '; + } + if (test.testOk) { + overviewString += cs(`T${test.id} ${plugins.figures.tick}`, 'green'); + } else { + overviewString += cs(`T${test.id} ${plugins.figures.cross}`, 'red'); + } + } + return overviewString; + } + + /** + * handles a tap process + * @param childProcessArg + */ async handleTapProcess(childProcessArg: ChildProcess) { const done = plugins.smartpromise.defer(); childProcessArg.stdout.on('data', data => { diff --git a/ts/tstest.tap.testresult.ts b/ts/tstest.classes.tap.testresult.ts similarity index 100% rename from ts/tstest.tap.testresult.ts rename to ts/tstest.classes.tap.testresult.ts diff --git a/ts/tstest.classes.testdirectory.ts b/ts/tstest.classes.testdirectory.ts index 0503026..df1a1d5 100644 --- a/ts/tstest.classes.testdirectory.ts +++ b/ts/tstest.classes.testdirectory.ts @@ -3,9 +3,9 @@ import * as paths from './tstest.paths'; import { Smartfile } from '@pushrocks/smartfile'; // tap related stuff -import { TapCombinator } from './tstest.tap.combinator'; -import { TapParser } from './tstest.tap.parser'; -import { TapTestResult } from './tstest.tap.testresult'; +import { TapCombinator } from './tstest.classes.tap.combinator'; +import { TapParser } from './tstest.classes.tap.parser'; +import { TapTestResult } from './tstest.classes.tap.testresult'; export class TestDirectory { /** diff --git a/ts/tstest.classes.tstest.ts b/ts/tstest.classes.tstest.ts index d94382c..d72ec02 100644 --- a/ts/tstest.classes.tstest.ts +++ b/ts/tstest.classes.tstest.ts @@ -5,8 +5,8 @@ import * as logPrefixes from './tstest.logprefixes'; import { coloredString as cs } from '@pushrocks/consolecolor'; import { TestDirectory } from './tstest.classes.testdirectory'; -import { TapCombinator } from './tstest.tap.combinator'; -import { TapParser } from './tstest.tap.parser'; +import { TapCombinator } from './tstest.classes.tap.combinator'; +import { TapParser } from './tstest.classes.tap.parser'; export class TsTest { testDir: TestDirectory; @@ -17,11 +17,13 @@ export class TsTest { async run() { const fileNamesToRun: string[] = await this.testDir.getTestFilePathArray(); - console.log(`${logPrefixes.TsTestPrefix} Found ${fileNamesToRun.length} Testfile(s):`); + console.log(cs(plugins.figures.hamburger.repeat(80), 'cyan')); + console.log(''); + console.log(`${logPrefixes.TsTestPrefix} FOUND ${fileNamesToRun.length} TESTFILE(S):`); for (const fileName of fileNamesToRun) { console.log(`${logPrefixes.TsTestPrefix} ${cs(fileName, 'orange')}`); } - console.log('-'.repeat(16)); + console.log('-'.repeat(48)); console.log(''); // force new line const smartshellInstance = new plugins.smartshell.Smartshell({ executor: 'bash',