coffee-coverage
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -10,3 +10,3 @@ Running with [JSCoverage](http://siliconforks.com/jscoverage/) | ||
* [Writing a Custom Loader](#writing-a-custom-loader) | ||
* [Precomiled Source](#precompiled-source) | ||
* [Precompiled Source](#precompiled-source) | ||
* [Some Weirdness with Line Numbers](#some-weirdness-with-line-numbers) | ||
@@ -20,7 +20,9 @@ | ||
npm install --save-dev coffee-coverage | ||
mocha --recursive \ | ||
--require coffee-coverage/register \ | ||
--reporter html-cov \ | ||
test > coverage.html | ||
```sh | ||
$ npm install --save-dev coffee-coverage | ||
$ mocha --recursive \ | ||
--require coffee-coverage/register \ | ||
--reporter html-cov \ | ||
test > coverage.html | ||
``` | ||
@@ -51,5 +53,7 @@ This will run your unit tests, instrument them with JSCoverge style instrumentation, and write | ||
"scripts": { | ||
"coverage": "mocha --require coffee-coverage/register --reporter html-cov > coverage.html" | ||
} | ||
```json | ||
"scripts": { | ||
"coverage": "mocha --require coffee-coverage/register --reporter html-cov > coverage.html" | ||
} | ||
``` | ||
@@ -64,22 +68,26 @@ now you can run `npm run coverage` to run your tests and generate a coverage report. | ||
require('coffee-coverage').register({ | ||
instrumentor: 'jscoverage', | ||
basePath: process.cwd(), | ||
path: 'relative' | ||
exclude: ['/test', '/node_modules', '/.git'], | ||
coverageVar: '_$jscoverage', | ||
initAll: true | ||
}); | ||
```js | ||
require('coffee-coverage').register({ | ||
instrumentor: 'jscoverage', | ||
basePath: process.cwd(), | ||
path: 'relative' | ||
exclude: ['/test', '/node_modules', '/.git'], | ||
coverageVar: '_$jscoverage', | ||
initAll: true | ||
}); | ||
``` | ||
Then when you run mocha, use `--require ./coffee-coverage-loader.js`. | ||
Precomiled Source | ||
================= | ||
Precompiled Source | ||
================== | ||
Alternatively, you can use coffeeCoverage to statically compile your code with instrumentation: | ||
# Compile everything except the test directory with coffeeCoverage | ||
coffeeCoverage --initfile ./lib/init.js --exclude test --path abbr ./src ./lib | ||
# Compile the test directory with regular coffeescript | ||
coffee -o ./lib/test ./src/test | ||
```sh | ||
# Compile everything except the test directory with coffeeCoverage | ||
$ coffeecoverage --initfile ./lib/init.js --exclude test --path abbr ./src ./lib | ||
# Compile the test directory with regular coffeescript | ||
$ coffee -o ./lib/test ./src/test | ||
``` | ||
@@ -91,3 +99,5 @@ This also writes an "lib/init.js" which initializes all the execution counts to 0. This is handy, | ||
mocha --require ./lib/init.js --reporter html-cov ./lib/test/* | ||
```sh | ||
$ mocha --require ./lib/init.js --reporter html-cov ./lib/test/* | ||
``` | ||
@@ -99,12 +109,16 @@ Some Weirdness with Line Numbers | ||
if x then y() \ | ||
else z() | ||
```coffeescript | ||
if x then y() \ | ||
else z() | ||
``` | ||
gets compile to this snippet of JavaScript: | ||
if (x) { | ||
y(); | ||
} else { | ||
z(); | ||
} | ||
```js | ||
if (x) { | ||
y(); | ||
} else { | ||
z(); | ||
} | ||
``` | ||
@@ -122,25 +136,31 @@ We have three statements we could instrument here; the "if" itself, the call to y, and the call to z. | ||
if x | ||
a() | ||
else if y | ||
b() | ||
```coffeescript | ||
if x | ||
a() | ||
else if y | ||
b() | ||
```` | ||
Would normally compile to: | ||
if(x) { | ||
a(); | ||
} else if(y) { | ||
b(); | ||
} | ||
```js | ||
if(x) { | ||
a(); | ||
} else if(y) { | ||
b(); | ||
} | ||
``` | ||
coffeeCoverage will instead compile this to: | ||
if(x) { | ||
a(); | ||
} else { | ||
if(y) { | ||
b(); | ||
} | ||
} | ||
```js | ||
if(x) { | ||
a(); | ||
} else { | ||
if(y) { | ||
b(); | ||
} | ||
} | ||
``` | ||
because otherwise it would be unable to instrument the `if(y)` statement. |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.2 | ||
// Generated by CoffeeScript 2.3.2 | ||
(function() { | ||
@@ -331,3 +331,3 @@ //### CoffeeCoverage | ||
})(); | ||
}).call(this); | ||
@@ -385,3 +385,3 @@ // Runs an instrumentor on some source code. | ||
results = []; | ||
for (i = j = 0, ref4 = nodeWrapper.depth; 0 <= ref4 ? j < ref4 : j > ref4; i = 0 <= ref4 ? ++j : --j) { | ||
for (i = j = 0, ref4 = nodeWrapper.depth; (0 <= ref4 ? j < ref4 : j > ref4); i = 0 <= ref4 ? ++j : --j) { | ||
results.push(" "); | ||
@@ -388,0 +388,0 @@ } |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.2 | ||
// Generated by CoffeeScript 2.3.2 | ||
(function() { | ||
@@ -3,0 +3,0 @@ //!/usr/bin/env coffee |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.2 | ||
// Generated by CoffeeScript 2.3.2 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var CompiledCache, EXTENSIONS, _, fs, getRelativeFilename, mkdirs, path; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.2 | ||
// Generated by CoffeeScript 2.3.2 | ||
(function() { | ||
@@ -3,0 +3,0 @@ // Extensions we know how to process. |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.2 | ||
// Generated by CoffeeScript 2.3.2 | ||
(function() { | ||
@@ -3,0 +3,0 @@ exports.register = require('./register'); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.2 | ||
// Generated by CoffeeScript 2.3.2 | ||
(function() { | ||
@@ -477,3 +477,3 @@ // This is an instrumentor which provides [Istanbul](https://github.com/gotwarlost/istanbul) style | ||
results = []; | ||
for (i = 0, ref = branch.locations.length; 0 <= ref ? i < ref : i > ref; 0 <= ref ? i++ : i--) { | ||
for (i = 0, ref = branch.locations.length; (0 <= ref ? i < ref : i > ref); 0 <= ref ? i++ : i--) { | ||
results.push(0); | ||
@@ -480,0 +480,0 @@ } |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.2 | ||
// Generated by CoffeeScript 2.3.2 | ||
(function() { | ||
@@ -3,0 +3,0 @@ // This is an instrumentor which provides [JSCoverage](http://siliconforks.com/jscoverage/) style |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.2 | ||
// Generated by CoffeeScript 2.3.2 | ||
(function() { | ||
@@ -236,3 +236,4 @@ var NodeWrapper, _, assert, coffeeScript, compile, forNodeAndChildren; | ||
compiled = coffeeScript.nodes(csSource); | ||
line = node.locationData.first_line; | ||
// In latest coffee-script, some blocks do not have locationData? | ||
line = !node.locationData ? 0 : line = node.locationData.first_line; | ||
forNodeAndChildren(compiled, function(n) { | ||
@@ -239,0 +240,0 @@ // Fix up location data for each instrumented line. Make these all 0-length, |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.2 | ||
// Generated by CoffeeScript 2.3.2 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var CompiledCache, StringStream, _, coffeeCoverage, excludeFile, fs, getRelativeFilename, mkdirs, path; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.2 | ||
// Generated by CoffeeScript 2.3.2 | ||
(function() { | ||
@@ -3,0 +3,0 @@ // Visitor which looks for pragma directives for skipping coverage, and marks coffeescript nodes |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.2 | ||
// Generated by CoffeeScript 2.3.2 | ||
(function() { | ||
@@ -3,0 +3,0 @@ // Takes the contents of a file and returns an array of lines. |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.2 | ||
// Generated by CoffeeScript 2.3.2 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var EXTENSIONS, _, assert, fs, minimatch, path, statFile, |
@@ -15,3 +15,3 @@ { | ||
], | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"author": "Benbria (http://www.benbria.com/)", | ||
@@ -49,11 +49,13 @@ "contributors": [ | ||
"devDependencies": { | ||
"@benbria/semantic-release-config": "^1.0.0", | ||
"benchmark": "^2.0.0", | ||
"chai": "^3.0.0", | ||
"coveralls": "^2.11.2", | ||
"coveralls": "^3.0.2", | ||
"istanbul": "^0.4.4", | ||
"mocha": "^3.2.0", | ||
"mocha": "^5.2.0", | ||
"semantic-release": "^15.12.5", | ||
"sinon": "^1.14.1" | ||
}, | ||
"scripts": { | ||
"prepublish": "npm run build && mocha", | ||
"prepare": "npm run build", | ||
"test": "npm run build && mocha && istanbul report", | ||
@@ -63,4 +65,5 @@ "coverage-report": "istanbul report text-summary lcov", | ||
"clean": "rm -rf lib coverage", | ||
"distclean": "npm run clean && rm -rf node_modules" | ||
"distclean": "npm run clean && rm -rf node_modules", | ||
"semantic-release": "semantic-release" | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) | ||
Istanbul and JSCoverage-style instrumentation for CoffeeScript files. | ||
@@ -2,0 +4,0 @@ |
Sorry, the diff of this file is not supported yet
129804
2024
69
8