dylanb / gulp-coverage

Gulp coverage reporting for Node.js that is independent of the test runner
MIT License
60 stars 12 forks source link

Not working on Windows #10

Closed adam-lynch closed 10 years ago

adam-lynch commented 10 years ago

Ok, this is working great for me on Mac / Linux but not Windows. It seems the stats aren't being gathered. enforce doesn't fail when it should and report isn't showing any code or stats.

I know this isn't a problem with a missing dependency or something like that because it's being tested with Travis. See build #9 where I set each of the enforce options to 100 to deliberately fail the build.

I just tried pulling the latest revision of this project (from GitHub) and running the tests. I got this:

stream.js:94
    throw er; // Unhandled stream error in pipe.
          ^
TypeError: Cannot call method 'stats' of undefined
    at Suite.<anonymous> (C:\Users\Digital\Code\GitHub\gulp-coverage\test\cover.js:95:50)
    at context.describe.context.context (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\interfaces\bdd.js:73:10)
    at Suite.<anonymous> (C:\Users\Digital\Code\GitHub\gulp-coverage\test\cover.js:87:5)
    at context.describe.context.context (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\interfaces\bdd.js:73:10)
    at Object.<anonymous> (C:\Users\Digital\Code\GitHub\gulp-coverage\test\cover.js:23:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
npm ERR! weird error 8
npm ERR! not ok code 0
dylanb commented 10 years ago

I will not be able to use a Windows machine until Saturday due to travel but will address this then

adam-lynch commented 10 years ago

:+1:

dylanb commented 10 years ago

@adam-lynch I have pushed a change to this repo that fixes the Windows issues. Do you want to clone and test against your repo before I mark this as fixed?

adam-lynch commented 10 years ago

@dylanb that would be good, if you don't mind.

Regards, Adam Lynch

On 13 February 2014 19:02, Dylan Barrell notifications@github.com wrote:

@adam-lynch https://github.com/adam-lynch I have pushed a change to this repo that fixes the Windows issues. Do you want to clone and test against your repo before I mark this as fixed?

Reply to this email directly or view it on GitHubhttps://github.com/dylanb/gulp-coverage/issues/10#issuecomment-35012885 .

dylanb commented 10 years ago

@adam-lynch - have you been able to test? All my testing on Windows indicates it is equivalent now to the *nix platforms.

adam-lynch commented 10 years ago

@dylanb I can test this tomorrow morning (GMT)

adam-lynch commented 10 years ago

Ok @dylanb it works now I think. I pulled the latest changes from this repo and the tests ran without error. Same goes for my project.

One thing that probably isn't a problem is that there's an error thrown but not caught.

gulp test

[gulp] Using file C:\Users\Digital\Code\GitHub\gulp-coverage\gulpfile.js [gulp] Working directory changed to C:\Users\Digital\Code\GitHub\gulp-coverage [gulp] Running 'test'... [gulp] Finished 'test' in 3.29 ms

cover.js cover V cover.init() will create the coverdata directory V cover.init() will create the .coverrun file V cover.init() will put the run directory into the .coverrun file V cover.init() will remove prior run directories V cover.init() will remove prior run directories coverInst V will cause the require function to instrument the file V will cause the data to be collected when the instrumented file is executed (112ms) coverInst.coverageData[filename].stats() V will return the correct number of covered lines V will return the correct number of code lines V will return the correct number of covered statements V will return the correct number of statements V will return the correct number of covered blocks V will return the correct number of blocks V will return the lines of code as an array V will return the code correctly V will return the correct lineDetails sparse array V will return the correct count for lines that were not covered V will return the correct count for lines that are blocks around other code V will return the correct line and position information for the statements V will return the correct coverage count for the covered statements V will return the correct coverage count for the uncovered statements

gulp-coverage instrument

.

1 passing (158ms)

 1) should instrument and collect data
  V should throw if passed a real stream 
report
  V should throw if passed a real stream 

.

1 passing (117ms)

 V should create an HTML report (413ms)

.

1 passing (131ms)

 V will send the coverage data through as a JSON structure (210ms)
gather
  V should throw if passed a real stream 

.

1 passing (102ms)

 V will send the coverage data through as a JSON structure (113ms)
enforce
  V should throw if not passed the correct data 
  V will emit an error if the statement coverage is below the appropriate threshold 
  V will emit an error if the line coverage is below the appropriate threshold 
  V will emit an error if the block coverage is below the appropriate threshold 
format
  V should throw if not passed the correct data 

.

1 passing (209ms)

 V will add a "contents" item to the stream object (291ms)

.

1 passing (125ms)

 V will add a "contents" item to the stream object in JSON format if asked (136ms)

.

1 passing (100ms)

 V will give the output file the name passed into the options (169ms)

.

1 passing (229ms)

 V can be chained with "enforce" (295ms)

36 passing (2s) 1 failing

