now has better coverage failure

This commit is contained in:
Philipp Kunz 2016-03-30 01:32:41 +02:00
parent 5b0814520a
commit 58043d0fa2
15 changed files with 127 additions and 54 deletions

View File

@ -33,6 +33,7 @@ exports.run = function (configArg) {
// handle coveralls // handle coveralls
config.coveralls ? void (0) : config.coveralls = false; config.coveralls ? void (0) : config.coveralls = false;
exports.doPublish() ? void (0) : config.coveralls = false; exports.doPublish() ? void (0) : config.coveralls = false;
config.coverageTreshold ? void (0) : config.coverageTreshold = 70;
// handle docs // handle docs
config.docs ? void (0) : config.docs = {}; config.docs ? void (0) : config.docs = {};
config.docs.publish ? void (0) : config.docs.publish = false; config.docs.publish ? void (0) : config.docs.publish = false;

1
dist/npmts.paths.js vendored
View File

@ -8,6 +8,7 @@ paths.tsDir = plugins.path.join(paths.cwd, "ts/");
paths.distDir = plugins.path.join(paths.cwd, "dist/"); paths.distDir = plugins.path.join(paths.cwd, "dist/");
paths.docsDir = plugins.path.join(paths.cwd, "docs/"); paths.docsDir = plugins.path.join(paths.cwd, "docs/");
paths.testDir = plugins.path.join(paths.cwd, "test/"); paths.testDir = plugins.path.join(paths.cwd, "test/");
paths.coverageDir = plugins.path.join(paths.cwd, "coverage/");
paths.npmtsAssetsDir = plugins.path.join(__dirname, "../assets/"); paths.npmtsAssetsDir = plugins.path.join(__dirname, "../assets/");
//Files //Files
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts"); paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");

View File

@ -21,6 +21,7 @@ exports.Q = require("q");
exports.shelljs = require("shelljs"); exports.shelljs = require("shelljs");
exports.smartci = require("smartci"); exports.smartci = require("smartci");
exports.smartcli = require("smartcli"); exports.smartcli = require("smartcli");
exports.smartcov = require("smartcov");
exports.smartenv = require("smartenv"); exports.smartenv = require("smartenv");
exports.smartfile = require("smartfile"); exports.smartfile = require("smartfile");
exports.smartpath = require("smartpath"); exports.smartpath = require("smartpath");

70
dist/npmts.tests.js vendored
View File

@ -13,33 +13,65 @@ exports.publishCoverage = function (configArg) {
}, "atEnd")); }, "atEnd"));
return done.promise; return done.promise;
}; };
/**
*
* @returns {*}
*/
var istanbul = function (configArg) {
var done = plugins.Q.defer();
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
.pipe(plugins.g.istanbul()) // Covering files
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
.pipe(plugins.g.gFunction(function () {
done.resolve(configArg);
}, "atEnd"));
return done.promise;
};
/**
*
* @returns {*}
*/
var mocha = function (configArg) {
var done = plugins.Q.defer();
var stream = plugins.gulp.src(["./test/test.js"])
.pipe(plugins.g.mocha())
.pipe(plugins.g.istanbul.writeReports()) // Creating the reports after tests ran
.pipe(plugins.g.gFunction(function () {
plugins.beautylog.ok("Tests have passed!");
done.resolve(configArg);
}, "atEnd"));
return done.promise;
};
var coverage = function (configArg) {
var done = plugins.Q.defer();
plugins.smartcov.get.percentage(plugins.path.join(paths.coverageDir, "lcov.info"))
.then(function (percentageArg) {
if (percentageArg >= configArg.coverageTreshold) {
plugins.beautylog.ok("your coverage of " + percentageArg + "% " + "is within your treshold of " +
configArg.coverageTreshold + "%");
}
else {
plugins.beautylog.warn("your coverage of " + percentageArg + "% " + "fails your treshold of " +
configArg.coverageTreshold + "%");
plugins.beautylog.error("exiting due to coverage failure");
process.exit(1);
}
done.resolve(configArg);
});
return done.promise;
};
exports.run = function (configArg) { exports.run = function (configArg) {
var done = plugins.Q.defer(); var done = plugins.Q.defer();
var config = configArg; var config = configArg;
var istanbul = function () {
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
.pipe(plugins.g.istanbul())
.pipe(plugins.g.istanbul.hookRequire());
return stream;
};
var mocha = function () {
var stream = plugins.gulp.src(["./test/test.js"])
.pipe(plugins.g.mocha())
.pipe(plugins.g.istanbul.writeReports())
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
return stream;
};
plugins.beautylog.log("now starting tests"); plugins.beautylog.log("now starting tests");
console.log("--------------------------------------------------------------\n" + console.log("--------------------------------------------------------------\n" +
"***************************" + "***************************" +
" TESTS: ".blue + " TESTS: ".blue +
"***************************\n" + "***************************\n" +
"--------------------------------------------------------------"); "--------------------------------------------------------------");
istanbul().on("finish", function () { istanbul(config)
mocha().on("finish", function () { .then(mocha)
plugins.beautylog.ok("Tests have passed!"); .then(coverage)
done.resolve(config); .then(done.resolve);
});
});
return done.promise; return done.promise;
}; };

