Skip to content
This repository
Browse code

Merge pull request #296 from alex-seville/development

v1.1.5
  • Loading branch information...
commit 5e6eaa6d1cb49250d321f5d23d235689c22c0aea 2 parents 6c1b00f + 0389f3f
Alex Seville authored

Showing 29 changed files with 1,414 additions and 4,859 deletions. Show diff stats Hide diff stats

  1. +1 1  component.json
  2. +450 2,306 dist/jasmine/blanket_jasmine.js
  3. +1 1  dist/jasmine/blanket_jasmine.min.js
  4. +436 2,292 dist/qunit/blanket.js
  5. +1 1  dist/qunit/blanket.min.js
  6. +4 4 docs/advanced_browser.md
  7. +111 0 docs/browser_options.md
  8. +15 2 docs/intermediate_browser.md
  9. +1 10 grunt.js
  10. +3 3 package.json
  11. +1 1  src/adapters/jasmine-blanket.js
  12. +2 2 src/blanket.js
  13. +245 131 src/blanketRequire.js
  14. +27 39 src/blanket_browser.js
  15. +6 17 src/config.js
  16. +18 13 src/index.js
  17. +1 1  src/qunit/qunit.js
  18. +69 11 src/qunit/reporter.js
  19. +7 6 src/reporters/lcov_reporter.js
  20. +6 5 src/reporters/simple_json_reporter.js
  21. +1 1  tasks/blanketTests.js
  22. +1 0  test/helpers/phantom_qunit_runner.js
  23. +0 5 test/lib-tests/blanket_test.js
  24. +3 3 test/requirejs/chutzpah.html
  25. +1 1  test/requirejs/require_runner.html
  26. +3 3 test/test-node/fixture/core_fixtures.js
  27. 0  test/test-node/fixture/{simple_test_file.js → simple_test_file.js.js}
  28. 0  test/test-node/fixture/{simple_test_file_instrumented.js → simple_test_file_instrumented.js.js}
  29. 0  test/test-node/fixture/{simple_test_file_instrumented_full.js → simple_test_file_instrumented_full.js.js}
