Last change
on this file since 19:ab5f65372038 was 19:ab5f65372038, checked in by Borja Lopez <borja@…>, 9 years ago |
Imported latest envjasmine version, the initial import from darcs had the wrong version
|
File size:
1.3 KB
|
Rev | Line | |
---|
[19] | 1 | if (!this.EnvJasmine.coverage) {
|
---|
| 2 | this.EnvJasmine.coverage = {};
|
---|
| 3 | };
|
---|
| 4 |
|
---|
| 5 | EnvJasmine.coverage.writeCoverageResults = function() {
|
---|
| 6 | var coverage = EnvJasmine.jscoverage;
|
---|
| 7 | try {
|
---|
| 8 | // clean coverage object
|
---|
| 9 | EnvJasmine.coverage.cleanCoverageObject(coverage);
|
---|
| 10 |
|
---|
| 11 | // write file
|
---|
| 12 | fstream = new FileWriter(EnvJasmine.coverage.reportJson);
|
---|
| 13 | out = new BufferedWriter(fstream);
|
---|
| 14 | out.write(JSON.stringify(coverage));
|
---|
| 15 |
|
---|
| 16 | //Close the output stream
|
---|
| 17 | out.close();
|
---|
| 18 | } catch (e) {//Catch exception if any
|
---|
| 19 | System.err.println("Error: " + e);
|
---|
| 20 | }
|
---|
| 21 | };
|
---|
| 22 |
|
---|
| 23 | EnvJasmine.coverage.cleanCoverageObject = function(jsonObj) {
|
---|
| 24 | // recursively iterate over the output object
|
---|
| 25 | // we need to remove the toJSON function which is causing JSON.stringify to break
|
---|
| 26 | if ( typeof jsonObj == "object") {
|
---|
| 27 | $.each(jsonObj, function(k, v) {
|
---|
| 28 | if ( typeof v != "undefined") {
|
---|
| 29 | delete v.toJSON;
|
---|
| 30 | // jscover ovrrides this function, so we have to delete it bfore writing the json string.
|
---|
| 31 | }
|
---|
| 32 | EnvJasmine.coverage.cleanCoverageObject(v);
|
---|
| 33 | });
|
---|
| 34 | } // else do nothing
|
---|
| 35 | };
|
---|
| 36 |
|
---|
| 37 | // add functions to envjasmine
|
---|
| 38 | EnvJasmine.addFinallyFunction(EnvJasmine.coverage.writeCoverageResults);
|
---|
| 39 |
|
---|
| 40 | print("EnvJasmine-Coverage Plugin Loaded");
|
---|
Note:
See
TracBrowser
for help on using the repository browser.