View File

@ -30,7 +30,7 @@
"gulp": "3.9.1", "gulp": "3.9.1",
"gulp-concat": "^2.6.0", "gulp-concat": "^2.6.0",
"gulp-coveralls": "^0.1.4", "gulp-coveralls": "^0.1.4",
"gulp-function": "^1.1.1", "gulp-function": "^1.2.0",
"gulp-if": "^2.0.0", "gulp-if": "^2.0.0",
"gulp-istanbul": "^0.10.3", "gulp-istanbul": "^0.10.3",
"gulp-jsdoc3": "^0.2.1", "gulp-jsdoc3": "^0.2.1",
@ -44,9 +44,10 @@
"shelljs": "^0.6.0", "shelljs": "^0.6.0",
"smartci": "0.0.1", "smartci": "0.0.1",
"smartcli": "0.0.11", "smartcli": "0.0.11",
"smartcov": "0.0.3",
"smartenv": "1.2.0", "smartenv": "1.2.0",
"smartfile": "2.2.0", "smartfile": "2.2.0",
"smartpath": "3.0.1", "smartpath": "3.0.3",
"source-map-support": "^0.4.0" "source-map-support": "^0.4.0"
}, },
"devDependencies": {} "devDependencies": {}

View File

@ -6,4 +6,4 @@ var testplugin = {
}; };
module.exports = testplugin; module.exports = testplugin;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0QztBQUM1QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxudmFyIHRlc3RwbHVnaW4gPSB7XG4gICAgbG9nU29tZXRoaW5nOiBmdW5jdGlvbigpe1xuICAgICAgICBjb25zb2xlLmxvZyhcIm9ubHkgZnVuY3Rpb24gZXhlY3V0ZWRcIik7XG4gICAgfVxufTtcbm1vZHVsZS5leHBvcnRzID0gdGVzdHBsdWdpbjsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0= //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0QztBQUM1QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxubGV0IHRlc3RwbHVnaW4gPSB7XG4gICAgbG9nU29tZXRoaW5nOiBmdW5jdGlvbigpe1xuICAgICAgICBjb25zb2xlLmxvZyhcIm9ubHkgZnVuY3Rpb24gZXhlY3V0ZWRcIik7XG4gICAgfVxufTtcbm1vZHVsZS5leHBvcnRzID0gdGVzdHBsdWdpbjsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=

View File

@ -1,2 +0,0 @@
/// <reference path="../ts/typings/main.d.ts" />
declare var testplugin: any;

View File

@ -7,4 +7,5 @@ describe("testplugins", function () {
}); });
}); });
}); });
//# sourceMappingURL=test.js.map
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELElBQUksVUFBVSxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDO0FBQzdDLFFBQVEsQ0FBQyxhQUFhLEVBQUM7SUFDbkIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixFQUFFLENBQUMsc0JBQXNCLEVBQUM7WUFDdEIsVUFBVSxDQUFDLFlBQVksRUFBRSxDQUFBO1FBQzdCLENBQUMsQ0FBQyxDQUFDO0lBQ1AsQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyIsImZpbGUiOiJ0ZXN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4uL3RzL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbnZhciB0ZXN0cGx1Z2luID0gcmVxdWlyZShcIi4uL2Rpc3QvaW5kZXguanNcIik7XG5kZXNjcmliZShcInRlc3RwbHVnaW5zXCIsZnVuY3Rpb24oKXtcbiAgICBkZXNjcmliZShcIi5sb2dTb21ldGhpbmdcIixmdW5jdGlvbigpe1xuICAgICAgICBpdChcInNob3VsZCBsb2cgc29tZXRoaW5nXCIsZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIHRlc3RwbHVnaW4ubG9nU29tZXRoaW5nKClcbiAgICAgICAgfSk7XG4gICAgfSk7XG59KTsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=

View File