2  component.json
... ... @@ -1,5 +1,5 @@
1 1 {
2 2 "name": "blanket",
3   - "version": "1.1.4",
  3 + "version": "1.1.5",
4 4 "main": ["./dist/qunit/blanket.js"]
5 5 }
2,756 dist/jasmine/blanket_jasmine.js
450 additions, 2,306 deletions not shown
2  dist/jasmine/blanket_jasmine.min.js
1 addition, 1 deletion not shown
2,728 dist/qunit/blanket.js
436 additions, 2,292 deletions not shown
2  dist/qunit/blanket.min.js
1 addition, 1 deletion not shown
8 docs/advanced_browser.md
Source Rendered
@@ -40,15 +40,15 @@ Custom reporters are used by Blanket to display the coverage results. Blanket c
40 40
41 41 See the [simple_json_reporter](https://raw.github.com/alex-seville/blanket/master/src/reporters/simple_json_reporter.js) as a very basic example of a reporter.
42 42
43   -Reporters need to be wrapped in a define statement, and return a function that accept the coverage results object as an argument, ex:
  43 +Reporters are functions assigned to blanket.customReporter, which accept the coverage results object as an argument, ex:
44 44
45 45 ```
46   -define([],function myReporter(){
  46 +(function myReporter(){
47 47 //your reporter code
48   - return function(coverage_results){
  48 + blanket.customReporter=function(coverage_results){
49 49 console.log(coverage_results);
50 50 };
51   -};
  51 +})();
52 52 ```
53 53
54 54 The example above will create a reporter that will print the coverage result object to the console. Not useful, but it illustrates the pattern.
111 docs/browser_options.md
Source Rendered
... ... @@ -0,0 +1,111 @@
  1 +# Blanket Options (browser version)
  2 +
  3 +This guide details all the configuration options available for the browser version of Blanket.js
  4 +
  5 +1. data-cover-adapter
  6 +2. data-cover-customVariable
  7 +3. data-cover-flags
  8 + a. autoStart
  9 + b. branchTracking
  10 + c. commonJS
  11 + d. debug
  12 + e. engineOnly
  13 + f. existingRequireJS
  14 + g. ignoreCors
  15 + h. ignoreError
  16 + i. instrumentCache
  17 + j. sourceURL
  18 +4. data-cover-loader
  19 +5. data-cover-modulepattern
  20 +6. data-cover-never
  21 +7. data-cover-only
  22 +8. data-cover-reporter
  23 +9. data-cover-reporter-options
  24 +10. data-cover-testReadyCallback
  25 +11. data-cover-timeout
  26 +
  27 +
  28 +1. data-cover-adapter
  29 +
  30 +Use this option to configure a custom adapter for Blanket. Examples include adapters for Jasmine or Mocha. An adapter can be any code intended to run in concert with Blanket. Adapters do not have any special execution scope or access to Blanket, but they are required to override the default QUnit bindings.
  31 +
  32 +The value for this setting must be a string representing a valid url path to the adapter JavaScript file.
  33 +
  34 +Syntax: data-cover-adapter="<path/to/adapter>"
  35 +Example: `data-cover-adapter="src/adapters/mocha-blanket.js"
  36 +Result: The mocha-blanket adapter, located in src/adapters, will be loaded when the main Blanket script is executed.
  37 +
  38 +
  39 +2. data-cover-customVariable
  40 +
  41 +This option can be used to override the default coverage variable name (_$blanket). Often this isn't required, but there may be use cases where you'd like it to match the variable name of another coverage package (i.e. _$jscoverage) or avoid collisions with local variables in your code.
  42 +
  43 +NOTE: There are no checks done to ensure that the variable you provide is valid. It is your responsibility to ensure that a valid, conflict-free variable name is provided.
  44 +
  45 +Syntax: data-cover-customVariable="<custom variable name>"
  46 +Example: data-cover-customVariable="myCoverageVariable"
  47 +Result: Blanket will use `myCoverageVariable` as the coverage variable. After covered files are executed you can retrieve coverage information by querying the `myCoverageVariable` variable.
  48 +
  49 +
  50 +3. data-cover-flags
  51 +
  52 +The data-cover-flags option is used to set a variety of boolean settings. It is a string value, and if an option is included in the string it will be set to `true`.
  53 +
  54 +The syntax for data-cover-flag values is `data-cover-flags="<whitespace separated list of flags>"`, i.e. `data-cover-flags="ignoreError debug"`.
  55 +
  56 + a. autoStart
  57 +
  58 + h. ignoreError
  59 +
  60 + This option is used to force Blanket to continue processing even if an error occurs during instrumentation. This allows users to manage error handling in their prefered manner.
  61 +
  62 +
  63 +
  64 +
  65 +7. data-cover-only
  66 +
  67 +This option is used to indicate which files you want included for coverage. The value can be a string, regular expression, array, or function.
  68 +If you're including it in a data attribute, you must use the following format:
  69 +
  70 +regular expression: data-cover-only="//<your regular expression>"
  71 +example: data-cover-only="//sourcefile[0-9]{2}.js$/i"
  72 +result: the file `sourcefile89.js` would be covered.
  73 +
  74 +array: data-cover-only="[<comma separated list of strings, regular expressions, arryas or functions>]"
  75 +example: data-cover-only="['src/','modules/']"
  76 +result: files contains `src/` and `modules/` in their files paths will be covered.
  77 +
  78 +function: data-cover-only="#<function declaration or function name>"
  79 +example: data-cover-only="#function(str){ return str.length < 5; }"
  80 +result: any files whose path is less than 5 characters will be covered.
  81 +
  82 +
  83 +6. data-cover-never
  84 +
  85 +This option is used to indicate which files you want excluded from coverage. If a file matches this setting it will be excluded, even if it matches a pattern from `data-cover-only`. The value can be a string, regular expression, array, or function.
  86 +If you're including it in a data attribute, you must use the following format:
  87 +
  88 +regular expression: data-cover-never="//<your regular expression>"
  89 +example: data-cover-never="//sourcefile[0-9]{2}.js$/i"
  90 +result: the file `sourcefile89.js` would be excluded from coverage.
  91 +
  92 +array: data-cover-never="[<comma separated list of strings, regular expressions, arryas or functions>]"
  93 +example: data-cover-never="['src/','modules/']"
  94 +result: files contains `src/` and `modules/` in their files paths will be excluded from coverage.
  95 +
  96 +function: data-cover-never="#<function declaration or function name>"
  97 +example: data-cover-never="#function(str){ return str.length < 5; }"
  98 +result: any files whose path is less than 5 characters will be excluded from coverage.
  99 +
  100 +
  101 +8. data-cover-reporter
  102 +
  103 +This option is used to set a custom reporter for Blanket. The value can be a string (valid file path to reporter file), or a function (accepting the coverage result as an argument).
  104 +
  105 +string: data-cover-reporter="<path/to/custom/reporter>"
  106 +example: data-cover-reporter="mocha_blanket_reporter.js"
  107 +result: The reporter defined in mocha_blanket_reporter will be attached as the reporter for Blanket coverage results.
  108 +
  109 +function: blanket.options('data-cover-reporter',<reporter function>);
  110 +example: blanket.options('data-cover-reporter',function myReporter(cov){ alert(cov); });
  111 +result: The full coverage object will be outputted via an alert dialog.
17 docs/intermediate_browser.md
Source Rendered
@@ -23,6 +23,19 @@ NOTE: PhantomJS and other third-party JS runtimes may not support synchronous XH
23 23 ```<script src="blanket.min.js" data-cover-adapter="jasmine-blanket.js"
24 24 data-cover-only="['source1.js','src/source2.js']"></script>```
25 25
26   -5. Open the test runner in the browser. The coverage details will be appended below the test results.
  26 +5. Add a `data-cover-modulepattern` attribute to have the reporter generate total coverage statistics for each module in your application. (*Currently only supported using QUnit reporter.*) This is useful for tracking code coverage across multiple teams that work on different modules. Modules are determined by the regular expression pattern you pass via this attribute. The regular expression is expected to have one pattern matching section in parenthesis, which will be captured as the module name. For example, let's say that the files in your blanket report look like this:
27 27
28   -6. If you will always be using the adapter, consider making a [custom build](https://github.com/alex-seville/blanket/blob/master/README.md#roll-your-own) of blanket (i.e. `dist/jasmine/blanket_jasmine.js`).
  28 +```
  29 +./core/src/js/MainView.js
  30 +./core/src/js/NavBar.js
  31 +./gallery/src/js/GalleryView.js
  32 +./cart/src/js/Cart.js
  33 +```
  34 +
  35 +In this case, we want the module to be recognized as the characters in between the first two slashes, such that we end up with modules `core`, `gallery`, and `cart`. To achieve this, specify an attribute like so: `data-cover-modulepattern="\.\/(.*?)\/"`
  36 +
  37 +This regular expression says, look for a period, followed by a slash, followed by any number of characters up until the next slash (which we store as a matched pattern). For more info on regular expressions, see the [MDN RegEx guide](https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Regular_Expressions).
  38 +
  39 +6. Open the test runner in the browser. The coverage details will be appended below the test results.
  40 +
  41 +7. If you will always be using the adapter, consider making a [custom build](https://github.com/alex-seville/blanket/blob/master/README.md#roll-your-own) of blanket (i.e. `dist/jasmine/blanket_jasmine.js`).
11 grunt.js
@@ -9,8 +9,6 @@ module.exports = function(grunt) {
9 9 falafelEnd: 'window.falafel = module.exports;})(function(){return {parse: esprima.parse};},{exports: {}});',
10 10 esprimaStart: '(function(define){',
11 11 esprimaEnd: '})(null);<%= "" %>',
12   - requireStart: 'blanket.setupRequireJS=function(context){',
13   - requireEnd: 'context.require=require; context.define=define; context.requirejs=requirejs; };'
14 12 },
15 13 blanketTest: {
16 14 normal:{
@@ -29,7 +27,7 @@ module.exports = function(grunt) {
29 27 browserBootstrap: "<%= cmds.phantom %> <%= phantom.qunit_old %> <%= runners.browserBootstrap %>",
30 28 browserCoffeeScript: "<%= cmds.phantom %> <%= phantom.qunit %> <%= runners.browserCoffeeScript %>",
31 29 browserJasmineRequire: "<%= cmds.phantom %> <%= phantom.jasmine %> <%= runners.browserJasmineRequire %>",
32   - browserChutzpah: "<%= cmds.phantom %> <%= phantom.qunit %> <%= runners.browserChutzpah %>",
  30 + //browserChutzpah: "<%= cmds.phantom %> <%= phantom.qunit %> <%= runners.browserChutzpah %>",
33 31 browserCommonjs: "<%= cmds.phantom %> <%= phantom.qunit %> <%= runners.browserCommonjs %>"
34 32 },
35 33 coverage:{
@@ -55,9 +53,6 @@ module.exports = function(grunt) {
55 53 '<banner:meta.falafelEnd>',
56 54 'src/blanket.js',
57 55 'src/blanket_browser.js',
58   - '<banner:meta.requireStart>',
59   - 'node_modules/requirejs/require.js',
60   - '<banner:meta.requireEnd>',
61 56 "src/qunit/reporter.js",
62 57 "src/config.js",
63 58 "src/blanketRequire.js",
@@ -74,9 +69,6 @@ module.exports = function(grunt) {
74 69 '<banner:meta.falafelEnd>',
75 70 'src/blanket.js',
76 71 'src/blanket_browser.js',
77   - '<banner:meta.requireStart>',
78   - 'node_modules/requirejs/require.js',
79   - '<banner:meta.requireEnd>',
80 72 "src/qunit/reporter.js",
81 73 "src/config.js",
82 74 "src/blanketRequire.js",
@@ -130,7 +122,6 @@ module.exports = function(grunt) {
130 122 node: true,
131 123 browser: true,
132 124 es5: true,
133   - "evil":"ignore",
134 125 expr: "warn"
135 126 },
136 127 globals: {}
6 package.json
... ... @@ -1,7 +1,7 @@
1 1 {
2 2 "name": "blanket",
3 3 "description": "seamless js code coverage",
4   - "version": "1.1.4",
  4 + "version": "1.1.5",
5 5 "homepage": "https://github.com/alex-seville/blanket",
6 6 "author": {
7 7 "name": "Alex-Seville",
@@ -23,18 +23,18 @@
23 23 ],
24 24 "main": "src/index.js",
25 25 "engines": {
26   - "node": "0.8.*"
  26 + "node": "0.10.7"
27 27 },
28 28 "dependencies": {
29 29 "esprima": "~1.0.2",
30 30 "falafel": "~0.1.6",
31   - "requirejs": "~2.1.4",
32 31 "xtend": "~2.0.3"
33 32 },
34 33 "devDependencies": {
35 34 "phantomjs": "1.8.2-0",
36 35 "coffee-script": "1.4.0",
37 36 "mocha": "1.7.4",
  37 + "requirejs": "~2.1.4",
38 38 "travis-cov": "*",
39 39 "grunt": "0.3.17"
40 40 },
2  src/adapters/jasmine-blanket.js
@@ -83,7 +83,7 @@
83 83 jasmine.getEnv().addReporter(new jasmine.BlanketReporter());
84 84 window.jasmine.getEnv().currentRunner().execute();
85 85 jasmine.getEnv().execute = function () {
86   - jasmine.getEnv().currentRunner().execute;
  86 + jasmine.getEnv().currentRunner().execute();
87 87 };
88 88 }
89 89 });
4 src/blanket.js
@@ -34,7 +34,6 @@ var parseAndModify = (inBrowser ? window.falafel : require("falafel"));
34 34 adapter:null,
35 35 filter: null,
36 36 customVariable: null,
37   - orderedLoading: true,
38 37 loader: null,
39 38 ignoreScriptError: false,
40 39 existingRequireJS:false,
@@ -47,7 +46,8 @@ var parseAndModify = (inBrowser ? window.falafel : require("falafel"));
47 46 engineOnly:false,
48 47 testReadyCallback:null,
49 48 commonJS:false,
50   - instrumentCache:false
  49 + instrumentCache:false,
  50 + modulePattern: null
51 51 };
52 52
53 53 if (inBrowser && typeof window.blanket !== 'undefined'){
376 src/blanketRequire.js
... ... @@ -1,139 +1,225 @@
1 1 (function(_blanket){
2 2 _blanket.extend({
3 3 utils: {
4   - normalizeBackslashes: function(str) {
5   - return str.replace(/\\/g, '/');
6   - },
7   - matchPatternAttribute: function(filename,pattern){
8   - if (typeof pattern === 'string'){
9   - if (pattern.indexOf("[") === 0){
10   - //treat as array
11   - var pattenArr = pattern.slice(1,pattern.length-1).split(",");
12   - return pattenArr.some(function(elem){
13   - return _blanket.utils.matchPatternAttribute(filename,_blanket.utils.normalizeBackslashes(elem.slice(1,-1)));
14   - //return filename.indexOf(_blanket.utils.normalizeBackslashes(elem.slice(1,-1))) > -1;
  4 + normalizeBackslashes: function(str) {
  5 + return str.replace(/\\/g, '/');
  6 + },
  7 + matchPatternAttribute: function(filename,pattern){
  8 + if (typeof pattern === 'string'){
  9 + if (pattern.indexOf("[") === 0){
  10 + //treat as array
  11 + var pattenArr = pattern.slice(1,pattern.length-1).split(",");
  12 + return pattenArr.some(function(elem){
  13 + return _blanket.utils.matchPatternAttribute(filename,_blanket.utils.normalizeBackslashes(elem.slice(1,-1)));
  14 + //return filename.indexOf(_blanket.utils.normalizeBackslashes(elem.slice(1,-1))) > -1;
  15 + });
  16 + }else if ( pattern.indexOf("//") === 0){
  17 + var ex = pattern.slice(2,pattern.lastIndexOf('/'));
  18 + var mods = pattern.slice(pattern.lastIndexOf('/')+1);
  19 + var regex = new RegExp(ex,mods);
  20 + return regex.test(filename);
  21 + }else if (pattern.indexOf("#") === 0){
  22 + return window[pattern.slice(1)].call(window,filename);
  23 + }else{
  24 + return filename.indexOf(_blanket.utils.normalizeBackslashes(pattern)) > -1;
  25 + }
  26 + }else if ( pattern instanceof Array ){
  27 + return pattern.some(function(elem){
  28 + return _blanket.utils.matchPatternAttribute(filename,elem);
15 29 });
16   - }else if ( pattern.indexOf("//") === 0){
17   - var ex = pattern.slice(2,pattern.lastIndexOf('/'));
18   - var mods = pattern.slice(pattern.lastIndexOf('/')+1);
19   - var regex = new RegExp(ex,mods);
20   - return regex.test(filename);
21   - }else if (pattern.indexOf("#") === 0){
22   - return window[pattern.slice(1)].call(window,filename);
23   - }else{
24   - return filename.indexOf(_blanket.utils.normalizeBackslashes(pattern)) > -1;
  30 + }else if (pattern instanceof RegExp){
  31 + return pattern.test(filename);
  32 + }else if (typeof pattern === "function"){
  33 + return pattern.call(window,filename);
25 34 }
26   - }else if ( pattern instanceof Array ){
27   - return pattern.some(function(elem){
28   - return _blanket.utils.matchPatternAttribute(filename,elem);
29   - });
30   - }else if (pattern instanceof RegExp){
31   - return pattern.test(filename);
32   - }else if (typeof pattern === "function"){
33   - return pattern.call(window,filename);
34   - }
35   - },
36   - blanketEval: function(data){
37   - return ( window.execScript || function( data ) {
38   - //borrowed from jquery
39   - window[ "eval" ].call( window, data );
40   - } )( data );
41   - },
42   - collectPageScripts: function(){
43   - console.log("cps1:"+new Date().getTime());
44   - var toArray = Array.prototype.slice;
45   - var scripts = toArray.call(document.scripts);
46   - var selectedScripts=[],scriptNames=[];
47   - var filter = _blanket.options("filter");
48   - if(filter != null){
49   - //global filter in place, data-cover-only
50   - var antimatch = _blanket.options("antifilter");
51   - selectedScripts = toArray.call(document.scripts)
52   - .filter(function(s){
53   - return toArray.call(s.attributes).filter(function(sn){
54   - return sn.nodeName === "src" && _blanket.utils.matchPatternAttribute(sn.nodeValue,filter) &&
55   - (typeof antimatch === "undefined" || !_blanket.utils.matchPatternAttribute(sn.nodeValue,antimatch));
56   - }).length === 1;
57   - });
58   - }else{
59   - selectedScripts = toArray.call(document.querySelectorAll("script[data-cover]"));
60   - }
61   - scriptNames = selectedScripts.map(function(s){
62   - return _blanket.utils.qualifyURL(
63   - toArray.call(s.attributes).filter(
64   - function(sn){
65   - return sn.nodeName === "src";
66   - })[0].nodeValue).replace(".js","");
  35 + },
  36 + blanketEval: function(data){
  37 + _blanket._addScript(data);
  38 + },
  39 + collectPageScripts: function(){
  40 + var toArray = Array.prototype.slice;
  41 + var scripts = toArray.call(document.scripts);
  42 + var selectedScripts=[],scriptNames=[];
  43 + var filter = _blanket.options("filter");
  44 + if(filter != null){
  45 + //global filter in place, data-cover-only
  46 + var antimatch = _blanket.options("antifilter");
  47 + selectedScripts = toArray.call(document.scripts)
  48 + .filter(function(s){
  49 + return toArray.call(s.attributes).filter(function(sn){
  50 + return sn.nodeName === "src" && _blanket.utils.matchPatternAttribute(sn.nodeValue,filter) &&
  51 + (typeof antimatch === "undefined" || !_blanket.utils.matchPatternAttribute(sn.nodeValue,antimatch));
  52 + }).length === 1;
67 53 });
68   - if (!filter){
69   - _blanket.options("filter","['"+scriptNames.join("','")+"']");
70   - }
71   - return scriptNames;
72   - }
73   -}
74   -});
75   -(function(){
76   - var require = blanket.options("commonJS") ? blanket._commonjs.require : window.require;
77   - var requirejs = blanket.options("commonJS") ? blanket._commonjs.requirejs : window.requirejs;
78   - if (!_blanket.options("engineOnly")){
79   -
80   - _blanket.utils.oldloader = requirejs.load;
81   - console.log("cps2:"+new Date().getTime());
82   -
83   - requirejs.load = function (context, moduleName, url) {
84   - _blanket.requiringFile(url);
85   - requirejs.cget(url, function (content) {
  54 + }else{
  55 + selectedScripts = toArray.call(document.querySelectorAll("script[data-cover]"));
  56 + }
  57 + scriptNames = selectedScripts.map(function(s){
  58 + return _blanket.utils.qualifyURL(
  59 + toArray.call(s.attributes).filter(
  60 + function(sn){
  61 + return sn.nodeName === "src";
  62 + })[0].nodeValue).replace(".js","");
  63 + });
  64 + if (!filter){
  65 + _blanket.options("filter","['"+scriptNames.join("','")+"']");
  66 + }
  67 + return scriptNames;
  68 + },
  69 + loadAll: function(nextScript,cb,preprocessor){
  70 + /**
  71 + * load dependencies
  72 + * @param {nextScript} factory for priority level
  73 + * @param {cb} the done callback
  74 + */
  75 + var currScript=nextScript();
  76 + var isLoaded = _blanket.utils.scriptIsLoaded(
  77 + currScript,
  78 + _blanket.utils.ifOrdered,
  79 + nextScript,
  80 + cb
  81 + );
  82 +
  83 + if (!(_blanket.utils.cache[currScript] && _blanket.utils.cache[currScript].loaded)){
  84 + var attach = function(){
  85 + if (_blanket.options("debug")) {console.log("BLANKET-Mark script:"+currScript+", as loaded and move to next script.");}
  86 + isLoaded();
  87 + };
  88 + var whenDone = function(result){
  89 + if (_blanket.options("debug")) {console.log("BLANKET-File loading finished");}
  90 + if (typeof result !== 'undefined'){
  91 + if (_blanket.options("debug")) {console.log("BLANKET-Add file to DOM.");}
  92 + _blanket._addScript(result);
  93 + }
  94 + attach();
  95 + };
86 96
87   - var match = _blanket.options("filter");
88   - //we check the never matches first
89   - var antimatch = _blanket.options("antifilter");
90   - if (typeof antimatch !== "undefined" &&
91   - _blanket.utils.matchPatternAttribute(url.replace(".js",""),antimatch)
92   - ){
93   - _blanket.utils.oldloader(context, moduleName, url);
94   - if (_blanket.options("debug")) {console.log("BLANKET-File will never be instrumented:"+url);}
95   - _blanket.requiringFile(url,true);
96   - }else if (_blanket.utils.matchPatternAttribute(url.replace(".js",""),match)){
97   - if (_blanket.options("debug")) {console.log("BLANKET-Attempting instrument of:"+url);}
98   - _blanket.instrument({
99   - inputFile: content,
100   - inputFileName: url
101   - },function(instrumented){
102   - try{
103   - _blanket.utils.blanketEval(instrumented);
104   - context.completeLoad(moduleName);
  97 + _blanket.utils.attachScript(
  98 + {
  99 + url: currScript
  100 + },
  101 + function (content){
  102 + _blanket.utils.processFile(
  103 + content,
  104 + currScript,
  105 + whenDone,
  106 + whenDone
  107 + );
  108 + }
  109 + );
  110 + }else{
  111 + isLoaded();
  112 + }
  113 + },
  114 + attachScript: function(options,cb){
  115 + var timeout = _blanket.options("timeout") || 3000;
  116 + setTimeout(function(){
  117 + if (!_blanket.utils.cache[options.url].loaded){
  118 + throw new Error("error loading source script");
  119 + }
  120 + },timeout);
  121 + _blanket.utils.getFile(
  122 + options.url,
  123 + cb,
  124 + function(){ throw new Error("error loading source script");}
  125 + );
  126 + },
  127 + ifOrdered: function(nextScript,cb){
  128 + /**
  129 + * ordered loading callback
  130 + * @param {nextScript} factory for priority level
  131 + * @param {cb} the done callback
  132 + */
  133 + var currScript = nextScript(true);
  134 + if (currScript){
  135 + _blanket.utils.loadAll(nextScript,cb);
  136 + }else{
  137 + cb(new Error("Error in loading chain."));
  138 + }
  139 + },
  140 + scriptIsLoaded: function(url,orderedCb,nextScript,cb){
  141 + /**
  142 + * returns a callback that checks a loading list to see if a script is loaded.
  143 + * @param {orderedCb} callback if ordered loading is being done
  144 + * @param {nextScript} factory for next priority level
  145 + * @param {cb} the done callback
  146 + */
  147 + if (_blanket.options("debug")) {console.log("BLANKET-Returning function");}
  148 + return function(){
  149 + if (_blanket.options("debug")) {console.log("BLANKET-Marking file as loaded: "+url);}
  150 +
  151 + _blanket.utils.cache[url].loaded=true;
  152 +
  153 + if (_blanket.utils.allLoaded()){
  154 + if (_blanket.options("debug")) {console.log("BLANKET-All files loaded");}
  155 + cb();
  156 + }else if (orderedCb){
  157 + //if it's ordered we need to
  158 + //traverse down to the next
  159 + //priority level
  160 + if (_blanket.options("debug")) {console.log("BLANKET-Load next file.");}
  161 + orderedCb(nextScript,cb);
  162 + }
  163 + };
  164 + },
  165 + cache: {},
  166 + allLoaded: function (){
  167 + /**
  168 + * check if depdencies are loaded in cache
  169 + */
  170 + var cached = Object.keys(_blanket.utils.cache);
  171 + for (var i=0;i<cached.length;i++){
  172 + if (!_blanket.utils.cache[cached[i]].loaded){
  173 + return false;
  174 + }
  175 + }
  176 + return true;
  177 + },
  178 + processFile: function (content,url,cb,oldCb) {
  179 + var match = _blanket.options("filter");
  180 + //we check the never matches first
  181 + var antimatch = _blanket.options("antifilter");
  182 + if (typeof antimatch !== "undefined" &&
  183 + _blanket.utils.matchPatternAttribute(url.replace(/\.js$/,""),antimatch)
  184 + ){
  185 + oldCb(content);
  186 + if (_blanket.options("debug")) {console.log("BLANKET-File will never be instrumented:"+url);}
  187 + _blanket.requiringFile(url,true);
  188 + }else if (_blanket.utils.matchPatternAttribute(url.replace(/\.js$/,""),match)){
  189 + if (_blanket.options("debug")) {console.log("BLANKET-Attempting instrument of:"+url);}
  190 + _blanket.instrument({
  191 + inputFile: content,
  192 + inputFileName: url
  193 + },function(instrumented){
  194 + try{
  195 + if (_blanket.options("debug")) {console.log("BLANKET-instrument of:"+url+" was successfull.");}
  196 + _blanket.utils.blanketEval(instrumented);
  197 + cb();
  198 + _blanket.requiringFile(url,true);
  199 + }
  200 + catch(err){
  201 + if (_blanket.options("ignoreScriptError")){
  202 + //we can continue like normal if
  203 + //we're ignoring script errors,
  204 + //but otherwise we don't want
  205 + //to completeLoad or the error might be
  206 + //missed.
  207 + if (_blanket.options("debug")) { console.log("BLANKET-There was an error loading the file:"+url); }
  208 + cb(content);
105 209 _blanket.requiringFile(url,true);
  210 + }else{
  211 + throw new Error("Error parsing instrumented code: "+err);
106 212 }
107   - catch(err){
108   - if (_blanket.options("ignoreScriptError")){
109   - //we can continue like normal if
110   - //we're ignoring script errors,
111   - //but otherwise we don't want
112   - //to completeLoad or the error might be
113   - //missed.
114   - if (_blanket.options("debug")) { console.log("BLANKET-There was an error loading the file:"+url); }
115   - context.completeLoad(moduleName);
116   - _blanket.requiringFile(url,true);
117   - }else{
118   - throw new Error("Error parsing instrumented code: "+err);
119   - }
120   - }
121   - });
122   - }else{
123   - if (_blanket.options("debug")) { console.log("BLANKET-Loading (without instrumenting) the file:"+url);}
124   - _blanket.utils.oldloader(context, moduleName, url);
125   - _blanket.requiringFile(url,true);
126   - }
127   -
128   - }, function (err) {
129   - _blanket.requiringFile();
130   - throw err;
131   - });
132   - };
133   -
  213 + }
  214 + });
  215 + }else{
  216 + if (_blanket.options("debug")) { console.log("BLANKET-Loading (without instrumenting) the file:"+url);}
  217 + oldCb(content);
  218 + _blanket.requiringFile(url,true);
  219 + }
134 220
135   - requirejs.createXhr = function () {
136   - //Would love to dump the ActiveX crap in here. Need IE 6 to die first.
  221 + },
  222 + createXhr: function(){
137 223 var xhr, i, progId;
138 224 if (typeof XMLHttpRequest !== "undefined") {
139 225 return new XMLHttpRequest();
@@ -152,10 +238,8 @@ _blanket.extend({
152 238 }
153 239
154 240 return xhr;
155   - };
156   -
157   -
158   - requirejs.cget = function (url, callback, errback, onXhr) {
  241 + },
  242 + getFile: function(url, callback, errback, onXhr){
159 243 var foundInSession = false;
160 244 if (_blanket.blanketSession){
161 245 var files = Object.keys(_blanket.blanketSession);
@@ -169,7 +253,7 @@ _blanket.extend({
169 253 }
170 254 }
171 255 if (!foundInSession){
172   - var xhr = requirejs.createXhr();
  256 + var xhr = _blanket.utils.createXhr();
173 257 xhr.open('GET', url, true);
174 258
175 259 //Allow overrides specified in config
@@ -208,7 +292,37 @@ _blanket.extend({
208 292 }
209 293 }
210 294 }
  295 + }
  296 + }
  297 +});
  298 +
  299 +(function(){
  300 + var require = blanket.options("commonJS") ? blanket._commonjs.require : window.require;
  301 + var requirejs = blanket.options("commonJS") ? blanket._commonjs.requirejs : window.requirejs;
  302 + if (!_blanket.options("engineOnly") && _blanket.options("existingRequireJS")){
  303 +
  304 + _blanket.utils.oldloader = requirejs.load;
  305 +
  306 + requirejs.load = function (context, moduleName, url) {
  307 + _blanket.requiringFile(url);
  308 + _blanket.utils.getFile(url,
  309 + function(content){
  310 + _blanket.utils.processFile(
  311 + content,
  312 + url,
  313 + function newLoader(){
  314 + context.completeLoad(moduleName);
  315 + },
  316 + function oldLoader(){
  317 + _blanket.utils.oldloader(context, moduleName, url);
  318 + }
  319 + );
  320 + }, function (err) {
  321 + _blanket.requiringFile();
  322 + throw err;
  323 + });
211 324 };
212 325 }
213 326 })();
  327 +
214 328 })(blanket);
66 src/blanket_browser.js
@@ -137,12 +137,15 @@ _blanket.extend({
137 137 var request = new XMLHttpRequest();
138 138 request.open('GET', path, false);
139 139 request.send();
140   - var script = document.createElement("script");
141   - script.type = "text/javascript";
142   - script.text = request.responseText;
143   - (document.body || document.getElementsByTagName('head')[0]).appendChild(script);
  140 + _blanket._addScript(request.responseText);
144 141 }
145 142 },
  143 + _addScript: function(data){
  144 + var script = document.createElement("script");
  145 + script.type = "text/javascript";
  146 + script.text = data;
  147 + (document.body || document.getElementsByTagName('head')[0]).appendChild(script);
  148 + },
146 149 hasAdapter: function(callback){
147 150 return _blanket.options("adapter") !== null;
148 151 },
@@ -165,9 +168,8 @@ _blanket.extend({
165 168 delete coverage_data.files.branchFcn;
166 169 }
167 170 if (typeof _blanket.options("reporter") === "string"){
168   - require([_blanket.options("reporter").replace(".js","")],function(r){
169   - r(coverage_data,_blanket.options("reporter_options"));
170   - });
  171 + _blanket._loadFile(_blanket.options("reporter"));
  172 + _blanket.customReporter(coverage_data,_blanket.options("reporter_options"));
171 173 }else if (typeof _blanket.options("reporter") === "function"){
172 174 _blanket.options("reporter")(coverage_data);
173 175 }else if (typeof _blanket.defaultReporter === 'function'){
@@ -184,7 +186,6 @@ _blanket.extend({
184 186 }
185 187 },
186 188 _loadSourceFiles: function(callback){
187   - console.log("ls1:"+new Date().getTime());
188 189 var require = blanket.options("commonJS") ? blanket._commonjs.require : window.require;
189 190 function copy(o){
190 191 var _copy = Object.create( Object.getPrototypeOf(o) );
@@ -208,38 +209,25 @@ _blanket.extend({
208 209 if (sessionStorage["blanketSessionLoader"]){
209 210 _blanket.blanketSession = JSON.parse(sessionStorage["blanketSessionLoader"]);
210 211 }
211   -
212   - var requireConfig = {
213   - paths: {},
214   - shim: {},
215   - waitSeconds: _blanket.options("timeout")
216   - };
217   - var lastDep = {
218   - deps: []
219   - };
220   - var isOrdered = _blanket.options("orderedLoading");
221   - var initialGet=[];
222   - scripts.forEach(function(file,indx){
223   - //for whatever reason requirejs
224   - //prefers when we don't use the full path
225   - //so we just use a custom name
226   - var requireKey = "blanket_"+indx;
227   - initialGet.push(requireKey);
228   - requireConfig.paths[requireKey] = file;
229   - if (isOrdered){
230   - if (indx > 0){
231   - requireConfig.shim[requireKey] = copy(lastDep);
232   - }
233   - lastDep.deps = [requireKey];
234   - }
235   - });
236   - require.config(requireConfig);
237   - var filt = initialGet;
238   - require(filt, function(){
239   - callback();
  212 +
  213 + scripts.forEach(function(file,indx){
  214 + _blanket.utils.cache[file+".js"]={
  215 + loaded:false
  216 + };
240 217 });
  218 +
  219 + var currScript=-1;
  220 + _blanket.utils.loadAll(function(test){
  221 + if (test){
  222 + return typeof scripts[currScript+1] !== 'undefined';
  223 + }
  224 + currScript++;
  225 + if (currScript >= scripts.length){
  226 + return null;
  227 + }
  228 + return scripts[currScript]+".js";
  229 + },callback);
241 230 }
242   - console.log("ls2:"+new Date().getTime());
243 231 },
244 232 beforeStartTestRunner: function(opts){
245 233 opts = opts || {};
@@ -263,7 +251,7 @@ _blanket.extend({
263 251 if (typeof cb === "function"){
264 252 cb(opts.callback);
265 253 }else if (typeof cb === "string"){
266   - eval(cb);
  254 + _blanket._addScript(cb);
267 255 opts.callback();
268 256 }
269 257 }else{
23 src/config.js
@@ -23,6 +23,9 @@
23 23 if (es.nodeName === "data-cover-timeout"){
24 24 newOptions.timeout = es.nodeValue;
25 25 }
  26 + if (es.nodeName === "data-cover-modulepattern") {
  27 + newOptions.modulePattern = es.nodeValue;
  28 + }
26 29 if (es.nodeName === "data-cover-reporter-options"){
27 30 try{
28 31 newOptions.reporter_options = JSON.parse(es.nodeValue);
@@ -40,9 +43,6 @@
40 43 }
41 44 if (es.nodeName === "data-cover-flags"){
42 45 var flags = " "+es.nodeValue+" ";
43   - if (flags.indexOf(" unordered ") > -1){
44   - newOptions.order = false;
45   - }
46 46 if (flags.indexOf(" ignoreError ") > -1){
47 47 newOptions.ignoreScriptError = true;
48 48 }
@@ -78,19 +78,8 @@
78 78 blanket.options("existingRequireJS",true);
79 79 }
80 80 /* setup requirejs loader, if needed */
81   - if (!blanket.options("existingRequireJS") ){
82   - if (typeof window["define"] !== "undefined"){
83   - window["__blanket_old_define"]=window["define"];
84   - window["define"]=void 0;
85   - }
86   - if (blanket.options("commonJS")){
87   - blanket._commonjs = {};
88   - blanket.setupRequireJS(blanket._commonjs);
89   - }else{
90   - blanket.setupRequireJS(window);
91   - }
92   - if (typeof window["__blanket_old_define"] !== "undefined"){
93   - window["define"] = window["__blanket_old_define"];
94   - }
  81 +
  82 + if (blanket.options("commonJS")){
  83 + blanket._commonjs = {};
95 84 }
96 85 })();
31 src/index.js
@@ -118,7 +118,7 @@ var blanketNode = function (userOptions,cli){
118 118 //we check the never matches first
119 119 var antipattern = _blanket.options("antifilter");
120 120 if (typeof antipattern !== "undefined" &&
121   - blanket.normalizeBackslashes(url.replace(".js",""),antimatch)
  121 + blanket.normalizeBackslashes(filename.replace(/\.js$/,""),antipattern)
122 122 ){
123 123 oldLoader(localModule,filename);
124 124 if (_blanket.options("debug")) {console.log("BLANKET-File will never be instrumented:"+filename);}
@@ -161,19 +161,24 @@ var blanketNode = function (userOptions,cli){
161 161 return blanket;
162 162 };
163 163
164   -var args = process.argv;
165   -if (args[0] === 'node' &&
166   - args[1].indexOf(join('node_modules','mocha','bin')) > -1 &&
167   - (args.indexOf('--require') > 1 || args.indexOf('-r') > -1) &&
168   - args.indexOf('blanket') > 2){
169   - //using mocha cli
170   - module.exports = blanketNode(null,true);
  164 +if ((process.env && process.env.BLANKET_COV===1) ||
  165 + (process.ENV && process.ENV.BLANKET_COV)){
  166 + module.exports = blanketNode({engineOnly:true},false);
171 167 }else{
172   - //not mocha cli
173   - module.exports = function(options){
174   - //we don't want to expose the cli option.
175   - return blanketNode(options,false);
176   - };
  168 + var args = process.argv;
  169 + if (args[0] === 'node' &&
  170 + args[1].indexOf(join('node_modules','mocha','bin')) > -1 &&
  171 + (args.indexOf('--require') > 1 || args.indexOf('-r') > -1) &&
  172 + args.indexOf('blanket') > 2){
  173 + //using mocha cli
  174 + module.exports = blanketNode(null,true);
  175 + }else{
  176 + //not mocha cli
  177 + module.exports = function(options){
  178 + //we don't want to expose the cli option.
  179 + return blanketNode(options,false);
  180 + };
  181 + }
177 182 }
178 183
179 184
2  src/qunit/qunit.js
@@ -61,7 +61,7 @@ if (typeof QUnit !== 'undefined'){
61 61 }
62 62 });
63 63 }else{
64   - requirejs.load = _blanket.utils.oldloader;
  64 + if (blanket.options("existingRequireJS")){ requirejs.load = _blanket.utils.oldloader; }
65 65 blanket.noConflict().beforeStartTestRunner({
66 66 condition: allLoaded,
67 67 callback: function(){
80 src/qunit/reporter.js
@@ -10,7 +10,7 @@ blanket.defaultReporter = function(coverage){
10 10 }),
11 11 bodyContent = "<div id='blanket-main'><div class='blanket bl-title'><div class='bl-cl bl-file'><a href='http://alex-seville.github.com/blanket/' target='_blank' class='bl-logo'>Blanket.js</a> results</div><div class='bl-cl rs'>Coverage (%)</div><div class='bl-cl rs'>Covered/Total Smts.</div>"+(hasBranchTracking ? "<div class='bl-cl rs'>Covered/Total Branches</div>":"")+"<div style='clear:both;'></div></div>",
12 12 fileTemplate = "<div class='blanket {{statusclass}}'><div class='bl-cl bl-file'><span class='bl-nb'>{{fileNumber}}.</span><a href='javascript:blanket_toggleSource(\"file-{{fileNumber}}\")'>{{file}}</a></div><div class='bl-cl rs'>{{percentage}} %</div><div class='bl-cl rs'>{{numberCovered}}/{{totalSmts}}</div>"+( hasBranchTracking ? "<div class='bl-cl rs'>{{passedBranches}}/{{totalBranches}}</div>" : "" )+"<div id='file-{{fileNumber}}' class='bl-source' style='display:none;'>{{source}}</div><div style='clear:both;'></div></div>";
13   - grandTotalTemplate = "<div class='blanket grand-total {{statusclass}}'><div class='bl-cl'>Totals</div><div class='bl-cl rs'>{{percentage}} %</div><div class='bl-cl rs'>{{numberCovered}}/{{totalSmts}}</div>"+( hasBranchTracking ? "<div class='bl-cl rs'>{{passedBranches}}/{{totalBranches}}</div>" : "" ) + "<div style='clear:both;'></div></div>";
  13 + grandTotalTemplate = "<div class='blanket grand-total {{statusclass}}'><div class='bl-cl'>{{rowTitle}}</div><div class='bl-cl rs'>{{percentage}} %</div><div class='bl-cl rs'>{{numberCovered}}/{{totalSmts}}</div>"+( hasBranchTracking ? "<div class='bl-cl rs'>{{passedBranches}}/{{totalBranches}}</div>" : "" ) + "<div style='clear:both;'></div></div>";
14 14
15 15 function blanket_toggleSource(id) {
16 16 var element = document.getElementById(id);
@@ -154,8 +154,17 @@ blanket.defaultReporter = function(coverage){
154 154 totalSmts: 0,
155 155 numberOfFilesCovered: 0,
156 156 passedBranches: 0,
157   - totalBranches: 0
  157 + totalBranches: 0,
  158 + moduleTotalStatements : {},
  159 + moduleTotalCoveredStatements : {},
  160 + moduleTotalBranches : {},
  161 + moduleTotalCoveredBranches : {}
158 162 };
  163 +
  164 + // check if a data-cover-modulepattern was provided for per-module coverage reporting
  165 + var modulePattern = _blanket.options("modulePattern");
  166 + var modulePatternRegex = ( modulePattern ? new RegExp(modulePattern) : null );
  167 +
159 168 for(var file in files)
160 169 {
161 170 fileNumber++;
@@ -226,6 +235,29 @@ blanket.defaultReporter = function(coverage){
226 235 }
227 236 totals.passedBranches += passedBranches;
228 237 totals.totalBranches += totalBranches;
  238 +
  239 + // if "data-cover-modulepattern" was provided,
  240 + // track totals per module name as well as globally
  241 + if (modulePatternRegex) {
  242 + var moduleName = file.match(modulePatternRegex)[1];
  243 +
  244 + if(!totals.moduleTotalStatements.hasOwnProperty(moduleName)) {
  245 + totals.moduleTotalStatements[moduleName] = 0;
  246 + totals.moduleTotalCoveredStatements[moduleName] = 0;
  247 + }
  248 +
  249 + totals.moduleTotalStatements[moduleName] += totalSmts;
  250 + totals.moduleTotalCoveredStatements[moduleName] += numberOfFilesCovered;
  251 +
  252 + if(!totals.moduleTotalBranches.hasOwnProperty(moduleName)) {
  253 + totals.moduleTotalBranches[moduleName] = 0;
  254 + totals.moduleTotalCoveredBranches[moduleName] = 0;
  255 + }
  256 +
  257 + totals.moduleTotalBranches[moduleName] += totalBranches;
  258 + totals.moduleTotalCoveredBranches[moduleName] += passedBranches;
  259 + }
  260 +
229 261 var result = percentage(numberOfFilesCovered, totalSmts);
230 262
231 263 var output = fileTemplate.replace("{{file}}", file)
@@ -245,16 +277,42 @@ blanket.defaultReporter = function(coverage){
245 277 bodyContent += output;
246 278 }
247 279
248   - var totalPercent = percentage(totals.numberOfFilesCovered, totals.totalSmts);
249   - var statusClass = totalPercent < successRate ? "bl-error" : "bl-success";
250   - var totalsOutput = grandTotalTemplate.replace("{{percentage}}", totalPercent)
251   - .replace("{{numberCovered}}", totals.numberOfFilesCovered)
252   - .replace("{{totalSmts}}", totals.totalSmts)
253   - .replace("{{passedBranches}}", totals.passedBranches)
254   - .replace("{{totalBranches}}", totals.totalBranches)
255   - .replace("{{statusclass}}", statusClass);
  280 + // create temporary function for use by the global totals reporter,
  281 + // as well as the per-module totals reporter
  282 + var createAggregateTotal = function(numSt, numCov, numBranch, numCovBr, moduleName) {
  283 +
  284 + var totalPercent = percentage(numCov, numSt);
  285 + var statusClass = totalPercent < successRate ? "bl-error" : "bl-success";
  286 + var rowTitle = ( moduleName ? "Total for module: " + moduleName : "Global total" );
  287 + var totalsOutput = grandTotalTemplate.replace("{{rowTitle}}", rowTitle)
  288 + .replace("{{percentage}}", totalPercent)
  289 + .replace("{{numberCovered}}", numCov)
  290 + .replace("{{totalSmts}}", numSt)
  291 + .replace("{{passedBranches}}", numCovBr)
  292 + .replace("{{totalBranches}}", numBranch)
  293 + .replace("{{statusclass}}", statusClass);
  294 +
  295 + bodyContent += totalsOutput;
  296 + };
  297 +
  298 + // if "data-cover-modulepattern" was provided,
  299 + // output the per-module totals alongside the global totals
  300 + if (modulePatternRegex) {
  301 + for (var thisModuleName in totals.moduleTotalStatements) {
  302 + if (totals.moduleTotalStatements.hasOwnProperty(thisModuleName)) {
  303 +
  304 + var moduleTotalSt = totals.moduleTotalStatements[thisModuleName];
  305 + var moduleTotalCovSt = totals.moduleTotalCoveredStatements[thisModuleName];
  306 +
  307 + var moduleTotalBr = totals.moduleTotalBranches[thisModuleName];
  308 + var moduleTotalCovBr = totals.moduleTotalCoveredBranches[thisModuleName];
  309 +
  310 + createAggregateTotal(moduleTotalSt, moduleTotalCovSt, moduleTotalBr, moduleTotalCovBr, thisModuleName);
  311 + }
  312 + }
  313 + }
256 314
257   - bodyContent += totalsOutput;
  315 + createAggregateTotal(totals.totalSmts, totals.numberOfFilesCovered, totals.totalBranches, totals.passedBranches, null);
258 316 bodyContent += "</div>"; //closing main
259 317
260 318
13 src/reporters/lcov_reporter.js
... ... @@ -1,10 +1,11 @@
1   -define([],function lcov_reporter(){
  1 +//lcov_reporter
  2 +(function (){
2 3 //takes the option: toHTML {boolean}
3   -
  4 +
4 5 var body = document.body;
5 6
6 7 var appendHtml = function ( filename,data,toHTML) {
7   -
  8 +
8 9 var str="";
9 10 str += 'SF:' + filename + '\n';
10 11
@@ -27,8 +28,8 @@ define([],function lcov_reporter(){
27 28 window._$blanket_LCOV = str;
28 29 }
29 30 };
30   -
31   - return function(coverageData,options){
  31 +
  32 + blanket.customReporter=function(coverageData,options){
32 33 var toHTML=true;
33 34 if (typeof options !== 'undefined' && typeof options.toHTML !== 'undefined'){
34 35 toHTML = options.toHTML;
@@ -38,4 +39,4 @@ define([],function lcov_reporter(){
38 39 appendHtml(filename,data,toHTML);
39 40 }
40 41 };
41   -});
  42 +})();
11 src/reporters/simple_json_reporter.js
... ... @@ -1,5 +1,6 @@
1   -define([],function simple_json_reporter(){
2   -
  1 +//simple_json_reporter
  2 +(function (){
  3 +
3 4 var body = document.body;
4 5
5 6 var appendHtml = function (el, str) {
@@ -7,8 +8,8 @@ define([],function simple_json_reporter(){
7 8 div.innerText = str;
8 9 el.appendChild(div);
9 10 };
10   -
11   - return function(coverageData){
  11 +
  12 + blanket.customReporter= function(coverageData){
12 13 appendHtml(body, JSON.stringify(coverageData,null,"\t"));
13 14 };
14   -});
  15 +})();
2  tasks/blanketTests.js
@@ -29,7 +29,7 @@ module.exports = function(grunt) {
29 29 if (!err) {
30 30 grunt.log.write(result+"\n");
31 31 }else{
32   - //grunt.log.write("\nError:"+err);
  32 + grunt.log.write("\nError:"+result);
33 33 done(false);
34 34 }
35 35 next();
1  test/helpers/phantom_qunit_runner.js
@@ -23,6 +23,7 @@ page.onConsoleMessage = function(msg) {
23 23 page.onInitialized = function() {
24 24 page.evaluate(addLogging);
25 25 };
  26 +
26 27 page.open(url, function(status){
27 28 if (status !== "success") {
28 29 console.log("Unable to access network: " + status);
5 test/lib-tests/blanket_test.js
@@ -69,7 +69,6 @@ test( "blanket instrument branch", function() {
69 69 test('get/set options', function(){
70 70 ok(blanket.options("filter") === null,"get filter");
71 71 ok(blanket.options("ignoreScriptError") === false,"get ignore");
72   - ok(blanket.options("orderedLoading") === true,"get ordered");
73 72 ok(blanket.options("existingRequireJS") === false,"get existing");
74 73 ok(blanket.options("reporter") === null,"get reporter");
75 74 ok(blanket.options("loader") === null,"get loader");
@@ -78,7 +77,6 @@ test('get/set options', function(){
78 77 blanket.options({
79 78 filter: "test",
80 79 ignoreScriptError: true,
81   - orderedLoading: false,
82 80 existingRequireJS: true,
83 81 reporter: "test1",
84 82 loader: "test2",
@@ -87,7 +85,6 @@ test('get/set options', function(){
87 85
88 86 ok(blanket.options("filter") === "test","get filter");
89 87 ok(blanket.options("ignoreScriptError") === true,"get ignore");
90   - ok(blanket.options("orderedLoading") === false,"get order");
91 88 ok(blanket.options("existingRequireJS") === true,"get existing");
92 89 ok(blanket.options("reporter") === "test1","get reporter");
93 90 ok(blanket.options("loader") === "test2","get loader");
@@ -95,7 +92,6 @@ test('get/set options', function(){
95 92
96 93 blanket.options("filter",null);
97 94 blanket.options("ignoreScriptError",false);
98   - blanket.options("orderedLoading",true);
99 95 blanket.options("existingRequireJS",false);
100 96 blanket.options("reporter",null);
101 97 blanket.options("loader",null);
@@ -103,7 +99,6 @@ test('get/set options', function(){
103 99
104 100 ok(blanket.options("filter") === null,"get filter");
105 101 ok(blanket.options("ignoreScriptError") === false,"get ignore");
106   - ok(blanket.options("orderedLoading") === true,"get ordered");
107 102 ok(blanket.options("existingRequireJS") === false,"get existing");
108 103 ok(blanket.options("reporter") === null,"get reporter");
109 104 ok(blanket.options("loader") === null,"get loader");
6 test/requirejs/chutzpah.html
@@ -9,10 +9,10 @@
9 9 -->
10 10 <link rel="stylesheet" type="text/css" href="../vendor/qunit.css"/>
11 11 <script type="text/javascript" src="../vendor/qunit.js"></script>
12   -<script type="text/javascript" src="../../src/lib/require.js"></script>
13   - <script type="text/javascript" src="../../dist/qunit/blanket.js" data-cover-flags="ignoreError autoStart"
  12 +<script type="text/javascript" src="../../node_modules/requirejs/require.js"></script>
  13 + <script type="text/javascript" src="../../dist/qunit/blanket.js" data-cover-flags=" autoStart debug"
14 14 data-cover-only="//.*/"
15   - data-cover-never="['vendor/qunit','lib/require','qunit/blanket']"></script>
  15 + data-cover-never="['vendor/qunit','require','qunit/blanket']"></script>
16 16
17 17
18 18 <script type="text/javascript">
2  test/requirejs/require_runner.html
@@ -7,7 +7,7 @@
7 7 <link rel="stylesheet" href="../vendor/qunit.css">
8 8 <script src="../vendor/qunit.js"></script>
9 9 <!-- qunit -->
10   - <script type="text/javascript" src="../../src/lib/require.js"></script>
  10 + <script type="text/javascript" src="../../node_modules/requirejs/require.js"></script>
11 11 <script src="../../dist/qunit/blanket.js"
12 12 data-cover-only="require_sample"></script>