Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
df3f1ea9d6 | |||
d749476d0c | |||
4456cd68d0 | |||
8f61b5648f | |||
5e1b378ac6 | |||
a0ed5c7a16 | |||
7a20c0a27f | |||
12414d7b5d | |||
addf9e51e9 | |||
24a6b7480b | |||
953a4e4b72 | |||
e7192800ea | |||
1516f843aa | |||
f29558d6d1 | |||
b6dc2df384 | |||
ec3999300d | |||
b0dddd48a2 | |||
65dda322c5 |
101
package-lock.json
generated
101
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/tstest",
|
||||
"version": "1.0.4",
|
||||
"name": "@gitzone/tstest",
|
||||
"version": "1.0.13",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -18,7 +18,6 @@
|
||||
"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",
|
||||
@ -28,13 +27,21 @@
|
||||
}
|
||||
},
|
||||
"@gitzone/tsrun": {
|
||||
"version": "1.1.9",
|
||||
"resolved": "https://registry.npmjs.org/@gitzone/tsrun/-/tsrun-1.1.9.tgz",
|
||||
"integrity": "sha512-MbCLj4hSK5nY6cMqT0OxY0BrXffmiC1Rjbzan8CmEpB8OttaAJT+zsJErJWhI+pk4s75Te73PyhHYaJAXUoJhw==",
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/@gitzone/tsrun/-/tsrun-1.1.11.tgz",
|
||||
"integrity": "sha512-LkWEmEDyG1px40sDWSgC3STw54VbVAGq828eZsfhYkKlpJa+HzLP0LG5Q31mwjSUFWlCf4AU4MFOD9xbUXTahA==",
|
||||
"requires": {
|
||||
"@pushrocks/smartfile": "^6.0.3",
|
||||
"@gitzone/tsbuild": "^2.0.21",
|
||||
"@pushrocks/smartfile": "^6.0.6",
|
||||
"ts-node": "^7.0.0",
|
||||
"typescript": "^2.9.1"
|
||||
"typescript": "^3.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"typescript": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.1.tgz",
|
||||
"integrity": "sha512-zQIMOmC+372pC/CCVLqnQ0zSBiY7HHodU7mpQdjiZddek4GMj31I3dUJ7gAs9o65X7mnRma6OokOkc6f9jjfBg=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@pushrocks/consolecolor": {
|
||||
@ -55,18 +62,18 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartfile": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartfile/-/smartfile-6.0.3.tgz",
|
||||
"integrity": "sha512-oYnLQzY/R6kVNerbWY4WwnPvdxXldrzMPWcB9j0aAdSDSqGwBEO1/ZFTQuNzN5MmPopoYmJrc06ZmI6dm4OJmw==",
|
||||
"version": "6.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartfile/-/smartfile-6.0.6.tgz",
|
||||
"integrity": "sha512-vA1+yS6n0kuBZ+Bl30rxOCYvgIj0mo9g303cUpOZR0I781iQVWHcBKRC05FaGDxJD1HuYdvbSK+7vlrzZjVcMw==",
|
||||
"requires": {
|
||||
"@pushrocks/smartpath": "^4.0.1",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@pushrocks/smartrequest": "^1.0.15",
|
||||
"@types/fs-extra": "^5.0.3",
|
||||
"@pushrocks/smartrequest": "^1.1.12",
|
||||
"@types/fs-extra": "^5.0.4",
|
||||
"@types/vinyl": "^2.0.2",
|
||||
"fs-extra": "^6.0.1",
|
||||
"fs-extra": "^7.0.0",
|
||||
"glob": "^7.1.2",
|
||||
"js-yaml": "^3.10.0",
|
||||
"smartpath": "^3.2.8",
|
||||
"vinyl-file": "^3.0.0"
|
||||
}
|
||||
},
|
||||
@ -86,8 +93,7 @@
|
||||
"@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
|
||||
"integrity": "sha512-MaI0+uLQPCr2V3WGnbdgb0pWa9xkWyrP4qYcbsHIjeismGLbn9s3jmP/HIXU8LkgzRgaVb+BJxmZJHOwl32DyA=="
|
||||
},
|
||||
"@pushrocks/smartpromise": {
|
||||
"version": "2.0.5",
|
||||
@ -105,9 +111,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.6",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartshell/-/smartshell-2.0.6.tgz",
|
||||
"integrity": "sha512-D48KB3DDqLfMjOXGEutqJi+v3Z4RcWacu5BJXxUwrecvd6oetbKobfmNGxeHSQPmNGb7U3ISfKwV6c5T5EZkJg==",
|
||||
"requires": {
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@types/which": "^1.3.1",
|
||||
@ -151,6 +157,11 @@
|
||||
"@types/chai": "*"
|
||||
}
|
||||
},
|
||||
"@types/figures": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/figures/-/figures-2.0.0.tgz",
|
||||
"integrity": "sha512-mcRgJ+ncKuNI+Dwac7omO18B8C8u+YBS+AU/oyLhEyjAnT3cUUThhHgZpbiIvu5ZqSvdD30BXtrqg9nxc3OKMg=="
|
||||
},
|
||||
"@types/form-data": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz",
|
||||
@ -168,9 +179,9 @@
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "10.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.5.tgz",
|
||||
"integrity": "sha512-6Qnb1gXbp3g1JX9QVJj3A6ORzc9XCyhokxUKaoonHgNXcQhmk8adhotxfkeK8El9TnFeUuH72yI6jQ5nDJKS6w=="
|
||||
"version": "10.5.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.7.tgz",
|
||||
"integrity": "sha512-VkKcfuitP+Nc/TaTFH0B8qNmn+6NbI6crLkQonbedViVz7O2w8QV/GERPlkJ4bg42VGHiEWa31CoTOPs1q6z1w=="
|
||||
},
|
||||
"@types/vinyl": {
|
||||
"version": "2.0.2",
|
||||
@ -397,11 +408,24 @@
|
||||
"integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==",
|
||||
"dev": true
|
||||
},
|
||||
"escape-string-regexp": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
||||
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
|
||||
},
|
||||
"esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
|
||||
},
|
||||
"figures": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz",
|
||||
"integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=",
|
||||
"requires": {
|
||||
"escape-string-regexp": "^1.0.5"
|
||||
}
|
||||
},
|
||||
"first-chunk-stream": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-2.0.0.tgz",
|
||||
@ -427,9 +451,9 @@
|
||||
}
|
||||
},
|
||||
"fs-extra": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz",
|
||||
"integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==",
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.0.tgz",
|
||||
"integrity": "sha512-EglNDLRpmaTWiD/qraZn6HREAEAHJcJOmxNEYwq6xeMKnVMAy3GUcFB+wXt2C6k4CNvB/mP1y/U3dzvKKj5OtQ==",
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.2",
|
||||
"jsonfile": "^4.0.0",
|
||||
@ -480,14 +504,6 @@
|
||||
"function-bind": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"home": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/home/-/home-1.0.1.tgz",
|
||||
"integrity": "sha1-lqQjzrSbmDeP9e886uBZpVf53TU=",
|
||||
"requires": {
|
||||
"os-homedir": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"inflight": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
@ -656,11 +672,6 @@
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"os-homedir": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
|
||||
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M="
|
||||
},
|
||||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
@ -731,15 +742,6 @@
|
||||
"chai-string": "^1.4.0"
|
||||
}
|
||||
},
|
||||
"smartpath": {
|
||||
"version": "3.2.8",
|
||||
"resolved": "https://registry.npmjs.org/smartpath/-/smartpath-3.2.8.tgz",
|
||||
"integrity": "sha1-SDS9OouuIpW6rK26I8h6UBlS+UA=",
|
||||
"requires": {
|
||||
"home": "^1.0.1",
|
||||
"typings-global": "^1.0.14"
|
||||
}
|
||||
},
|
||||
"smartq": {
|
||||
"version": "1.1.8",
|
||||
"resolved": "https://registry.npmjs.org/smartq/-/smartq-1.1.8.tgz",
|
||||
@ -830,7 +832,8 @@
|
||||
"typings-global": {
|
||||
"version": "1.0.28",
|
||||
"resolved": "https://registry.npmjs.org/typings-global/-/typings-global-1.0.28.tgz",
|
||||
"integrity": "sha512-6VOwJWEY2971HOMHu/7sURzUXiD4/LiMJPsMAOqkHHAtS3MVpLFE5gzTiHilsH9KY5VE1mBQirWIgWFsDuo90A=="
|
||||
"integrity": "sha512-6VOwJWEY2971HOMHu/7sURzUXiD4/LiMJPsMAOqkHHAtS3MVpLFE5gzTiHilsH9KY5VE1mBQirWIgWFsDuo90A==",
|
||||
"dev": true
|
||||
},
|
||||
"universalify": {
|
||||
"version": "0.1.2",
|
||||
|
14
package.json
14
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/tstest",
|
||||
"version": "1.0.4",
|
||||
"name": "@gitzone/tstest",
|
||||
"version": "1.0.13",
|
||||
"private": false,
|
||||
"description": "a test utility to run tests that match test/**/*.ts",
|
||||
"main": "dist/index.js",
|
||||
@ -12,7 +12,7 @@
|
||||
},
|
||||
"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)",
|
||||
@ -23,11 +23,13 @@
|
||||
"@pushrocks/tapbundle": "^3.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@gitzone/tsrun": "^1.1.9",
|
||||
"@gitzone/tsrun": "^1.1.11",
|
||||
"@pushrocks/consolecolor": "^2.0.1",
|
||||
"@pushrocks/smartfile": "^6.0.3",
|
||||
"@pushrocks/smartfile": "^6.0.6",
|
||||
"@pushrocks/smartlog": "^2.0.1",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@pushrocks/smartshell": "^2.0.4"
|
||||
"@pushrocks/smartshell": "^2.0.6",
|
||||
"@types/figures": "^2.0.0",
|
||||
"figures": "^2.0.0"
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
import * as plugins from "./tstest.plugins";
|
||||
import * as plugins from './tstest.plugins';
|
||||
import * as paths from './tstest.paths';
|
||||
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 { TestDirectory } from './tstest.classes.testdirectory';
|
||||
import { TapCombinator } from './tstest.tap.combinator';
|
||||
import { TapParser } from './tstest.tap.parser';
|
||||
|
||||
export class TsTest {
|
||||
testDir: TestDirectory;
|
||||
@ -14,24 +17,26 @@ export class TsTest {
|
||||
|
||||
async run() {
|
||||
const fileNamesToRun: string[] = await this.testDir.getTestFilePathArray();
|
||||
console.log(`Found ${fileNamesToRun.length} Testfile(s):`);
|
||||
console.log(`${logPrefixes.TsTestPrefix} Found ${fileNamesToRun.length} Testfile(s):`);
|
||||
for (const fileName of fileNamesToRun) {
|
||||
console.log(cs(fileName, "orange"));
|
||||
console.log(`${logPrefixes.TsTestPrefix} ${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));
|
||||
const tapParser = new TapParser();
|
||||
const execResultStreaming = await smartshellInstance.execStreamingSilent(
|
||||
`tsrun ${fileName}`
|
||||
);
|
||||
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}`);
|
||||
await tapParser.handleTapProcess(execResultStreaming.childProcess);
|
||||
console.log(cs(`^`.repeat(16), 'cyan'));
|
||||
console.log(''); // force new line
|
||||
tapCombinator.addTapParser(tapParser);
|
||||
}
|
||||
tapCombinator.evaluate();
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as plugins from './tstest.plugins';
|
||||
import { coloredString as cs } from '@pushrocks/consolecolor';
|
||||
|
||||
export const TapPrefix = plugins.consolecolor.coloredString(
|
||||
`:::TAP:::`,
|
||||
'green',
|
||||
'black'
|
||||
)
|
||||
export const TapPrefix = cs(`::TAP::`, 'pink', 'black');
|
||||
export const TapErrorPrefix = cs(` !!!TAP PROTOCOL ERROR!!! `, 'red', 'black');
|
||||
|
||||
export const TsTestPrefix = cs(`**TSTEST**`, 'pink', 'black');
|
||||
|
@ -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');
|
||||
|
@ -8,4 +8,7 @@ import * as smartlog from '@pushrocks/smartlog';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartshell from '@pushrocks/smartshell';
|
||||
|
||||
export { consolecolor, path, smartfile, smartlog, smartpromise, smartshell };
|
||||
// sindresorhus
|
||||
import * as figures from 'figures';
|
||||
|
||||
export { consolecolor, figures, path, smartfile, smartlog, smartpromise, smartshell };
|
||||
|
@ -5,6 +5,7 @@ import * as plugins from './tstest.plugins';
|
||||
import { coloredString as cs } from '@pushrocks/consolecolor';
|
||||
|
||||
import { TapParser } from './tstest.tap.parser';
|
||||
import * as logPrefixes from './tstest.logprefixes';
|
||||
|
||||
export class TapCombinator {
|
||||
tapParserStore: TapParser[] = [];
|
||||
@ -13,9 +14,35 @@ export class TapCombinator {
|
||||
}
|
||||
|
||||
evaluate() {
|
||||
console.log(`Ran ${this.tapParserStore.length} Testfiles!`);
|
||||
console.log(`${logPrefixes.TsTestPrefix} Ran ${this.tapParserStore.length} Testfiles!`);
|
||||
console.log(`${logPrefixes.TsTestPrefix} Here are the overall results:`);
|
||||
|
||||
let failGlobal = false; // determine wether tstest should fail
|
||||
for (const tapParser of this.tapParserStore) {
|
||||
|
||||
if(tapParser.getErrorTests().length === 0) {
|
||||
console.log(
|
||||
logPrefixes.TsTestPrefix +
|
||||
cs(` ${tapParser.fileName} ${plugins.figures.tick}`, 'green') +
|
||||
' | ' +
|
||||
cs(` all tests completed successfully!`, 'blue')
|
||||
)
|
||||
} else {
|
||||
console.log(
|
||||
logPrefixes.TsTestPrefix +
|
||||
cs(` ${tapParser.fileName} ${plugins.figures.cross}`, 'red') +
|
||||
' | ' +
|
||||
cs(` Errors ocurred, please check for the logs!`, 'blue')
|
||||
);
|
||||
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'));
|
||||
} else {
|
||||
console.log(cs('Ending with code 1: TESTS ARE FAILING!', 'red'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +1,39 @@
|
||||
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[] = [];
|
||||
testStore: TapTestResult[] = [];
|
||||
|
||||
expectedTestsRegex = /([0-9]*)\.\.([0-9]*)/;
|
||||
expectedTests: number;
|
||||
receivedTests: 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
|
||||
);
|
||||
/**
|
||||
* the constructor for TapParser
|
||||
*/
|
||||
constructor(public fileName: string) {}
|
||||
|
||||
|
||||
private _getNewTapTestResult() {
|
||||
this.activeTapTestResult = new TapTestResult(this.testStore.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();
|
||||
}
|
||||
|
||||
@ -38,42 +44,53 @@ export class TapParser {
|
||||
logLineIsTapProtocol = true;
|
||||
const regexResult = this.expectedTestsRegex.exec(logLine);
|
||||
this.expectedTests = parseInt(regexResult[2]);
|
||||
console.log(`:::TAP::: Expecting ${this.expectedTests} tests!`);
|
||||
console.log(
|
||||
`${logPrefixes.TapPrefix} ${cs(
|
||||
`Expecting ${this.expectedTests} tests!`,
|
||||
'blue'
|
||||
)}`
|
||||
);
|
||||
|
||||
// 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(
|
||||
`${
|
||||
logPrefixes.TapErrorPrefix
|
||||
} 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(`T${testId} ${plugins.figures.tick}`, 'green')} | ` +
|
||||
cs(testSubject, 'blue') +
|
||||
` | ${cs(`${testDuration} ms`, 'orange')}`
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
cs(
|
||||
`:::TAP::: Error: Test ${testId} is NOT ok!`,
|
||||
'green',
|
||||
'black'
|
||||
));
|
||||
logPrefixes.TapPrefix,
|
||||
`${cs(`T${testId} ${plugins.figures.cross}`, 'red')} | ` +
|
||||
cs(testSubject, 'blue') +
|
||||
` | ${cs(`${testDuration} ms`, 'orange')}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,22 +101,75 @@ export class TapParser {
|
||||
console.log(logLine);
|
||||
}
|
||||
|
||||
if(this.activeTapTestResult && this.activeTapTestResult.testSettled) {
|
||||
this.resultStore.push(this.activeTapTestResult);
|
||||
if (this.activeTapTestResult && this.activeTapTestResult.testSettled) {
|
||||
this.testStore.push(this.activeTapTestResult);
|
||||
this._getNewTapTestResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns all tests that are not completed
|
||||
*/
|
||||
getUncompletedTests() {
|
||||
// TODO:
|
||||
}
|
||||
|
||||
/**
|
||||
* returns all tests that threw an error
|
||||
*/
|
||||
getErrorTests() {
|
||||
return this.testStore.filter(tapTestArg => {
|
||||
return !tapTestArg.testOk;
|
||||
});
|
||||
}
|
||||
|
||||
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', () => {
|
||||
this.receivedTests = this.testStore.length;
|
||||
|
||||
// check wether all tests ran
|
||||
if (this.expectedTests === this.receivedTests) {
|
||||
console.log(
|
||||
`${logPrefixes.TapPrefix} ${cs(
|
||||
`${this.receivedTests} out of ${
|
||||
this.expectedTests
|
||||
} Tests completed!`,
|
||||
'green'
|
||||
)}`
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
`${logPrefixes.TapErrorPrefix} ${cs(
|
||||
`Only ${this.receivedTests} out of ${
|
||||
this.expectedTests
|
||||
} completed!`,
|
||||
'red'
|
||||
)}`
|
||||
);
|
||||
}
|
||||
if (this.getErrorTests().length === 0) {
|
||||
console.log(
|
||||
`${logPrefixes.TapPrefix} ${cs(
|
||||
`All tests are successfull!!!`,
|
||||
'green'
|
||||
)}`
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
`${logPrefixes.TapPrefix} ${cs(
|
||||
`${this.getErrorTests().length} tests threw an error!!!`,
|
||||
'red'
|
||||
)}`
|
||||
);
|
||||
}
|
||||
done.resolve();
|
||||
});
|
||||
await done.promise;
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user