Compare commits

...

12 Commits

Author SHA1 Message Date
953a4e4b72 1.0.8 2018-08-04 19:23:17 +02:00
e7192800ea fix(improve log output): update 2018-08-04 19:23:17 +02:00
1516f843aa 1.0.7 2018-08-04 17:19:24 +02:00
f29558d6d1 fix(package): fix packagename 2018-08-04 17:19:24 +02:00
b6dc2df384 1.0.6 2018-08-04 17:13:01 +02:00
ec3999300d fix(peerDependency): now correctly finds bin of tsrun peer Dependency 2018-08-04 17:13:01 +02:00
b0dddd48a2 1.0.5 2018-08-04 16:04:12 +02:00
65dda322c5 fix(ci): switch to https for cloning ci dependencies 2018-08-04 16:04:11 +02:00
8db6e5e6f1 1.0.4 2018-08-04 15:55:49 +02:00
d1e60ad4ab fix(ci): remove globally required tools 2018-08-04 15:55:48 +02:00
e64728860d 1.0.3 2018-08-04 15:51:44 +02:00
ae1ce98a19 fix(CI): now building correctly 2018-08-04 15:51:44 +02:00
10 changed files with 84 additions and 64 deletions

2
.npmignore Normal file
View File

@ -0,0 +1,2 @@
node_modules/
.nogit/

View File

@ -1,9 +1,6 @@
{
"npmci": {
"npmGlobalTools": [
"@gitzone/npmts",
"ts-node"
],
"npmGlobalTools": [],
"npmAccessLevel": "public"
}
}

