fix(peerDependency): now correctly finds bin of tsrun peer Dependency

This commit is contained in:
Philipp Kunz 2018-08-04 17:13:01 +02:00
parent b0dddd48a2
commit ec3999300d
8 changed files with 36 additions and 55 deletions

6
package-lock.json generated
View File

@ -105,9 +105,9 @@
} }
}, },
"@pushrocks/smartshell": { "@pushrocks/smartshell": {
"version": "2.0.4", "version": "2.0.5",
"resolved": "https://registry.npmjs.org/@pushrocks/smartshell/-/smartshell-2.0.4.tgz", "resolved": "https://registry.npmjs.org/@pushrocks/smartshell/-/smartshell-2.0.5.tgz",
"integrity": "sha512-yGVfp0i474nBUL44ufx5AQchFs5gAYBHiVAupDcG5H0f0KmnR2RKK1EIqKmdfmK7CIqLf8IAvv9FlhetmSrUhw==", "integrity": "sha512-bMmh46jfJxQ7F46bdujmBR8BqPeEFxBqdXab7885v0kaXASIf9+1BMPKfXiPsDrrR8z/2j2cG/Wgh/0+DDD9hQ==",
"requires": { "requires": {
"@pushrocks/smartpromise": "^2.0.5", "@pushrocks/smartpromise": "^2.0.5",
"@types/which": "^1.3.1", "@types/which": "^1.3.1",

View File

@ -28,6 +28,6 @@
"@pushrocks/smartfile": "^6.0.3", "@pushrocks/smartfile": "^6.0.3",
"@pushrocks/smartlog": "^2.0.1", "@pushrocks/smartlog": "^2.0.1",
"@pushrocks/smartpromise": "^2.0.5", "@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 { coloredString as cs } from '@pushrocks/consolecolor';
import { TestDirectory } from "./tstest.classes.testdirectory"; import { TestDirectory } from './tstest.classes.testdirectory';
import { TapCombinator } from "./tstest.tap.combinator"; import { TapCombinator } from './tstest.tap.combinator';
import { TapParser } from "./tstest.tap.parser"; import { TapParser } from './tstest.tap.parser';
export class TsTest { export class TsTest {
testDir: TestDirectory; testDir: TestDirectory;
@ -16,21 +17,20 @@ export class TsTest {
const fileNamesToRun: string[] = await this.testDir.getTestFilePathArray(); const fileNamesToRun: string[] = await this.testDir.getTestFilePathArray();
console.log(`Found ${fileNamesToRun.length} Testfile(s):`); console.log(`Found ${fileNamesToRun.length} Testfile(s):`);
for (const fileName of fileNamesToRun) { for (const fileName of fileNamesToRun) {
console.log(cs(fileName, "orange")); console.log(cs(fileName, 'orange'));
} }
console.log("-".repeat(16)); console.log('-'.repeat(16));
const smartshellInstance = new plugins.smartshell.Smartshell({ const smartshellInstance = new plugins.smartshell.Smartshell({
executor: "bash", executor: 'bash',
pathDirectories: [paths.binDirectory],
sourceFilePaths: [] sourceFilePaths: []
}); });
const tapCombinator = new TapCombinator(); // lets create the TapCombinator const tapCombinator = new TapCombinator(); // lets create the TapCombinator
for (const fileName of fileNamesToRun) { for (const fileName of fileNamesToRun) {
console.log(`${cs("=> ", "blue")} Running ${cs(fileName, "orange")}`); console.log(`${cs('=> ', 'blue')} Running ${cs(fileName, 'orange')}`);
console.log(`=`.repeat(16)); console.log(`=`.repeat(16));
const tapParser = new TapParser(); const tapParser = new TapParser();
const execResultStreaming = await smartshellInstance.execStreamingSilent( const execResultStreaming = await smartshellInstance.execStreamingSilent(`tsrun ${fileName}`);
`tsrun ${fileName}`
);
await tapParser.handleTapProcess(execResultStreaming.childProcess); await tapParser.handleTapProcess(execResultStreaming.childProcess);
tapCombinator.addTapParser(tapParser); tapCombinator.addTapParser(tapParser);
} }

View File

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

View File

@ -2,3 +2,4 @@ import * as plugins from './tstest.plugins';
export const cwd = process.cwd(); export const cwd = process.cwd();
export const testDir = plugins.path.join(cwd, './test/'); 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() { evaluate() {
console.log(`Ran ${this.tapParserStore.length} Testfiles!`); console.log(`Ran ${this.tapParserStore.length} Testfiles!`);
for (const tapParser of this.tapParserStore) { for (const tapParser of this.tapParserStore) {
} }
} }
} }

View File

@ -1,11 +1,11 @@
import { ChildProcess } from "child_process"; import { ChildProcess } from 'child_process';
import { coloredString as cs } from '@pushrocks/consolecolor'; import { coloredString as cs } from '@pushrocks/consolecolor';
// ============ // ============
// combines different tap test files to an overall result // combines different tap test files to an overall result
// ============ // ============
import * as plugins from "./tstest.plugins"; import * as plugins from './tstest.plugins';
import { TapTestResult } from "./tstest.tap.testresult"; import { TapTestResult } from './tstest.tap.testresult';
export class TapParser { export class TapParser {
resultStore: TapTestResult[] = []; resultStore: TapTestResult[] = [];
@ -16,18 +16,16 @@ export class TapParser {
testStatusRegex = /(ok|not\sok)\s([0-9]+)\s-\s/; testStatusRegex = /(ok|not\sok)\s([0-9]+)\s-\s/;
activeTapTestResult: TapTestResult; activeTapTestResult: TapTestResult;
private _getNewTapTestResult () { private _getNewTapTestResult() {
this.activeTapTestResult = new TapTestResult( this.activeTapTestResult = new TapTestResult(this.resultStore.length + 1);
this.resultStore.length + 1
);
} }
private _processLog(logChunk: Buffer | string) { private _processLog(logChunk: Buffer | string) {
if (Buffer.isBuffer(logChunk)) { if (Buffer.isBuffer(logChunk)) {
logChunk = logChunk.toString(); logChunk = logChunk.toString();
} }
const logLineArray = logChunk.split("\n"); const logLineArray = logChunk.split('\n');
if (logLineArray[logLineArray.length - 1] === "") { if (logLineArray[logLineArray.length - 1] === '') {
logLineArray.pop(); logLineArray.pop();
} }
@ -42,38 +40,27 @@ export class TapParser {
// initiating first TapResult // initiating first TapResult
this._getNewTapTestResult(); this._getNewTapTestResult();
} else if (this.testStatusRegex.test(logLine)) { } else if (this.testStatusRegex.test(logLine)) {
logLineIsTapProtocol = true; logLineIsTapProtocol = true;
const regexResult = this.testStatusRegex.exec(logLine); const regexResult = this.testStatusRegex.exec(logLine);
const testId = parseInt(regexResult[2]); const testId = parseInt(regexResult[2]);
const testOk = (() => { const testOk = (() => {
if (regexResult[1] === "ok") { if (regexResult[1] === 'ok') {
return true; return true;
} }
return false; return false;
})(); })();
// test for protocol error // test for protocol error
if(testId !== this.activeTapTestResult.id) { if (testId !== this.activeTapTestResult.id) {
console.log(`:::TAP PROTOCOL ERROR::: Something is strange! Test Ids are not equal!`) console.log(`:::TAP PROTOCOL ERROR::: Something is strange! Test Ids are not equal!`);
} }
this.activeTapTestResult.setTestResult(testOk); this.activeTapTestResult.setTestResult(testOk);
if(testOk) { if (testOk) {
console.log( console.log(cs(`:::TAP::: Success: Test ${testId} is ok!`, 'green', 'black'));
cs(
`:::TAP::: Success: Test ${testId} is ok!`,
'green',
'black'
));
} else { } else {
console.log( console.log(cs(`:::TAP::: Error: Test ${testId} is NOT ok!`, 'green', 'black'));
cs(
`:::TAP::: Error: Test ${testId} is NOT ok!`,
'green',
'black'
));
} }
} }
@ -84,7 +71,7 @@ export class TapParser {
console.log(logLine); console.log(logLine);
} }
if(this.activeTapTestResult && this.activeTapTestResult.testSettled) { if (this.activeTapTestResult && this.activeTapTestResult.testSettled) {
this.resultStore.push(this.activeTapTestResult); this.resultStore.push(this.activeTapTestResult);
this._getNewTapTestResult(); this._getNewTapTestResult();
} }
@ -93,13 +80,13 @@ export class TapParser {
async handleTapProcess(childProcessArg: ChildProcess) { async handleTapProcess(childProcessArg: ChildProcess) {
const done = plugins.smartpromise.defer(); const done = plugins.smartpromise.defer();
childProcessArg.stdout.on("data", data => { childProcessArg.stdout.on('data', data => {
this._processLog(data); this._processLog(data);
}); });
childProcessArg.stderr.on("data", data => { childProcessArg.stderr.on('data', data => {
this._processLog(data); this._processLog(data);
}); });
childProcessArg.on("exit", () => { childProcessArg.on('exit', () => {
done.resolve(); done.resolve();
}); });
await done.promise; await done.promise;

View File

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