1) gulp-coverage instrument should instrument and collect data: Uncaught AssertionError: false == true at Transform._flush (C:/Users/Digital/Code/GitHub/gulp-coverage/test/gulp-coverage.js:64:24) at Transform. (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\through2\node_modules\readable-stream\lib_stream_transform.js:130:12) at Transform.g (events.js:175:14) at Transform.EventEmitter.emit (events.js:117:20) at finishMaybe (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\through2\node_modules\readable-stream\lib_stream_writable.js:356:12) at endWritable (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\through2\node_modules\readable-stream\lib_stream_writable.js:363:3) at Transform.Writable.end (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\through2\node_modules\readable-stream\lib_stream_writable.js:341:5) at Transform.onend (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\through2\node_modules\readable-stream\lib_stream_readable.js:486:10) at Transform.g (events.js:175:14) at Transform.EventEmitter.emit (events.js:117:20)

events.js:72 throw er; // Unhandled 'error' event ^ [←[32mgulp←[39m] Error in plugin '←[36mgulp-mocha←[39m': 1 test failed. at Transform. (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\index.js:23:25) at Runner. (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runner.js:577:5) at Runner.EventEmitter.emit (events.js:117:20) at C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runner.js:584:10 at C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runner.js:518:7 at next (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runner.js:247:23) at Object._onImmediate (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runner.js:276:5) at processImmediate as _immediateCallback npm ERR! weird error 8 npm ERR! not ok code 0

dylanb commented 10 years ago

ok, I found some problems in the tests that relate to path construction. I have committed a fix, can you try one more time?

adam-lynch commented 10 years ago

Didn't get a chance. Will tomorrow.

dylanb commented 10 years ago

@adam-lynch can we close this?

adam-lynch commented 10 years ago

I just pulled the latest and ran the tests with one forced failure. It seems to me nothing has changed. Like I said earlier though, I'm not sure if this is even a problem.

C:\Users\Digital\Code\GitHub\gulp-coverage>npm test

gulp-coverage@0.0.18 test C:\Users\Digital\Code\GitHub\gulp-coverage gulp test

[gulp] Using file C:\Users\Digital\Code\GitHub\gulp-coverage\gulpfile.js [gulp] Working directory changed to C:\Users\Digital\Code\GitHub\gulp-coverage [gulp] Running 'test'... [gulp] Finished 'test' in 3.49 ms

cover.js cover V cover.init() will create the coverdata directory V cover.init() will create the .coverrun file V cover.init() will put the run directory into the .coverrun file V cover.init() will remove prior run directories V cover.init() will remove prior run directories coverInst V will cause the require function to instrument the file V will cause the data to be collected when the instrumented file is executed (123ms) coverInst.coverageData[filename].stats() V will return the correct number of covered lines V will return the correct number of code lines V will return the correct number of covered statements 1) will return the correct number of statements V will return the correct number of covered blocks V will return the correct number of blocks V will return the lines of code as an array V will return the code correctly V will return the correct lineDetails sparse array V will return the correct count for lines that were not covered V will return the correct count for lines that are blocks around other code V will return the correct line and position information for the statements V will return the correct coverage count for the covered statements V will return the correct coverage count for the uncovered statements

gulp-coverage instrument

.

1 passing (184ms)

 V should instrument and collect data (197ms)
  V should throw if passed a real stream 
report
  V should throw if passed a real stream 

.

1 passing (152ms)

 V should create an HTML report (428ms)

.

1 passing (111ms)

 V will send the coverage data through as a JSON structure (182ms)
gather
  V should throw if passed a real stream 

.

1 passing (121ms)

 V will send the coverage data through as a JSON structure (130ms)
enforce
  V should throw if not passed the correct data 
  V will emit an error if the statement coverage is below the appropriate threshold 
  V will emit an error if the line coverage is below the appropriate threshold 
  V will emit an error if the block coverage is below the appropriate threshold 
format
  V should throw if not passed the correct data 

.

1 passing (128ms)

 V will add a "contents" item to the stream object (194ms)

.

1 passing (95ms)

 V will add a "contents" item to the stream object in JSON format if asked (106ms)

.

1 passing (131ms)

 V will give the output file the name passed into the options (197ms)

.

1 passing (97ms)

 V can be chained with "enforce" (157ms)

36 passing (2s) 1 failing

1) cover.js coverInst.coverageData[filename].stats() will return the correct number of statements: AssertionError: 13 == 14 at Context. (C:\Users\Digital\Code\GitHub\gulp-coverage\test\cover.js:120:20) at Test.Runnable.run (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runnable.js:221:32) at Runner.runTest (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runner.js:374:10) at C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runner.js:452:12 at next (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runner.js:299:14) at C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runner.js:309:7 at next (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runner.js:247:23) at Object._onImmediate (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runner.js:276:5) at processImmediate as _immediateCallback

events.js:72 throw er; // Unhandled 'error' event ^ [←[32mgulp←[39m] Error in plugin '←[36mgulp-mocha←[39m': 1 test failed. at Transform. (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\index.js:23:25) at Runner. (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runner.js:577:5) at Runner.EventEmitter.emit (events.js:117:20) at C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runner.js:584:10 at C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runner.js:518:7 at next (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runner.js:247:23) at Object._onImmediate (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\runner.js:276:5) at processImmediate as _immediateCallback npm ERR! weird error 8 npm ERR! not ok code 0

dylanb commented 10 years ago

I am going to close the Windows issue and open another one to look at this exceptions specifcially