now has correct test time measurement

This commit is contained in:
Philipp Kunz 2017-04-23 22:08:52 +02:00
parent 140f8a2499
commit 42cd52a2f3
8 changed files with 54 additions and 15 deletions

View File

@ -1,4 +1,5 @@
import 'typings-global';
import * as smartq from 'smartq';
import * as early from 'early';
import * as leakage from 'leakage';
export { smartq, leakage };
import * as smartq from 'smartq';
export { early, smartq, leakage };

View File

@ -1,8 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global");
const smartq = require("smartq");
exports.smartq = smartq;
const early = require("early");
exports.early = early;
const leakage = require("leakage");
exports.leakage = leakage;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90YXBidW5kbGUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QixpQ0FBZ0M7QUFJOUIsd0JBQU07QUFIUixtQ0FBa0M7QUFJaEMsMEJBQU8ifQ==
const smartq = require("smartq");
exports.smartq = smartq;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90YXBidW5kbGUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QiwrQkFBOEI7QUFLNUIsc0JBQUs7QUFKUCxtQ0FBa0M7QUFNaEMsMEJBQU87QUFMVCxpQ0FBZ0M7QUFJOUIsd0JBQU0ifQ==

View File

@ -1,13 +1,14 @@
import { HrtMeasurement } from 'early';
export declare type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess';
export interface ITestFunction {
(): Promise<any>;
}
export declare class TapTest {
description: string;
parallel: boolean;
hrtMeasurement: HrtMeasurement;
testFunction: ITestFunction;
status: TTestStatus;
parallel: boolean;
returnValue: any;
/**
* constructor
*/

12
dist/tapbundle.tap.js vendored
View File

@ -8,6 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", { value: true });
// imported interfaces
const early_1 = require("early");
class TapTest {
/**
* constructor
@ -17,19 +19,23 @@ class TapTest {
this.testFunction = optionsArg.testFunction;
this.parallel = optionsArg.parallel;
this.status = 'pending';
this.hrtMeasurement = new early_1.HrtMeasurement();
}
/**
* run the test
*/
run(testKeyArg) {
return __awaiter(this, void 0, void 0, function* () {
this.hrtMeasurement.start();
try {
yield this.testFunction();
console.log(`ok ${testKeyArg + 1} - ${this.description} # time=20.040ms`);
this.hrtMeasurement.stop();
console.log(`ok ${testKeyArg + 1} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`);
this.status = 'success';
}
catch (err) {
console.log(`not ok ${testKeyArg + 1} - ${this.description} # time=20.040ms`);
this.hrtMeasurement.stop();
console.log(`not ok ${testKeyArg + 1} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`);
if (this.status === 'success') {
this.status = 'errorAfterSuccess';
console.log('!!! ALERT !!!: weird behaviour, since test has been already successfull');
@ -111,4 +117,4 @@ class Tap {
}
exports.Tap = Tap;
exports.tap = new Tap();
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwYnVuZGxlLnRhcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3RhcGJ1bmRsZS50YXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQVlBO0lBT0U7O09BRUc7SUFDSCxZQUFhLFVBSVo7UUFDQyxJQUFJLENBQUMsV0FBVyxHQUFHLFVBQVUsQ0FBQyxXQUFXLENBQUE7UUFDekMsSUFBSSxDQUFDLFlBQVksR0FBRyxVQUFVLENBQUM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": "^1.0.3",
"smartq": "^1.1.1",

View File

@ -1,8 +1,10 @@
import 'typings-global'
import * as smartq from 'smartq'
import * as early from 'early'
import * as leakage from 'leakage'
import * as smartq from 'smartq'
export {
early,
smartq,
leakage
}

View File

@ -2,6 +2,9 @@ import * as plugins from './tapbundle.plugins'
import { tapCreator } from './tapbundle.tapcreator'
// imported interfaces
import { HrtMeasurement } from 'early'
// interfaces
export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess'
@ -12,10 +15,10 @@ export interface ITestFunction {
export class TapTest {
description: string
parallel: boolean
hrtMeasurement: HrtMeasurement
testFunction: ITestFunction
status: TTestStatus
parallel: boolean
returnValue
/**
* constructor
@ -29,18 +32,22 @@ export class TapTest {
this.testFunction = optionsArg.testFunction
this.parallel = optionsArg.parallel
this.status = 'pending'
this.hrtMeasurement = new HrtMeasurement()
}
/**
* run the test
*/
async run (testKeyArg: number) {
this.hrtMeasurement.start()
try {
await this.testFunction()
console.log(`ok ${testKeyArg + 1} - ${this.description} # time=20.040ms`)
this.hrtMeasurement.stop()
console.log(`ok ${testKeyArg + 1} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`)
this.status = 'success'
} catch (err) {
console.log(`not ok ${testKeyArg + 1} - ${this.description} # time=20.040ms`)
this.hrtMeasurement.stop()
console.log(`not ok ${testKeyArg + 1} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`)
if (this.status === 'success') {
this.status = 'errorAfterSuccess'
console.log('!!! ALERT !!!: weird behaviour, since test has been already successfull')

View File

@ -23,6 +23,10 @@
version "0.0.27"
resolved "https://registry.yarnpkg.com/@types/promises-a-plus/-/promises-a-plus-0.0.27.tgz#c64651134614c84b8f5d7114ce8901d36a609780"
ansi-256-colors@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/ansi-256-colors/-/ansi-256-colors-1.1.0.tgz#910de50efcc7c09e3d82f2f87abd6b700c18818a"
assertion-error@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.0.2.tgz#13ca515d86206da0bac66e834dd397d87581094c"
@ -31,6 +35,13 @@ balanced-match@^0.4.1:
version "0.4.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
beautycolor@^1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/beautycolor/-/beautycolor-1.0.7.tgz#a4715738ac4c8221371e9cbeb5a6cc6d11ecbf7c"
dependencies:
ansi-256-colors "^1.1.0"
typings-global "^1.0.14"
bindings@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.2.1.tgz#14ad6113812d2d37d72e67b4cacb4bb726505f11"
@ -74,6 +85,14 @@ deep-eql@^0.1.3:
dependencies:
type-detect "0.1.1"
early@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/early/-/early-2.1.1.tgz#841e23254ea5dc54d8afaeee82f5ab65c00ee23c"
dependencies:
beautycolor "^1.0.7"
smartq "^1.1.1"
typings-global "^1.0.16"
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"