Compare commits

...

10 Commits

Author SHA1 Message Date
5afe6e6981 1.0.18 2018-12-06 01:03:49 +01:00
5d071d0299 fix(core): update 2018-12-06 01:03:48 +01:00
180bfcb353 1.0.17 2018-12-06 00:56:36 +01:00
3161e6b4eb fix(core): update 2018-12-06 00:56:36 +01:00
6129388a20 1.0.16 2018-12-06 00:38:03 +01:00
8f0cfe1a06 fix(core): update 2018-12-06 00:38:03 +01:00
39926fb08b 1.0.15 2018-08-14 00:04:43 +02:00
36594b64f2 fix(dependencies): update 2018-08-14 00:04:42 +02:00
9f898b6579 1.0.14 2018-08-13 23:58:51 +02:00
b1725b636b fix(improve test handling): now failing correctly and with better log output 2018-08-13 23:58:50 +02:00
10 changed files with 684 additions and 243 deletions

View File

@ -26,6 +26,7 @@ mirror:
snyk:
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
@ -36,21 +37,11 @@ snyk:
# ====================
# test stage
# ====================
testLEGACY:
stage: test
script:
- npmci node install legacy
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
allow_failure: true
testLTS:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
@ -62,6 +53,7 @@ testLTS:
testSTABLE:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
@ -118,6 +110,7 @@ pages:
stage: metadata
script:
- npmci command npm install -g typedoc typescript
- npmci npm prepare
- npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
tags:
@ -130,13 +123,3 @@ pages:
paths:
- public
allow_failure: true
windowsCompatibility:
image: stefanscherer/node-windows:10-build-tools
stage: metadata
script:
- npm install & npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- windows
allow_failure: true

3
contribute.md Normal file
View File

@ -0,0 +1,3 @@
# How to contribute
Start with `tstest.classes.tstest.ts` to understand whats happening

749
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@gitzone/tstest",
"version": "1.0.13",
"version": "1.0.18",
"private": false,
"description": "a test utility to run tests that match test/**/*.ts",
"main": "dist/index.js",
@ -19,16 +19,16 @@
"build": "(tsbuild)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.0.21",
"@pushrocks/tapbundle": "^3.0.1"
"@gitzone/tsbuild": "^2.1.3",
"@pushrocks/tapbundle": "^3.0.7"
},
"dependencies": {
"@gitzone/tsrun": "^1.1.11",
"@gitzone/tsrun": "^1.1.17",
"@pushrocks/consolecolor": "^2.0.1",
"@pushrocks/smartfile": "^6.0.6",
"@pushrocks/smartlog": "^2.0.1",
"@pushrocks/smartfile": "^6.0.11",
"@pushrocks/smartlog": "^2.0.9",
"@pushrocks/smartpromise": "^2.0.5",
"@pushrocks/smartshell": "^2.0.6",
"@pushrocks/smartshell": "^2.0.11",
"@types/figures": "^2.0.0",
"figures": "^2.0.0"
}

View File

@ -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,35 @@ 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);
}
}
}

View File

@ -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;
@ -23,7 +23,6 @@ export class TapParser {
*/
constructor(public fileName: string) {}
private _getNewTapTestResult() {
this.activeTapTestResult = new TapTestResult(this.testStore.length + 1);
}
@ -45,10 +44,7 @@ export class TapParser {
const regexResult = this.expectedTestsRegex.exec(logLine);
this.expectedTests = parseInt(regexResult[2]);
console.log(
`${logPrefixes.TapPrefix} ${cs(
`Expecting ${this.expectedTests} tests!`,
'blue'
)}`
`${logPrefixes.TapPrefix} ${cs(`Expecting ${this.expectedTests} tests!`, 'blue')}`
);
// initiating first TapResult
@ -70,9 +66,7 @@ export class TapParser {
// test for protocol error
if (testId !== this.activeTapTestResult.id) {
console.log(
`${
logPrefixes.TapErrorPrefix
} Something is strange! Test Ids are not equal!`
`${logPrefixes.TapErrorPrefix} Something is strange! Test Ids are not equal!`
);
}
this.activeTapTestResult.setTestResult(testOk);
@ -80,14 +74,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 +118,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 => {
@ -139,29 +155,20 @@ export class TapParser {
if (this.expectedTests === this.receivedTests) {
console.log(
`${logPrefixes.TapPrefix} ${cs(
`${this.receivedTests} out of ${
this.expectedTests
} Tests completed!`,
`${this.receivedTests} out of ${this.expectedTests} Tests completed!`,
'green'
)}`
);
} else {
console.log(
`${logPrefixes.TapErrorPrefix} ${cs(
`Only ${this.receivedTests} out of ${
this.expectedTests
} completed!`,
`Only ${this.receivedTests} out of ${this.expectedTests} completed!`,
'red'
)}`
);
}
if (this.getErrorTests().length === 0) {
console.log(
`${logPrefixes.TapPrefix} ${cs(
`All tests are successfull!!!`,
'green'
)}`
);
console.log(`${logPrefixes.TapPrefix} ${cs(`All tests are successfull!!!`, 'green')}`);
} else {
console.log(
`${logPrefixes.TapPrefix} ${cs(

View File

@ -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 {
/**

View File

@ -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',
@ -33,7 +35,16 @@ export class TsTest {
console.log(`${cs('=> ', 'blue')} Running ${cs(fileName, 'orange')}`);
console.log(cs(`=`.repeat(16), 'cyan'));
const tapParser = new TapParser(fileName);
const execResultStreaming = await smartshellInstance.execStreamingSilent(`tsrun ${fileName}`);
// tsrun options
let tsrunOptions = '';
if (process.argv.includes('--web')) {
tsrunOptions += ' --web';
}
const execResultStreaming = await smartshellInstance.execStreamingSilent(
`tsrun ${fileName}${tsrunOptions}`
);
await tapParser.handleTapProcess(execResultStreaming.childProcess);
console.log(cs(`^`.repeat(16), 'cyan'));
console.log(''); // force new line

View File

@ -1,3 +1,17 @@
{
"extends": "tslint-config-standard"
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}