Permalink
Browse files

Merge pull request #531 from koenbok/feature/code-coverage

Feature/code coverage
  • Loading branch information...
nvh committed Jul 14, 2017
2 parents 026c816 + baba33d commit 60674ee5eb7b34eb19fd6dfe5b0f3a7ae036d4bd
View
@@ -74,3 +74,13 @@ site-upload: bootstrap site-build
resources:
scripts/resources-optimize.sh
# Code coverage
coverage: bootstrap
$(BIN)/gulp version
mkdir -p ./build/build
$(BIN)/coffeeCoverage -t istanbul -c __coverage__ ./build/Version.coffee ./build/build/Version.js
$(BIN)/coffeeCoverage -t istanbul -c __coverage__ ./framer ./build/instrumented
$(BIN)/gulp coverage
View
@@ -0,0 +1,7 @@
coverage:
precision: 1
range: 40..95
codecov:
branch: master
strict_yaml_branch: master
View
@@ -2,6 +2,7 @@ _ = require("lodash")
async = require("async")
gulp = require("gulp")
phantomjs = require("gulp-mocha-phantomjs")
istanbulReport = require('gulp-istanbul-report')
webpack = require("webpack")
rename = require("gulp-rename")
template = require("gulp-template")
@@ -34,10 +35,11 @@ gulp.task "test", ["webpack:tests", "lint"], ->
return gulp
.src("test/phantomjs/index.html")
.pipe(phantomjs({
reporter: "dot",
viewportSize: {width: 1024, height: 768},
useColors: true,
loadImages: false
reporter: "dot"
phantomjs:
# viewportSize: {width: 1024, height: 768}
useColors: true
loadImages: false
}))
gulp.task 'lint', ->
@@ -109,6 +111,45 @@ gulp.task "webpack:tests", ["webpack:debug"], (callback) ->
webpackDev("webpack:tests", config, callback)
gulp.task "webpack:coverage", ["version"], (callback) ->
config = _.extend WEBPACK,
entry: "./build/instrumented/Framer.js"
output:
filename: "build/framer.debug.js"
debug: true
webpackDev("webpack:coverage", config, callback)
gulp.task "coverage", ["version", "webpack:coverage", "webpack:tests"], ->
coverageFile = "build/coverage/coverage.json"
return gulp
.src("test/phantomjs/index.html")
.pipe(phantomjs(
phantomjs:
hooks: "mocha-phantomjs-istanbul"
coverageFile: coverageFile
# viewportSize: {width: 1024, height: 768}
useColors: true
loadImages: false
reporter: "dot"
))
.on "finish", ->
gulp.src(coverageFile)
.pipe(istanbulReport(
reporterOpts:
dir: './build/coverage'
reporters: [
'text',
{'name': 'lcov', file: 'lcov.info'},
{'name': 'json', file: 'coverage-final.json'},
{'name': 'clover', file: 'clover.xml'},
]
))
console.log "done"
################################################################################
# Utilities
View
@@ -18,13 +18,15 @@
"async": "^2.0.1",
"bower": "^1.3.12",
"chai": "^3.5.0",
"coffee-coverage": "^1.0.1",
"codecov": "^2.2.0",
"coffee-coverage": "^2.0.1",
"coffee-loader": "^0.7.2",
"coffee-script": "^1.9.1",
"eventemitter3": "^1.1.1",
"gulp": "^3.8.11",
"gulp-coffeelint": "^0.6.0",
"gulp-mocha-phantomjs": "^0.11.0",
"gulp-istanbul-report": "0.0.1",
"gulp-mocha-phantomjs": "^0.12.1",
"gulp-plumber": "^1.0.1",
"gulp-rename": "^1.2.2",
"gulp-template": "^4.0.0",
@@ -35,6 +37,7 @@
"mime": "^1.3.4",
"mocha": "^3.0.0",
"mocha-phantomjs": "^4.0.1",
"mocha-phantomjs-istanbul": "0.0.2",
"mustache": "^2.0.0",
"simulate": "^0.0.5",
"webpack": "^1.7.3",
@@ -1,40 +0,0 @@
# This is required to be a module in order for the Mocha-PhantomJS
# Gulp task to be able to invoke it as a hook.
#
# When PhantomJS is finished, but before it has closed the headless
# browser window, the "collectCoverage" routine will be invoked. It
# saves the coverage data to a .json file.
#
# Inspired by https://github.com/willembult/mocha-phantomjs-istanbul
fs = require "fs"
collectCoverage = (page) ->
console.log "collecting..."
coverage = page.evaluate (() ->
# Collect the main coverage object from the browser:
data = window._$jscoverage
# The object has natural numbers for field names. This makes
# JS think it is an array on transforming it to JSON, foregoing
# the 'source' field that's also present. Fix this by putting the
# array in a "coverage" field, and keeping "source". This is also
# how the coverage reporter expects the JSON to be formatted:
for field of data
file = data[field] =
coverage: data[field]
source: data[field].source
delete file.coverage.source
return JSON.stringify data, " "
)
# Save the date to file:
fs.write "build/coverage/jscoverage.json", coverage
module.exports =
afterEnd: (runner) ->
collectCoverage(runner.page)
@@ -1,9 +0,0 @@
{
"name": "coverage-capture",
"version": "1.0.0",
"description": "A module that captures coverage data from PhantomJS and saves it to build/coverage/jscoverage.json",
"main": "index.coffee",
"author": "Motif",
"repository": "local",
"private": true
}
@@ -1 +0,0 @@
A module that captures coverage data from PhantomJS and saves it to build/coverage/jscoverage.json
@@ -1,38 +0,0 @@
/*
jscoverage-highlight.css - JSCoverage syntax highlighting style sheet
Copyright (C) 2008, 2009, 2010 siliconforks.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* keyword, type, symbol, cbracket */
#sourceTable .k {
font-weight: bold;
}
/* string, regexp, number */
#sourceTable .s {
color: #006400;
}
/* specialchar */
#sourceTable .t {
color: #2e8b57;
}
/* comment */
#sourceTable .c {
font-style: italic;
}
@@ -1,108 +0,0 @@
/*
jscoverage-ie.css - JSCoverage style sheet for Internet Explorer
Copyright (C) 2007, 2008, 2009, 2010 siliconforks.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#headingDiv {
position: static;
margin-left: 10px;
margin-right: 10px;
padding-top: 0.5em;
}
#tabs {
clear: all;
position: static;
top: auto;
left: auto;
right: auto;
height: auto;
margin-left: 10px;
margin-right: 10px;
}
#tabs div {
position: relative;
height: auto;
line-height: normal;
padding-top: 5px;
padding-bottom: 5px;
}
#tabs div.selected {
padding-bottom: 6px;
z-index: 2;
}
.TabPage {
position: relative;
top: -1px;
left: auto;
right: auto;
bottom: auto;
clear: left;
margin-left: 10px;
margin-right: 10px;
padding: 10px;
z-index: 1;
}
#locationDiv {
margin-bottom: 10px;
}
#iframeDiv {
position: static;
width: 100%;
}
#summaryDiv {
position: static;
width: 100%;
}
#fileDiv {
margin-bottom: 10px;
}
#sourceDiv {
position: static;
width: 100%;
}
#storeDiv {
position: static;
width: 100%;
}
/* some defaults */
.TabPage {
height: 650px;
}
#iframeDiv {
height: 600px;
}
#summaryDiv {
height: 600px;
}
#sourceDiv {
height: 600px;
}
Binary file not shown.
Oops, something went wrong.

0 comments on commit 60674ee

Please sign in to comment.