Closed tpbowden closed 10 years ago
Hmmm. Your setup has a lot to do with that. Technically speaking there are two phases on coverage. This may help you track down why, and hopefully you can share what you find.
First, the files have to be instrumented, and this happens with a layer that hooks into sprockets (technically rack, but also sprockets). Because of the nature of how complex sprockets is, and how heavily it caches files, this is hard.
After a file is instrumented, when it's then "run", and code is executed the instrumentation code builds up an object with information about methods, ifs, etc.
That object is then passed back to the server, and teaspoon routes that though eventually to the resolve_coverage method.
If you want to spend some time on it, it would be appreciated. First check that the js files being loaded in the browser are being instrumented. The easiest way to do that is to console.log a function def as a string. If it looks normal it's not being instrumented (at least I think).
Bonus points, figure out why it's not being instrumented. :)
Just spent an hour or so trying to figure it out. The only real difference I can see so far is that when running rake
, Rails.application.assets
is an instance of Sprockets::Index
and when running rake teaspoon
it is an instance of Sprockets::Environment
which is the class in which the module Teaspoon::SprocketsInstrumentation
is injected into. I'll probably try see if that is the problem some time tomorrow.
Ok I can confirm that adding Sprockets::Index.send(:include, Teaspoon::SprocketsInstrumentation)
to
engine.rb fixes the problem, going to see if there's a cleaner solution now.
I've created a pull request here #262
Thanks again.
I've been trying to get coverage to work with my default Rake task but it just won't run. It works fine from the teaspoon command and when I run rake teaspoon, but for some reason when it's called from the default rake task the coverage gets ignored.
My default rake task looks like this:
And after inspecting the data passed into resolve_coverage in runner.rb it seems that the coverage data is coming out as nil.