The `--preload-sources` option is now deprecated and superseded by the
`--include-all-sources` option instead. This provides a better coverage representation
of the code that has not been included for testing.
v0.3.4
Merge #219 - Support reporting within symlink/junction. Thanks to @dougwilson
v0.3.3
Merge #268 - per file coverage enforcement. Thanks to @ryan-roemer
v0.3.2
Republish 0.3.1 because of bad shasum
v0.3.1
Fixes #249
v0.3.0
The *reports* release. **Potentially backwards-incompatible** if you are using
undocumented features or custom report implementations.
Change report command line to support multiple reports, add back-compat processing with warnings
Enable `report` command to read report list from config, thanks to @piuccio
Support multiple reports for `cover` and `report` commands
Support per-report config options in configuration file
Turn reports into event emitters so they can signal `done`
Add `Reporter` class to be able to generate multiple reports
Add a bunch of API docs, refactor README
v0.2.16
Make YUI links https-always since relative links break local
filesystem use-case
v0.2.15
make link protocols relative so they don't break on https connections
(thanks to @yasyf)
v0.2.14
Fix hook to deal with non-string/ missing filenames
(thanks to @jason0x43), update dependencies
v0.2.13
Add `--preload-sources` option to `cover` command to make
code not required by tests to appear in the coverage report.
v0.2.12
Text summary as valid markdown, thanks to @smikes
v0.2.11
Allow source map generation, thanks to @jason0x43
v0.2.10
Add flag to handle sigints and dump coverage, thanks to @samccone
v0.2.9
Fix #202
v0.2.8
Upgrade esprima
v0.2.7
Upgrade esprima
Misc jshint fixes
v0.2.6
Revert bad commit for tree summarizer
v0.2.5
Add clover report, thanks to @bixdeng, @mpderbec
Fix cobertura report bug for relative paths, thanks to @jxiaodev
Run self-coverage on tests always
Fix tree summarizer when relative paths are involved, thanks to @Swatinem
v0.2.4
Fix line-split algo to handle Mac lin separators, thanks to @asifrc
Update README for quick intro to ignoring code for coverage, thanks to @gergelyke
v0.2.3
Add YAML config file. `istanbul help config` has more details
Support custom reporting thresholds using the `watermarks` section of the config file
v0.2.2
update escodegen, handlebars and resolve dependency versions
v0.2.1
Add ability to skip branches and other hard-to-test code using comments.
See the doc for more details
Turn `util.error` into `console.error` for node 0.11 compatibility, thanks to @pornel
v0.2.0
Add --preserve-comments to instrumenter options, thanks to @arikon
Support 'use strict;' in file scope, thanks to @pornel
Up minor version due to the new way in which the global object is accessed.
This _should_ be backwards-compatible but has not been tested in the wild.
v0.1.46
Fix #114
v0.1.45
Add teamcity reporter, thanks to @chrisgladd
v0.1.44
Fix inconsistency in processing empty switch with latest esprima, up deps
v0.1.43
Add colors to text report thanks to @runk
v0.1.42
fix #78: embed source regression introduced in v0.1.38. Fix broken test for this
v0.1.41
add json report to dump coverage object for certain use cases
v0.1.40
forward sourceStore from lcov to html report, pull request by @vojtajina
v0.1.39
add tag to cobertura report, pull request by @jhansche
v0.1.38
factor out AST instrumentation into own instrumentASTSync method
always set function declaration coverage stats to 1 since every such declaration is "executed" exactly one time by the compiler
v0.1.37
--complete-copy flag contrib from @kami, correct strict mode semantics for instrumented functions
v0.1.36
real quiet when --print=none specified, add repo URL to package.json, add contributors
v0.1.35
accept cobertura contrib from @nbrownus, fix #52
v0.1.34
fix async reporting, update dependencies, accept html cleanup contrib from @mathiasbynens
v0.1.33
initialize global coverage object before running tests to workaround mocha leak detection
v0.1.32
Fix for null nodes in array expressions, add @unindented as contributor
v0.1.31
Misc internal fixes and test changes
v0.1.30
Write standard blurbs ("writing coverage object..." etc.) to stderr rather than stdout
v0.1.29
Allow --post-require-hook to be a module that can be `require`-d
v0.1.28
Add --post-require-hook switch to support use-cases similar to the YUI loader
v0.1.27
Add --hook-run-in-context switch to support RequireJS modules. Thanks to @millermedeiros for the pull request
v0.1.26
Add support for minimum uncovered unit for check-coverage. Fixes #25
v0.1.25
Allow for relative paths in the YUI loader hook
v0.1.24
Add lcov summaries. Fixes issue #20
v0.1.23
Add ability to save a baseline coverage file for the instrument command. Fixes issue #19
v0.1.22
Add signature attribute to cobertura method tags to fix NPE by the Hudson publisher
v0.1.21
Add cobertura XML report format; exprimental for now
v0.1.20
Fix HTML/ lcov report interface to be more customizable for middleware needs
v0.1.19
make all hooking non-destructive in that already loaded modules are never reloaded. Add self-test mode so that already loaded istanbul modules can be unloaded prior to hooking.
v0.1.18
Add option to hook in non-destructive mode; i.e. the require cache is not unloaded when hooking
v0.1.17
Export some more objects; undocumented for now
v0.1.16
Fix npm keywords for istanbul which expects an array of strings but was being fed a single string with keywords instead
v0.1.15
Add the 'check-coverage' command so that Istanbul can be used as a posttest script to enforce minimum coverage
v0.1.14
Expose the experimental YUI load hook in the interface
v0.1.13
Internal jshint cleanup, no features or fixes
v0.1.12
Give npm the README that was getting inadvertently excluded
v0.1.11
Merge pull request #14 for HTML tweaks. Thanks @davglass. Add @davglass and @nowamasa as contributors in `package.json`
v0.1.10
Fix to issue #12. Do not install `uncaughtException` handler and pass input error back to CLI using a callback as opposed to throwing.
v0.1.9
Attempt to create reporting directory again just before writing coverage in addition to initial creation
v0.1.8
Fix issue #11.
v0.1.7
Add text summary and detailed reporting available as --print [summary|detail|both|none]. summary is the default if nothing specified.
v0.1.6
Handle backslashes in the file path correctly in emitted code. Fixes #9. Thanks to @nowamasa for bug report and fix
v0.1.5
make object-utils.js work on a browser as-is
v0.1.4
partial fix for issue #4; add titles to missing coverage spans, remove negative margin for missing if/else indicators
v0.1.3
Set the environment variable running_under_istanbul to 1 when that is the case. This allows test runners that use istanbul as a library to back off on using it when set.
v0.1.2
HTML reporting cosmetics. Reports now show syntax-colored JS using `prettify`. Summary tables no longer wrap in awkward places.
v0.1.1
Fixes issue #1. HTML reports use sources embedded inside the file coverage objects if found rather than reading from the filesystem
v0.1.0
Initial version
istanbul-0.4.5/LICENSE 0000664 0000000 0000000 00000002713 12756403262 0014360 0 ustar 00root root 0000000 0000000 Copyright 2012 Yahoo! Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Yahoo! Inc. nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL YAHOO! INC. BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
istanbul-0.4.5/README.md 0000664 0000000 0000000 00000026553 12756403262 0014642 0 ustar 00root root 0000000 0000000 ## Istanbul - a JS code coverage tool written in JS
[](http://travis-ci.org/gotwarlost/istanbul)
[](https://gemnasium.com/gotwarlost/istanbul)
[](https://coveralls.io/r/gotwarlost/istanbul?branch=master)
[](https://www.bithound.io/github/gotwarlost/istanbul)
[](https://nodei.co/npm/istanbul/)
**New** `v0.4.0` now has beautiful HTML reports. Props to Tom MacWright @tmcw for a fantastic job!
* [Features and use cases](#features)
* [Getting started and configuration](#getting-started)
* [Usage on Windows](#usage-on-windows)
* [The command line](#the-command-line)
* [Ignoring code for coverage](#ignoring-code-for-coverage)
* [API](#api)
* [Changelog](https://github.com/gotwarlost/istanbul/blob/master/CHANGELOG.md)
* [License and credits](#license)
### Features
* All-javascript instrumentation library that tracks **statement, branch,
and function coverage**.
* **Module loader hooks** to instrument code on the fly
* **Command line tools** to run node unit tests "with coverage turned on" and no cooperation
whatsoever from the test runner
* Multiple report formats: **HTML**, **LCOV**, **Cobertura** and more.
* Ability to use as [middleware](https://github.com/gotwarlost/istanbul-middleware) when serving JS files that need to be tested on the browser.
* Can be used on the **command line** as well as a **library**
* Based on the awesome `esprima` parser and the equally awesome `escodegen` code generator
* Well-tested on node (prev, current and next versions) and the browser (instrumentation library only)
### Use cases
Supports the following use cases and more
* transparent coverage of nodejs unit tests
* instrumentation/ reporting of files in batch mode for browser tests
* Server side code coverage for nodejs by embedding it as [custom middleware](https://github.com/gotwarlost/istanbul-middleware)
### Getting started
$ npm install -g istanbul
The best way to see it in action is to run node unit tests. Say you have a test
script `test.js` that runs all tests for your node project without coverage.
Simply:
$ cd /path/to/your/source/root
$ istanbul cover test.js
and this should produce a `coverage.json`, `lcov.info` and `lcov-report/*html` under `./coverage`
Sample of code coverage reports produced by this tool (for this tool!):
[HTML reports](http://gotwarlost.github.com/istanbul/public/coverage/lcov-report/index.html)
### Usage on Windows
Istanbul assumes that the `command` passed to it is a JS file (e.g. Jasmine, vows etc.),
this is however not true on Windows where npm wrap bin files in a `.cmd` file.
Since Istanbul can not parse `.cmd` files you need to reference the bin file manually.
Here is an example using Jasmine 2:
istanbul cover node_modules\jasmine\bin\jasmine.js
In order to use this cross platform (e.i. Linux, Mac and Windows), you can insert
the above line into the script object in your package.json file but with normal
slash.
"scripts": {
"test": "istanbul cover node_modules/jasmine/bin/jasmine.js"
}
### Configuring
Drop a `.istanbul.yml` file at the top of the source tree to configure istanbul.
`istanbul help config` tells you more about the config file format.
### The command line
$ istanbul help
gives you detailed help on all commands.
```
Usage: istanbul help config |
`config` provides help with istanbul configuration
Available commands are:
check-coverage
checks overall/per-file coverage against thresholds from coverage
JSON files. Exits 1 if thresholds are not met, 0 otherwise
cover transparently adds coverage information to a node command. Saves
coverage.json and reports at the end of execution
help shows help
instrument
instruments a file or a directory tree and writes the
instrumented code to the desired output location
report writes reports for coverage JSON objects produced in a previous
run
test cover a node command only when npm_config_coverage is set. Use in
an `npm test` script for conditional coverage
Command names can be abbreviated as long as the abbreviation is unambiguous
```
To get detailed help for a command and what command-line options it supports, run:
istanbul help
(Most of the command line options are not covered in this document.)
#### The `cover` command
$ istanbul cover my-test-script.js -- my test args
# note the -- between the command name and the arguments to be passed
The `cover` command can be used to get a coverage object and reports for any arbitrary
node script. By default, coverage information is written under `./coverage` - this
can be changed using command-line options.
The `cover` command can also be passed an optional `--handle-sigint` flag to
enable writing reports when a user triggers a manual SIGINT of the process that is
being covered. This can be useful when you are generating coverage for a long lived process.
#### The `test` command
The `test` command has almost the same behavior as the `cover` command, except that
it skips coverage unless the `npm_config_coverage` environment variable is set.
**This command is deprecated** since the latest versions of npm do not seem to
set the `npm_config_coverage` variable.
#### The `instrument` command
Instruments a single JS file or an entire directory tree and produces an output
directory tree with instrumented code. This should not be required for running node
unit tests but is useful for tests to be run on the browser.
#### The `report` command
Writes reports using `coverage*.json` files as the source of coverage information.
Reports are available in multiple formats and can be individually configured
using the istanbul config file. See `istanbul help report` for more details.
#### The `check-coverage` command
Checks the coverage of statements, functions, branches, and lines against the
provided thresholds. Positive thresholds are taken to be the minimum percentage
required and negative numbers are taken to be the number of uncovered entities
allowed.
### Ignoring code for coverage
* Skip an `if` or `else` path with `/* istanbul ignore if */` or `/* istanbul ignore else */` respectively.
* For all other cases, skip the next 'thing' in the source with: `/* istanbul ignore next */`
See [ignoring-code-for-coverage.md](ignoring-code-for-coverage.md) for the spec.
### API
All the features of istanbul can be accessed as a library.
#### Instrument code
```javascript
var istanbul = require('istanbul');
var instrumenter = new istanbul.Instrumenter();
var generatedCode = instrumenter.instrumentSync('function meaningOfLife() { return 42; }',
'filename.js');
```
#### Generate reports given a bunch of coverage JSON objects
```javascript
var istanbul = require('istanbul'),
collector = new istanbul.Collector(),
reporter = new istanbul.Reporter(),
sync = false;
collector.add(obj1);
collector.add(obj2); //etc.
reporter.add('text');
reporter.addAll([ 'lcov', 'clover' ]);
reporter.write(collector, sync, function () {
console.log('All reports generated');
});
```
For the gory details consult the [public API](http://gotwarlost.github.com/istanbul/public/apidocs/index.html)
### Multiple Process Usage
Istanbul can be used in a multiple process environment by running each process
with Istanbul, writing a unique coverage file for each process, and combining
the results when generating reports. The method used to perform this will
depend on the process forking API used. For example when using the
[cluster module](http://nodejs.org/api/cluster.html) you must setup the master
to start child processes with Istanbul coverage, disable reporting, and output
coverage files that include the PID in the filename. Before each run you may
need to clear out the coverage data directory.
```javascript
if(cluster.isMaster) {
// setup cluster if running with istanbul coverage
if(process.env.running_under_istanbul) {
// use coverage for forked process
// disabled reporting and output for child process
// enable pid in child process coverage filename
cluster.setupMaster({
exec: './node_modules/.bin/istanbul',
args: [
'cover', '--report', 'none', '--print', 'none', '--include-pid',
process.argv[1], '--'].concat(process.argv.slice(2))
});
}
// ...
// ... cluster.fork();
// ...
} else {
// ... worker code
}
```
### Coverage.json
For details on the format of the coverage.json object, [see here](./coverage.json.md).
### License
istanbul is licensed under the [BSD License](http://github.com/gotwarlost/istanbul/raw/master/LICENSE).
### Third-party libraries
The following third-party libraries are used by this module:
* abbrev: https://github.com/isaacs/abbrev-js - to handle command abbreviations
* async: https://github.com/caolan/async - for parallel instrumentation of files
* escodegen: https://github.com/Constellation/escodegen - for JS code generation
* esprima: https://github.com/ariya/esprima - for JS parsing
* glob: https://github.com/isaacs/node-glob - for loading and matching path expressions
* handlebars: https://github.com/wycats/handlebars.js/ - for report template expansion
* js-yaml: https://github.com/nodeca/js-yaml - for YAML config file load
* mkdirp: https://github.com/substack/node-mkdirp - to create output directories
* nodeunit: https://github.com/caolan/nodeunit - dev dependency for unit tests
* nopt: https://github.com/isaacs/nopt - for option parsing
* once: https://github.com/isaacs/once - to ensure callbacks are called once
* resolve: https://github.com/substack/node-resolve - for resolving a post-require hook module name into its main file.
* rimraf - https://github.com/isaacs/rimraf - dev dependency for unit tests
* which: https://github.com/isaacs/node-which - to resolve a node command to a file for the `cover` command
* wordwrap: https://github.com/substack/node-wordwrap - for prettier help
* prettify: http://code.google.com/p/google-code-prettify/ - for syntax colored HTML reports. Files checked in under `lib/vendor/`
### Inspired by
* YUI test coverage - https://github.com/yui/yuitest - the grand-daddy of JS coverage tools. Istanbul has been specifically designed to offer an alternative to this library with an easy migration path.
* cover: https://github.com/itay/node-cover - the inspiration for the `cover` command, modeled after the `run` command in that tool. The coverage methodology used by istanbul is quite different, however
### Shout out to
* [mfncooper](https://github.com/mfncooper) - for great brainstorming discussions
* [reid](https://github.com/reid), [davglass](https://github.com/davglass), the YUI dudes, for interesting conversations, encouragement, support and gentle pressure to get it done :)
### Why the funky name?
Since all the good ones are taken. Comes from the loose association of ideas across
coverage, carpet-area coverage, the country that makes good carpets and so on...
istanbul-0.4.5/coverage.json.md 0000664 0000000 0000000 00000005723 12756403262 0016444 0 ustar 00root root 0000000 0000000 # Format of coverage.json
`coverage.json` contains a report object, which is a hash where keys are file names (absolute
paths), and values are coverage data for that file (the result of
`json.stringify(collector.fileCoverageFor(filename))`) Each entry consists of:
* `path` - The path to the file. This is an absolute path, and should be the same as the
key in the report object.
* `s` - Hash of statement counts, where keys as statement IDs.
* `b` - Hash of branch counts, where keys are branch IDs and values are arrays of counts.
For an if statement, the value would have two counts; one for the if, and one for the
else. Switch statements would have an array of values for each case.
* `f` - Hash of function counts, where keys are function IDs.
* `fnMap` - Hash of functions where keys are function IDs, and values are `{name, line, loc, skip}`,
where `name` is the name of the function, `line` is the line the function is declared on,
and `loc` is the `Location` of the function declaration (just the declaration, not the entire
function body - see 'Location Objects' below.) If `skip` is present and true, then this
indicates that this function was ignored by a `### instabul ignore ... ###` pragma. Note that
if a function is not ignored the `skip` field will be missing entirely.
* `statementMap` - Hash where keys are statement IDs, and values are `Location` objects for each
statement. The `Location` for a function definition is really an assignment, and should
include the entire function. In addition to the normal location object fields, a
`statementMap` entry can also have an optional `skip` field.
* `branchMap` - Hash where keys are branch IDs, and values are `{line, type, locations}` objects.
`line` is the line the branch starts on. `type` is the type of the branch (e.g. "if", "switch").
`locations` is an array of `Location` objects, one for each possible outcome of the branch.
Note for an `if` statement where there is no `else` clause, there will still be two `locations`
generated. Istanbul does *not* generate coverage for the `default` case of a switch statement
if `default` is not explicitly present in the source code.
* `l` - Hash of line counts, where keys are the line number.
`locations` for an if statement are always 0-length and located at the start of the `if` (even
the location for the "else"). For a `switch` statement, `locations` start at the start of the
`case` statement and go to the end of the line before the next case statement (note Istanbul
does nothing clever here if a `case` is missing a `break`.) Each location in `locations` can
also optionally have a `skip: true` field to indicate that this branch was ignored.
IDs used in the fnMap, statementMap, and branchMap are sequential integers, starting at 1.
## Location Objects
Location objects are a `{start: {line, column}, end: {line, column}}` object that describes
the start and end of a piece of code. Note that `line` is 1-based, but `column` is 0-based.
istanbul-0.4.5/download-escodegen-browser.sh 0000775 0000000 0000000 00000001144 12756403262 0021131 0 ustar 00root root 0000000 0000000 #!/bin/sh
ESCG_DIR=node_modules/escodegen
ESCG_VERSION=`grep '"version"' ${ESCG_DIR}/package.json | awk '{print $2}' | sed 's/[",]//g'`
OUT_FILE=${ESCG_DIR}/escodegen.browser.min.js
if [ ! -f ${OUT_FILE} ]
then
set -v
rm -rf __escodegen_clone__
git clone --branch ${ESCG_VERSION} https://github.com/estools/escodegen.git __escodegen_clone__
cd __escodegen_clone__
# Temporarily ignore missing package, see #489
perl -i -ne '/esprima\-moz/ or print' package.json
npm i && npm run build-min
mv escodegen.browser.min.js ../${OUT_FILE}
cd -
rm -rf __escodegen_clone__
fi
istanbul-0.4.5/generate-pages.sh 0000775 0000000 0000000 00000000325 12756403262 0016576 0 ustar 00root root 0000000 0000000 set -ex
export PAGES_DIR=../istanbul-pages
npm test --coverage
mkdir -p public/apidocs
yuidoc .
rsync -rvt ./public/apidocs/ ${PAGES_DIR}/public/apidocs/
rsync -rvt ./build/coverage/ ${PAGES_DIR}/public/coverage
istanbul-0.4.5/ignoring-code-for-coverage.md 0000664 0000000 0000000 00000010533 12756403262 0020775 0 ustar 00root root 0000000 0000000 ## Ignoring code for coverage purposes
Some branches in JS code are typically hard, if not impossible to test.
Examples are a `hasOwnProperty` check, [UMD wrappers](https://github.com/umdjs/umd) and so on. Istanbul now has a
facility by which coverage can be excluded for certain sections of code.
### The interface
1. Coverage can be explicitly skipped using comments. There is no automatic pattern match of expressions to determine
if they should be skipped for coverage.
2. A coverage skip hint looks like `/* istanbul ignore [non-word] [optional-docs] */`
3. For `if` conditions you can say `/* istanbul ignore if */` or `/* istanbul ignore else */` and that will end up
ignoring whichever path was required to be ignored.
4. For all other cases, the Swiss army knife `/* istanbul ignore next */` may be used which skips the "next thing" in
the source code
5. The "next" thing may be, among other things:
* A JS statement (including assignments, ifs, loops, switches, functions) in which case all of the statement is
ignored for all forms of coverage.
* A switch case statement, in which case the particular case is ignored for branch coverage and its contents ignored
for all forms
* A conditional inside a ternary expression in which case the branch is ignored
* A part of a logical expression in which case that part of the expression is ignored for branch coverage
6. It is up to the caller to scope this as narrowly as possible. For example, if you have a source file that is wrapped
in a function expression, adding `/* istanbul ignore next */` at the top of the file will ignore the whole file!
### How it works
When some part of the JS is considered skipped, nothing actually happens in terms of changes to the instrumentation. Everything is calculated as though nothing was skipped - all that changes is that there is a `skip` attribute added to the metadata of the statement, function or branch as applicable.
Coverage reporting however takes the `skip` attribute into account and artificially increments counts, when 0 and skipped to pretend that the thing in question was covered. The HTML report shows the coverage after taking skips into account but at the same time colors the skipped statements with a gray color for easy visual scan.
This design makes it possible to report on either of the coverage numbers ("raw" v/s "processed"), show a count of statements/ functions/ branches skipped etc. The HTML and text summary reports display counts of how many statements, branches and functions were ignored.
### Some practical examples
#### Ignore an else path
```javascript
/* istanbul ignore else */
if (foo.hasOwnProperty('bar')) {
// do something
}
```
Usually istanbul would complain about missing coverage for the `else` branch but it won't do so because of the comment.
#### Ignore an if path
```javascript
/* istanbul ignore if */
if (hardToReproduceError)) {
return callback(hardToReproduceError);
}
```
In this case, you do not have to produce the error to have full branch coverage.
#### Ignore specific switch cases
```javascript
switch (foo) {
case 1: /* some code */; break;
/* istanbul ignore next */
case 2: // really difficult to enter in a unit test for some reason
someCode();
}
```
In the above example, the `case 2` branch is treated as covered.
#### Ignore default assignments
```javascript
var object = parameter || /* istanbul ignore next: tired of writing tests */ {};
```
In the above example, the entire line will be treated a covered even if you don't have a test for a falsy `parameter` value. In this example the trailing `: tired of writing tests` string is an explanatory comment for your future self. It can be anything.
#### Ignore specific conditions in an expression
```javascript
if (simpleError ||
/* istanbul ignore next */ reallyDifficultToProduceError) {
}
```
You get the idea by now.
#### Ignore a UMD wrapper
```javascript
(function (root, factory) {
'use strict';
/* istanbul ignore next */
if (typeof exports === 'object') {
// CommonJS
module.exports = factory();
} else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(factory);
} else {
// Browser globals
root.module = factory();
}
})(this, fn);
```
This will cause the entire function expression to be skipped for coverage.
istanbul-0.4.5/index.js 0000664 0000000 0000000 00000010361 12756403262 0015016 0 ustar 00root root 0000000 0000000 /*
Copyright (c) 2012, Yahoo! Inc. All rights reserved.
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
/*jslint nomen: true */
var path = require('path'),
Store = require('./lib/store'),
Report = require('./lib/report'),
meta = require('./lib/util/meta');
//register our standard plugins
require('./lib/register-plugins');
/**
* the top-level API for `istanbul`. provides access to the key libraries in
* istanbul so you can write your own tools using `istanbul` as a library.
*
* Usage
* -----
*
* var istanbul = require('istanbul');
*
*
* @class Istanbul
* @static
* @module main
* @main main
*/
module.exports = {
/**
* the Instrumenter class.
* @property Instrumenter
* @type Instrumenter
* @static
*/
Instrumenter: require('./lib/instrumenter'),
/**
* the Store class.
* @property Store
* @type Store
* @static
*/
Store: Store,
/**
* the Collector class
* @property Collector
* @type Collector
* @static
*/
Collector: require('./lib/collector'),
/**
* the hook module
* @property hook
* @type Hook
* @static
*/
hook: require('./lib/hook'),
/**
* the Report class
* @property Report
* @type Report
* @static
*/
Report: Report,
/**
* the config module
* @property config
* @type Config
* @static
*/
config: require('./lib/config'),
/**
* the Reporter class
* @property Reporter
* @type Reporter
* @static
*/
Reporter: require('./lib/reporter'),
/**
* utility for processing coverage objects
* @property utils
* @type ObjectUtils
* @static
*/
utils: require('./lib/object-utils'),
/**
* asynchronously returns a function that can match filesystem paths.
* The function returned in the callback may be passed directly as a `matcher`
* to the functions in the `hook` module.
*
* When no options are passed, the match function is one that matches all JS
* files under the current working directory except ones under `node_modules`
*
* Match patterns are `ant`-style patterns processed using the `glob` library.
* Examples not provided due to limitations in putting asterisks inside
* jsdoc comments. Please refer to tests under `test/other/test-matcher.js`
* for examples.
*
* @method matcherFor
* @static
* @param {Object} options Optional. Lookup options.
* @param {String} [options.root] the root of the filesystem tree under
* which to match files. Defaults to `process.cwd()`
* @param {Array} [options.includes] an array of include patterns to match.
* Defaults to all JS files under the root.
* @param {Array} [options.excludes] and array of exclude patterns. File paths
* matching these patterns will be excluded by the returned matcher.
* Defaults to files under `node_modules` found anywhere under root.
* @param {Function(err, matchFunction)} callback The callback that is
* called with two arguments. The first is an `Error` object in case
* of errors or a falsy value if there were no errors. The second
* is a function that may be use as a matcher.
*/
matcherFor: require('./lib/util/file-matcher').matcherFor,
/**
* the version of the library
* @property VERSION
* @type String
* @static
*/
VERSION: meta.VERSION,
/**
* the abstract Writer class
* @property Writer
* @type Writer
* @static
*/
Writer: require('./lib/util/writer').Writer,
/**
* the abstract ContentWriter class
* @property ContentWriter
* @type ContentWriter
* @static
*/
ContentWriter: require('./lib/util/writer').ContentWriter,
/**
* the concrete FileWriter class
* @property FileWriter
* @type FileWriter
* @static
*/
FileWriter: require('./lib/util/file-writer'),
//undocumented
_yuiLoadHook: require('./lib/util/yui-load-hook'),
//undocumented
TreeSummarizer: require('./lib/util/tree-summarizer'),
//undocumented
assetsDir: path.resolve(__dirname, 'lib', 'assets')
};
istanbul-0.4.5/lib/ 0000775 0000000 0000000 00000000000 12756403262 0014116 5 ustar 00root root 0000000 0000000 istanbul-0.4.5/lib/assets/ 0000775 0000000 0000000 00000000000 12756403262 0015420 5 ustar 00root root 0000000 0000000 istanbul-0.4.5/lib/assets/base.css 0000664 0000000 0000000 00000012027 12756403262 0017046 0 ustar 00root root 0000000 0000000 body, html {
margin:0; padding: 0;
height: 100%;
}
body {
font-family: Helvetica Neue, Helvetica, Arial;
font-size: 14px;
color:#333;
}
.small { font-size: 12px; }
*, *:after, *:before {
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
box-sizing:border-box;
}
h1 { font-size: 20px; margin: 0;}
h2 { font-size: 14px; }
pre {
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
margin: 0;
padding: 0;
-moz-tab-size: 2;
-o-tab-size: 2;
tab-size: 2;
}
a { color:#0074D9; text-decoration:none; }
a:hover { text-decoration:underline; }
.strong { font-weight: bold; }
.space-top1 { padding: 10px 0 0 0; }
.pad2y { padding: 20px 0; }
.pad1y { padding: 10px 0; }
.pad2x { padding: 0 20px; }
.pad2 { padding: 20px; }
.pad1 { padding: 10px; }
.space-left2 { padding-left:55px; }
.space-right2 { padding-right:20px; }
.center { text-align:center; }
.clearfix { display:block; }
.clearfix:after {
content:'';
display:block;
height:0;
clear:both;
visibility:hidden;
}
.fl { float: left; }
@media only screen and (max-width:640px) {
.col3 { width:100%; max-width:100%; }
.hide-mobile { display:none!important; }
}
.quiet {
color: #7f7f7f;
color: rgba(0,0,0,0.5);
}
.quiet a { opacity: 0.7; }
.fraction {
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
font-size: 10px;
color: #555;
background: #E8E8E8;
padding: 4px 5px;
border-radius: 3px;
vertical-align: middle;
}
div.path a:link, div.path a:visited { color: #333; }
table.coverage {
border-collapse: collapse;
margin: 10px 0 0 0;
padding: 0;
}
table.coverage td {
margin: 0;
padding: 0;
vertical-align: top;
}
table.coverage td.line-count {
text-align: right;
padding: 0 5px 0 20px;
}
table.coverage td.line-coverage {
text-align: right;
padding-right: 10px;
min-width:20px;
}
table.coverage td span.cline-any {
display: inline-block;
padding: 0 5px;
width: 100%;
}
.missing-if-branch {
display: inline-block;
margin-right: 5px;
border-radius: 3px;
position: relative;
padding: 0 4px;
background: #333;
color: yellow;
}
.skip-if-branch {
display: none;
margin-right: 10px;
position: relative;
padding: 0 4px;
background: #ccc;
color: white;
}
.missing-if-branch .typ, .skip-if-branch .typ {
color: inherit !important;
}
.coverage-summary {
border-collapse: collapse;
width: 100%;
}
.coverage-summary tr { border-bottom: 1px solid #bbb; }
.keyline-all { border: 1px solid #ddd; }
.coverage-summary td, .coverage-summary th { padding: 10px; }
.coverage-summary tbody { border: 1px solid #bbb; }
.coverage-summary td { border-right: 1px solid #bbb; }
.coverage-summary td:last-child { border-right: none; }
.coverage-summary th {
text-align: left;
font-weight: normal;
white-space: nowrap;
}
.coverage-summary th.file { border-right: none !important; }
.coverage-summary th.pct { }
.coverage-summary th.pic,
.coverage-summary th.abs,
.coverage-summary td.pct,
.coverage-summary td.abs { text-align: right; }
.coverage-summary td.file { white-space: nowrap; }
.coverage-summary td.pic { min-width: 120px !important; }
.coverage-summary tfoot td { }
.coverage-summary .sorter {
height: 10px;
width: 7px;
display: inline-block;
margin-left: 0.5em;
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
}
.coverage-summary .sorted .sorter {
background-position: 0 -20px;
}
.coverage-summary .sorted-desc .sorter {
background-position: 0 -10px;
}
.status-line { height: 10px; }
/* dark red */
.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
.low .chart { border:1px solid #C21F39 }
/* medium red */
.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
/* light red */
.low, .cline-no { background:#FCE1E5 }
/* light green */
.high, .cline-yes { background:rgb(230,245,208) }
/* medium green */
.cstat-yes { background:rgb(161,215,106) }
/* dark green */
.status-line.high, .high .cover-fill { background:rgb(77,146,33) }
.high .chart { border:1px solid rgb(77,146,33) }
/* dark yellow (gold) */
.medium .chart { border:1px solid #f9cd0b; }
.status-line.medium, .medium .cover-fill { background: #f9cd0b; }
/* light yellow */
.medium { background: #fff4c2; }
/* light gray */
span.cline-neutral { background: #eaeaea; }
.cbranch-no { background: yellow !important; color: #111; }
.cstat-skip { background: #ddd; color: #111; }
.fstat-skip { background: #ddd; color: #111 !important; }
.cbranch-skip { background: #ddd !important; color: #111; }
.cover-fill, .cover-empty {
display:inline-block;
height: 12px;
}
.chart {
line-height: 0;
}
.cover-empty {
background: white;
}
.cover-full {
border-right: none !important;
}
pre.prettyprint {
border: none !important;
padding: 0 !important;
margin: 0 !important;
}
.com { color: #999 !important; }
.ignore-none { color: #999; font-weight: normal; }
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -48px;
}
.footer, .push {
height: 48px;
}
istanbul-0.4.5/lib/assets/sort-arrow-sprite.png 0000664 0000000 0000000 00000000321 12756403262 0021545 0 ustar 00root root 0000000 0000000 ‰PNG
IHDR °F•3 tEXtSoftware Adobe ImageReadyqÉe<