feat(tools): can now ensure certain directories
This commit is contained in:
parent
deae532820
commit
3ac46b2363
743
package-lock.json
generated
743
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -22,6 +22,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/early": "^3.0.3",
|
"@pushrocks/early": "^3.0.3",
|
||||||
"@pushrocks/smartdelay": "^2.0.3",
|
"@pushrocks/smartdelay": "^2.0.3",
|
||||||
|
"@pushrocks/smartfile": "^7.0.6",
|
||||||
"@pushrocks/smartpromise": "^3.0.2",
|
"@pushrocks/smartpromise": "^3.0.2",
|
||||||
"smartchai": "^2.0.1"
|
"smartchai": "^2.0.1"
|
||||||
},
|
},
|
||||||
|
@ -7,7 +7,7 @@ export class Tap {
|
|||||||
* skips a test
|
* skips a test
|
||||||
* tests marked with tap.skip.test() are never executed
|
* tests marked with tap.skip.test() are never executed
|
||||||
*/
|
*/
|
||||||
skip = {
|
public skip = {
|
||||||
test: (descriptionArg: string, functionArg: ITestFunction) => {
|
test: (descriptionArg: string, functionArg: ITestFunction) => {
|
||||||
console.log(`skipped test: ${descriptionArg}`);
|
console.log(`skipped test: ${descriptionArg}`);
|
||||||
},
|
},
|
||||||
@ -19,7 +19,7 @@ export class Tap {
|
|||||||
/**
|
/**
|
||||||
* only executes tests marked as ONLY
|
* only executes tests marked as ONLY
|
||||||
*/
|
*/
|
||||||
only = {
|
public only = {
|
||||||
test: (descriptionArg: string, testFunctionArg: ITestFunction) => {
|
test: (descriptionArg: string, testFunctionArg: ITestFunction) => {
|
||||||
this.test(descriptionArg, testFunctionArg, 'only');
|
this.test(descriptionArg, testFunctionArg, 'only');
|
||||||
}
|
}
|
||||||
@ -33,14 +33,14 @@ export class Tap {
|
|||||||
* @param testDescription - A description of what the test does
|
* @param testDescription - A description of what the test does
|
||||||
* @param testFunction - A Function that returns a Promise and resolves or rejects
|
* @param testFunction - A Function that returns a Promise and resolves or rejects
|
||||||
*/
|
*/
|
||||||
async test(
|
public async test(
|
||||||
testDescription: string,
|
testDescription: string,
|
||||||
testFunction: ITestFunction,
|
testFunction: ITestFunction,
|
||||||
modeArg: 'normal' | 'only' | 'skip' = 'normal'
|
modeArg: 'normal' | 'only' | 'skip' = 'normal'
|
||||||
) {
|
) {
|
||||||
let localTest = new TapTest({
|
const localTest = new TapTest({
|
||||||
description: testDescription,
|
description: testDescription,
|
||||||
testFunction: testFunction,
|
testFunction,
|
||||||
parallel: false
|
parallel: false
|
||||||
});
|
});
|
||||||
if (modeArg === 'normal') {
|
if (modeArg === 'normal') {
|
||||||
@ -54,7 +54,7 @@ export class Tap {
|
|||||||
/**
|
/**
|
||||||
* wraps function
|
* wraps function
|
||||||
*/
|
*/
|
||||||
wrap(functionArg: ITapWrapFunction) {
|
public wrap(functionArg: ITapWrapFunction) {
|
||||||
return new TapWrap(functionArg);
|
return new TapWrap(functionArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,11 +63,11 @@ export class Tap {
|
|||||||
* @param testDescription - A description of what the test does
|
* @param testDescription - A description of what the test does
|
||||||
* @param testFunction - A Function that returns a Promise and resolves or rejects
|
* @param testFunction - A Function that returns a Promise and resolves or rejects
|
||||||
*/
|
*/
|
||||||
testParallel(testDescription: string, testFunction: ITestFunction) {
|
public testParallel(testDescription: string, testFunction: ITestFunction) {
|
||||||
this._tapTests.push(
|
this._tapTests.push(
|
||||||
new TapTest({
|
new TapTest({
|
||||||
description: testDescription,
|
description: testDescription,
|
||||||
testFunction: testFunction,
|
testFunction,
|
||||||
parallel: true
|
parallel: true
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -76,8 +76,8 @@ export class Tap {
|
|||||||
/**
|
/**
|
||||||
* starts the test evaluation
|
* starts the test evaluation
|
||||||
*/
|
*/
|
||||||
async start(optionsArg?: { throwOnError: boolean }) {
|
public async start(optionsArg?: { throwOnError: boolean }) {
|
||||||
let promiseArray: Promise<any>[] = [];
|
const promiseArray: Array<Promise<any>> = [];
|
||||||
|
|
||||||
// safeguard against empty test array
|
// safeguard against empty test array
|
||||||
if (this._tapTests.length === 0) {
|
if (this._tapTests.length === 0) {
|
||||||
@ -95,8 +95,8 @@ export class Tap {
|
|||||||
|
|
||||||
console.log(`1..${concerningTests.length}`);
|
console.log(`1..${concerningTests.length}`);
|
||||||
for (let testKey = 0; testKey < concerningTests.length; testKey++) {
|
for (let testKey = 0; testKey < concerningTests.length; testKey++) {
|
||||||
let currentTest = concerningTests[testKey];
|
const currentTest = concerningTests[testKey];
|
||||||
let testPromise = currentTest.run(testKey);
|
const testPromise = currentTest.run(testKey);
|
||||||
if (currentTest.parallel) {
|
if (currentTest.parallel) {
|
||||||
promiseArray.push(testPromise);
|
promiseArray.push(testPromise);
|
||||||
} else {
|
} else {
|
||||||
@ -106,10 +106,10 @@ export class Tap {
|
|||||||
await Promise.all(promiseArray);
|
await Promise.all(promiseArray);
|
||||||
|
|
||||||
// when tests have been run and all promises are fullfilled
|
// when tests have been run and all promises are fullfilled
|
||||||
let failReasons: string[] = [];
|
const failReasons: string[] = [];
|
||||||
let executionNotes: string[] = [];
|
const executionNotes: string[] = [];
|
||||||
// collect failed tests
|
// collect failed tests
|
||||||
for (let tapTest of concerningTests) {
|
for (const tapTest of concerningTests) {
|
||||||
if (tapTest.status !== 'success') {
|
if (tapTest.status !== 'success') {
|
||||||
failReasons.push(
|
failReasons.push(
|
||||||
`Test ${tapTest.testKey + 1} failed with status ${tapTest.status}:\n` +
|
`Test ${tapTest.testKey + 1} failed with status ${tapTest.status}:\n` +
|
||||||
@ -120,7 +120,7 @@ export class Tap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// render fail Reasons
|
// render fail Reasons
|
||||||
for (let failReason of failReasons) {
|
for (const failReason of failReasons) {
|
||||||
console.log(failReason);
|
console.log(failReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ export class Tap {
|
|||||||
/**
|
/**
|
||||||
* handle errors
|
* handle errors
|
||||||
*/
|
*/
|
||||||
threw(err) {
|
public threw(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,10 @@ export class TapTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async ensureDir(pathArg: string) {
|
||||||
|
await plugins.smartfile.fs.ensureDir(pathArg);
|
||||||
|
}
|
||||||
|
|
||||||
public async checkIterationLeak(iterationfuncArg: IPromiseFunc) {
|
public async checkIterationLeak(iterationfuncArg: IPromiseFunc) {
|
||||||
console.log('iteration leakage checks disabled for now due to incompatibilities with node v12');
|
console.log('iteration leakage checks disabled for now due to incompatibilities with node v12');
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
// pushrocks
|
// pushrocks
|
||||||
import * as early from '@pushrocks/early';
|
import * as early from '@pushrocks/early';
|
||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
export { early, smartdelay, smartpromise };
|
export { early, smartfile, smartdelay, smartpromise };
|
||||||
|
|
||||||
// third party
|
// third party
|
||||||
/* import * as leakage from 'leakage';
|
/* import * as leakage from 'leakage';
|
||||||
|
Loading…
Reference in New Issue
Block a user