29
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "tstest",
"version": "1.0.2",
"name": "@pushrocks/tstest",
"version": "1.0.8",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -14,6 +14,19 @@
"nan": "^2.9.2"
}
},
"@gitzone/tsbuild": {
"version": "2.0.21",
"resolved": "https://registry.npmjs.org/@gitzone/tsbuild/-/tsbuild-2.0.21.tgz",
"integrity": "sha512-MAKfqnhf+42twSzXziRoBCu+sW61+2Rvc5qXxpEb594Fpnsj28cZ1VIEckSmiAkoBSiCnoU+2/qea2ycwWMBTg==",
"dev": true,
"requires": {
"@pushrocks/smartfile": "^6.0.3",
"@pushrocks/smartlog": "^2.0.1",
"@pushrocks/smartpath": "^4.0.1",
"@pushrocks/smartpromise": "^2.0.5",
"typescript": "^2.9.2"
}
},
"@gitzone/tsrun": {
"version": "1.1.9",
"resolved": "https://registry.npmjs.org/@gitzone/tsrun/-/tsrun-1.1.9.tgz",
@ -70,6 +83,12 @@
"resolved": "https://registry.npmjs.org/@pushrocks/smartlog-interfaces/-/smartlog-interfaces-1.0.9.tgz",
"integrity": "sha512-0qwpomrRN0kFjmhR9m1iHYXoISoNuXtRP0Wr+JtkYyURLwKHMaW8Xoznf8MzXJptRfqufJi3Fxh5HodpPrIZUA=="
},
"@pushrocks/smartpath": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@pushrocks/smartpath/-/smartpath-4.0.1.tgz",
"integrity": "sha512-MaI0+uLQPCr2V3WGnbdgb0pWa9xkWyrP4qYcbsHIjeismGLbn9s3jmP/HIXU8LkgzRgaVb+BJxmZJHOwl32DyA==",
"dev": true
},
"@pushrocks/smartpromise": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/@pushrocks/smartpromise/-/smartpromise-2.0.5.tgz",
@ -86,9 +105,9 @@
}
},
"@pushrocks/smartshell": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@pushrocks/smartshell/-/smartshell-2.0.4.tgz",
"integrity": "sha512-yGVfp0i474nBUL44ufx5AQchFs5gAYBHiVAupDcG5H0f0KmnR2RKK1EIqKmdfmK7CIqLf8IAvv9FlhetmSrUhw==",
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/@pushrocks/smartshell/-/smartshell-2.0.5.tgz",
"integrity": "sha512-bMmh46jfJxQ7F46bdujmBR8BqPeEFxBqdXab7885v0kaXASIf9+1BMPKfXiPsDrrR8z/2j2cG/Wgh/0+DDD9hQ==",
"requires": {
"@pushrocks/smartpromise": "^2.0.5",
"@types/which": "^1.3.1",

View File

@ -1,21 +1,25 @@
{
"name": "tstest",
"version": "1.0.2",
"name": "@gitzone/tstest",
"version": "1.0.8",
"private": false,
"description": "a test utility to run tests that match test/**/*.ts",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"author": "Lossless GmbH",
"license": "MIT",
"bin": {
"tstest": "./cli.js"
},
"scripts": {
"test": "(npm run prepareTest && npm run tstest && npm run cleanUp)",
"prepareTest": "git clone git@gitlab.com:sandboxzone/sandbox-npmts.git .nogit/sandbox-npmts && cd .nogit/sandbox-npmts && npm install",
"prepareTest": "git clone https://gitlab.com/sandboxzone/sandbox-npmts.git .nogit/sandbox-npmts && cd .nogit/sandbox-npmts && npm install",
"tstest": "cd .nogit/sandbox-npmts && node ../../cli.ts.js test/",
"cleanUp": "rm -rf .nogit/sandbox-npmts",
"format": "(gitzone format)",
"build": "echo \"Not needed for now\""
"build": "(tsbuild)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.0.21",
"@pushrocks/tapbundle": "^3.0.1"
},
"dependencies": {
@ -24,6 +28,6 @@
"@pushrocks/smartfile": "^6.0.3",
"@pushrocks/smartlog": "^2.0.1",
"@pushrocks/smartpromise": "^2.0.5",
"@pushrocks/smartshell": "^2.0.4"
"@pushrocks/smartshell": "^2.0.5"
}
}

View File

@ -1,9 +1,10 @@
import * as plugins from "./tstest.plugins";
import * as plugins from './tstest.plugins';
import * as paths from './tstest.paths';
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 { TestDirectory } from './tstest.classes.testdirectory';
import { TapCombinator } from './tstest.tap.combinator';
import { TapParser } from './tstest.tap.parser';
export class TsTest {
testDir: TestDirectory;
@ -16,22 +17,24 @@ export class TsTest {
const fileNamesToRun: string[] = await this.testDir.getTestFilePathArray();
console.log(`Found ${fileNamesToRun.length} Testfile(s):`);
for (const fileName of fileNamesToRun) {
console.log(cs(fileName, "orange"));
console.log(cs(fileName, 'orange'));
}
console.log("-".repeat(16));
console.log('-'.repeat(16));
console.log(''); // force new line
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: "bash",
executor: 'bash',
pathDirectories: [paths.binDirectory],
sourceFilePaths: []
});
const tapCombinator = new TapCombinator(); // lets create the TapCombinator
for (const fileName of fileNamesToRun) {
console.log(`${cs("=> ", "blue")} Running ${cs(fileName, "orange")}`);
console.log(`=`.repeat(16));
console.log(`${cs('=> ', 'blue')} Running ${cs(fileName, 'orange')}`);
console.log(cs(`=`.repeat(16), 'cyan'));
const tapParser = new TapParser();
const execResultStreaming = await smartshellInstance.execStreamingSilent(
`tsrun ${fileName}`
);
const execResultStreaming = await smartshellInstance.execStreamingSilent(`tsrun ${fileName}`);
await tapParser.handleTapProcess(execResultStreaming.childProcess);
console.log(cs(`^`.repeat(16), 'cyan'));
console.log(''); // force new line
tapCombinator.addTapParser(tapParser);
}
tapCombinator.evaluate();

View File

@ -1,7 +1,3 @@
import * as plugins from './tstest.plugins';
export const TapPrefix = plugins.consolecolor.coloredString(
`:::TAP:::`,
'green',
'black'
)
export const TapPrefix = plugins.consolecolor.coloredString(`:::TAP:::`, 'green', 'black');

View File

@ -2,3 +2,4 @@ import * as plugins from './tstest.plugins';
export const cwd = process.cwd();
export const testDir = plugins.path.join(cwd, './test/');
export const binDirectory = plugins.path.join(cwd, 'node_modules/.bin');

View File

@ -15,7 +15,6 @@ export class TapCombinator {
evaluate() {
console.log(`Ran ${this.tapParserStore.length} Testfiles!`);
for (const tapParser of this.tapParserStore) {
}
}
}

View File

@ -1,11 +1,12 @@
import { ChildProcess } from "child_process";
import { ChildProcess } from 'child_process';
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 * as plugins from './tstest.plugins';
import { TapTestResult } from './tstest.tap.testresult';
import * as logPrefixes from './tstest.logprefixes';
export class TapParser {
resultStore: TapTestResult[] = [];
@ -13,21 +14,19 @@ export class TapParser {
expectedTestsRegex = /([0-9]*)\.\.([0-9]*)/;
expectedTests: number;
testStatusRegex = /(ok|not\sok)\s([0-9]+)\s-\s/;
testStatusRegex = /(ok|not\sok)\s([0-9]+)\s-\s(.*)\s#\stime=(.*)ms$/;
activeTapTestResult: TapTestResult;
private _getNewTapTestResult () {
this.activeTapTestResult = new TapTestResult(
this.resultStore.length + 1
);
private _getNewTapTestResult() {
this.activeTapTestResult = new TapTestResult(this.resultStore.length + 1);
}
private _processLog(logChunk: Buffer | string) {
if (Buffer.isBuffer(logChunk)) {
logChunk = logChunk.toString();
}
const logLineArray = logChunk.split("\n");
if (logLineArray[logLineArray.length - 1] === "") {
const logLineArray = logChunk.split('\n');
if (logLineArray[logLineArray.length - 1] === '') {
logLineArray.pop();
}
@ -42,38 +41,40 @@ export class TapParser {
// initiating first TapResult
this._getNewTapTestResult();
} else if (this.testStatusRegex.test(logLine)) {
logLineIsTapProtocol = true;
const regexResult = this.testStatusRegex.exec(logLine);
const testId = parseInt(regexResult[2]);
const testOk = (() => {
if (regexResult[1] === "ok") {
if (regexResult[1] === 'ok') {
return true;
}
return false;
})();
const testSubject = regexResult[3];
const testDuration = parseInt(regexResult[4]);
// test for protocol error
if(testId !== this.activeTapTestResult.id) {
console.log(`:::TAP PROTOCOL ERROR::: Something is strange! Test Ids are not equal!`)
if (testId !== this.activeTapTestResult.id) {
console.log(`:::TAP PROTOCOL ERROR::: Something is strange! Test Ids are not equal!`);
}
this.activeTapTestResult.setTestResult(testOk);
if(testOk) {
if (testOk) {
console.log(
cs(
`:::TAP::: Success: Test ${testId} is ok!`,
'green',
'black'
));
logPrefixes.TapPrefix,
` ${cs(`Test ${testId} -> Success!`, 'green')} | ` +
cs(testSubject, 'blue') +
` | ${cs(`${testDuration} milliseconds`, 'orange')}`
);
} else {
console.log(
cs(
`:::TAP::: Error: Test ${testId} is NOT ok!`,
'green',
'black'
));
logPrefixes.TapPrefix,
` ${cs(`Test ${testId} -> Error!`, 'red')} | ` +
cs(testSubject, 'blue') +
` | ${cs(`${testDuration} milliseconds`, 'orange')}`
);
}
}
@ -84,7 +85,7 @@ export class TapParser {
console.log(logLine);
}
if(this.activeTapTestResult && this.activeTapTestResult.testSettled) {
if (this.activeTapTestResult && this.activeTapTestResult.testSettled) {
this.resultStore.push(this.activeTapTestResult);
this._getNewTapTestResult();
}
@ -93,13 +94,13 @@ export class TapParser {
async handleTapProcess(childProcessArg: ChildProcess) {
const done = plugins.smartpromise.defer();
childProcessArg.stdout.on("data", data => {
childProcessArg.stdout.on('data', data => {
this._processLog(data);
});
childProcessArg.stderr.on("data", data => {
childProcessArg.stderr.on('data', data => {
this._processLog(data);
});
childProcessArg.on("exit", () => {
childProcessArg.on('exit', () => {
done.resolve();
});
await done.promise;

View File

@ -7,9 +7,7 @@ export class TapTestResult {
testLogBuffer = Buffer.from('');
testOk: boolean = false;
testSettled: boolean = false;
constructor(public id: number) {
}
constructor(public id: number) {}
/**
* adds a logLine to the log buffer of the test