@ -1,5 +1,5 @@
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
var testplugin = { let testplugin = {
logSomething: function(){ logSomething: function(){
console.log("only function executed"); console.log("only function executed");
} }

View File

@ -40,6 +40,8 @@ export var run = function(configArg){
config.coveralls ? void(0) : config.coveralls = false; config.coveralls ? void(0) : config.coveralls = false;
doPublish() ? void(0) : config.coveralls = false; doPublish() ? void(0) : config.coveralls = false;
config.coverageTreshold ? void(0) : config.coverageTreshold = 70;
// handle docs // handle docs
config.docs ? void(0) : config.docs = {}; config.docs ? void(0) : config.docs = {};
config.docs.publish ? void(0) : config.docs.publish = false; config.docs.publish ? void(0) : config.docs.publish = false;

View File

@ -8,6 +8,7 @@ paths.tsDir = plugins.path.join(paths.cwd,"ts/");
paths.distDir = plugins.path.join(paths.cwd,"dist/"); paths.distDir = plugins.path.join(paths.cwd,"dist/");
paths.docsDir = plugins.path.join(paths.cwd,"docs/"); paths.docsDir = plugins.path.join(paths.cwd,"docs/");
paths.testDir = plugins.path.join(paths.cwd,"test/"); paths.testDir = plugins.path.join(paths.cwd,"test/");
paths.coverageDir = plugins.path.join(paths.cwd,"coverage/");
paths.npmtsAssetsDir = plugins.path.join(__dirname,"../assets/"); paths.npmtsAssetsDir = plugins.path.join(__dirname,"../assets/");

View File

@ -21,6 +21,7 @@ export let Q = require("q");
export let shelljs = require("shelljs"); export let shelljs = require("shelljs");
export let smartci = require("smartci"); export let smartci = require("smartci");
export let smartcli = require("smartcli"); export let smartcli = require("smartcli");
export let smartcov = require("smartcov");
export let smartenv = require("smartenv"); export let smartenv = require("smartenv");
export let smartfile = require("smartfile"); export let smartfile = require("smartfile");
export let smartpath = require("smartpath"); export let smartpath = require("smartpath");

View File

@ -8,7 +8,6 @@ import NpmtsJsdoc = require("./npmts.jsdoc");
export let run = function(configArg){ export let run = function(configArg){
let done = plugins.Q.defer(); let done = plugins.Q.defer();
let config = configArg; let config = configArg;
let promiseArray = []; let promiseArray = [];
config.coveralls ? promiseArray.push(NpmtsTests.publishCoverage(configArg)) : void(0); config.coveralls ? promiseArray.push(NpmtsTests.publishCoverage(configArg)) : void(0);
config.docs.publish ? promiseArray.push(NpmtsJsdoc.publishDocs(configArg)) : void(0); config.docs.publish ? promiseArray.push(NpmtsJsdoc.publishDocs(configArg)) : void(0);

View File

@ -14,27 +14,62 @@ export let publishCoverage = function(configArg){
return done.promise; return done.promise;
}; };
export var run = function(configArg) { /**
var done = plugins.Q.defer(); *
var config = configArg; * @returns {*}
var istanbul = function () { */
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")]) let istanbul = function (configArg) {
// Covering files let done = plugins.Q.defer();
.pipe(plugins.g.istanbul()) var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
// Force `require` to return covered files .pipe(plugins.g.istanbul()) // Covering files
.pipe(plugins.g.istanbul.hookRequire()); .pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
return stream; .pipe(plugins.g.gFunction(function(){
}; done.resolve(configArg);
},"atEnd"));
return done.promise;
};
var mocha = function () { /**
var stream = plugins.gulp.src(["./test/test.js"]) *
.pipe(plugins.g.mocha()) * @returns {*}
// Creating the reports after tests ran */
.pipe(plugins.g.istanbul.writeReports()) let mocha = function (configArg) {
// Enforce a coverage of at least 90% let done = plugins.Q.defer();
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } })); let stream = plugins.gulp.src(["./test/test.js"])
return stream; .pipe(plugins.g.mocha())
}; .pipe(plugins.g.istanbul.writeReports()) // Creating the reports after tests ran
.pipe(plugins.g.gFunction(function(){
plugins.beautylog.ok("Tests have passed!");
done.resolve(configArg);
},"atEnd"));
return done.promise;
};
let coverage = function(configArg){
let done = plugins.Q.defer();
plugins.smartcov.get.percentage(plugins.path.join(paths.coverageDir,"lcov.info"))
.then(function(percentageArg){
if (percentageArg >= configArg.coverageTreshold){
plugins.beautylog.ok(
"your coverage of " + percentageArg + "% " + "is within your treshold of " +
configArg.coverageTreshold + "%"
);
} else {
plugins.beautylog.warn(
"your coverage of " + percentageArg + "% " + "fails your treshold of " +
configArg.coverageTreshold + "%"
);
plugins.beautylog.error("exiting due to coverage failure");
process.exit(1);
}
done.resolve(configArg);
});
return done.promise;
};
export let run = function(configArg) {
let done = plugins.Q.defer();
let config = configArg;
plugins.beautylog.log("now starting tests"); plugins.beautylog.log("now starting tests");
console.log( console.log(
@ -44,11 +79,10 @@ export var run = function(configArg) {
"***************************\n" + "***************************\n" +
"--------------------------------------------------------------" "--------------------------------------------------------------"
); );
istanbul().on("finish",function(){
mocha().on("finish",function(){ istanbul(config)
plugins.beautylog.ok("Tests have passed!"); .then(mocha)
done.resolve(config); .then(coverage)
}) .then(done.resolve);
});
return done.promise; return done.promise;
}; };

View File

@ -1,7 +1,8 @@
{ {
"ambientDependencies": { "ambientDependencies": {
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d", "colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
"istanbul": "registry:dt/istanbul#0.4.0+20160316155526",
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777" "vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
} }
} }