gotwarlost / istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k stars 786 forks source link

Coverage filename is incorrect #156

Closed akinnee closed 9 years ago

akinnee commented 10 years ago

After generating some coverage reports for one of my Backbone plugins, the name of the file that istanbul generates is ckbone.rpc2.js.html when it should be backbone.rpc2.js.html. I have no idea why the first 2 characters are being cut off. The file name reported in coverage/index.html is also wrong.

Screenshots: https://www.dropbox.com/s/mmgl9stpfr4i36p/Screenshot%202014-02-19%2012.53.56.png https://www.dropbox.com/s/15o57djc97fys38/Screenshot%202014-02-19%2012.54.11.png

gotwarlost commented 10 years ago

on windows? or some other OS?

akinnee commented 10 years ago

OSX Mavericks

gotwarlost commented 10 years ago

are you sure there are no control characters in the filename? I'm at a complete loss and need some more data to debug - thing is I don't even know what to ask for!

davidlinse commented 10 years ago

@gotwarlost I had a short code-review an my first thought was it could be some issue with an regex and \b .. but afaikt everything looks fine.. Sadly i'm running on 10.6.x and 10.7.x so i probably can't reproduce the issue, but i'll try to give it a shot these days..

regards ~david

akinnee commented 10 years ago

The file name is exactly backbone.rpc2.js, and the spec file is backbone.rpc2_spec.js. I'm using grunt-contrib-jasmine-istanbul to make a runner and run istanbul cover, so I'll admit it could actually be an issue with that.

gotwarlost commented 10 years ago

The easiest way for me to debug this is if you create a structurally similar github repo that exhibits the same problem on your box but without the code you want to keep to yourself. Is it possible you could do that?

akinnee commented 10 years ago

Actually you can check that project out to this specific commit and run grunt. (make sure you npm install and have grunt install globally) https://github.com/akinnee/Backbone.RPC2/commit/d743e04f3ce7f29f861c34d5c958b5df73e1bca5

I have since removed grunt-contrib-jasmine-istanbul since it wasn't working right, but I'd like to add it back if I can get it working right (in addition to this naming problem, it would also hang and never finish).

davidlinse commented 10 years ago

I poked around a bit and "must" confirm the issue.

Some setup details:

$ git log --online -n1 #=> d743e04 started generating code coverage reports
$ node --version #=> v0.11.12-pre

Could only have a quick look but could it be an issue in the lib/util/*-writer.js files ?

~david

akinnee commented 10 years ago

Were you able to reproduce the issue then? Those writer files are just part of whatever comes with the node modules my project depends on.

gotwarlost commented 10 years ago

Sorry, I haven't had a chance to look at it. Things are crazy at work. I'll get to it soon.

akinnee commented 10 years ago

No problem! I was just wondering if @davidlinse's response meant he was able to reproduce the issue.

davidlinse commented 10 years ago

@akinnee sorry, thought i was clear, but yes, i had the same behavior..

first two characters were stripped from the filename of the written report.

akinnee commented 10 years ago

Thanks so much for confirming that @davidlinse.

gotwarlost commented 10 years ago

Can you tell me how to produce coverage reports? I checked out that commit ran npm install, npm install -g grunt-cli and grunt but I couldn't find the lcov-report/ directory anywhere.

(sorry I'm not a grunt/ jasmine user myself so I don't know those tools very well)

akinnee commented 10 years ago

Running the default grunt task will generate istanbul output in backbone.rpc2/coverage/.

Swatinem commented 10 years ago

Hm, I also have the same problem, simply using istanbul report with a coverage.json.

Swatinem commented 10 years ago

Just tried something: If I use relative filenames, the report filename misses the first 2 chars, also the "All Files" link is wrong, it takes me up into the parent dir. Using absolute filenames, it works just fine.

It seems like with a relative filename, it treats it wrongly as a directory?

gotwarlost commented 10 years ago

Please try istanbul@0.2.5 and see if it fixes your problem. Close the issue if it does :)

Thanks for the diagnosis and the patch!

gotwarlost commented 10 years ago

Please do not use v0.2.5 - it is broken. I have reverted my bad fix for this in v0.2.6

akinnee commented 10 years ago

Thanks for your effort. Do you think it's fixed in 0.2.6, or should I wait for a different fix?