Problem with metric-fu

35 views
Skip to first unread message

Fabio Kreusch

unread,
May 16, 2009, 12:26:09 PM5/16/09
to metric_fu
Hello all,

I'm trying to use metric-fu in my project, and have done these steps:

- Installed gem
- Added "require 'metric_fu'" to Rakefile
- Added "config.gem 'jscruggs-metric_fu', :version => '1.0.2', :lib =>
'metric_fu', :source => 'http://gems.github.com'" to environments/
test.rb

When I run "rake metrics:all", I receive this error:

No file to analyze was found. All the files loaded by rcov matched one
of the
following expressions, and were thus ignored:
[/\A\/usr\/lib/,
/\btc_[^.]*.rb/,
/_test\.rb\z/,
/\btest\//,
/\bvendor\//,
/\A\/usr\/lib\/ruby\/gems\/1\.8\/gems\/rcov\-0\.8\.1\.2\.0\/lib\/rcov
\/report\.rb\z/,
/\bvendor\//,
/\bconfig\//,
/\benvironment\//,
/\/gems\//,
/\/Library\//,
/spec/]

You can solve this by doing one or more of the following:
* rename the files not to be ignored so they don't match the above
regexps
* use --include-file to give a list of patterns for files not to be
ignored
* use --exclude-only to give the new list of regexps to match against
* structure your code as follows:
test/test_*.rb for the test cases
lib/**/*.rb for the target source code whose coverage you
want
making sure that the test/test_*.rb files are loading from lib/,
e.g. by
using the -Ilib command-line argument, adding
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
to test/test_*.rb, or running rcov via a Rakefile (read the RDoc
documentation or README.rake in the source distribution).
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require': no such file to load -- test_helper
(LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
from ./test/functional/accounts_controller_test.rb:1
from /usr/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/bin/rcov:554:in
`load'
from /usr/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0/bin/rcov:554
from /usr/bin/rcov:19:in `load'
from /usr/bin/rcov:19
rake aborted!
NaN


I suppose it may not be finding my test files, because it looks like
is searching for test/test_*.rb , and my tests are *_test.rb.

I have tried to set the options on Rakefile so rcov searches the right
test files, but I still got the same error.

Any advices?

Joe Van Dyk

unread,
May 16, 2009, 3:31:59 PM5/16/09
to metric_fu
Same problem here.

Joe

Jake Scruggs

unread,
May 20, 2009, 8:38:25 AM5/20/09
to metr...@googlegroups.com
That is really weird.  I had no idea that rcov was looking for "test/test_*.rb" since I use RSpec.  If you want to get the rest of metric_fu to work while I (or anyone else who wants to) takes a look at this problem, you can leave rcov off the list of metrics like so:

Metric_fu can be customized to your liking by altering the defaults in your Rakefile:

      MetricFu::Configuration.run do |config|
#define which metrics you want to use
config.metrics = [:churn, :saikuro, :stats, :flog, :flay, :reek, :roodi]
end
-Jake

Glenn Rempe

unread,
May 31, 2009, 2:34:16 PM5/31/09
to metric_fu
Same problem. I had to turn off :rcov to resolve temporarily.

I am using shoulda + cucumber on Rails 2.3.2

My setup is based on the following if you want to see what the config/
tests look like:

http://github.com/thoughtbot/suspenders/tree/master

Thanks,

Glenn

On May 20, 5:38 am, Jake Scruggs <jake.scru...@gmail.com> wrote:
> That is really weird.  I had no idea that rcov was looking for
> "test/test_*.rb" since I use RSpec.  If you want to get the rest of
> metric_fu to work while I (or anyone else who wants to) takes a look at this
> problem, you can leave rcov off the list of metrics like so:
>
> Metric_fu can be customized to your liking by altering the defaults in your
> Rakefile:
>
>       MetricFu::Configuration.run do |config|
>         #define which metrics you want to use
>         config.metrics  = [:churn, :saikuro, :stats, :flog, :flay,
> :reek, :roodi]
>     end
>
> -Jake
>

Matías Flores

unread,
Jun 9, 2009, 2:48:27 PM6/9/09
to metric_fu
Today I had the same problem here. I've found that it's not related to
a "test_*" vs "*_test" thing, the default options should work just
fine for that. The real problem was that rcov could not find the
test_helper file when running my tests.

I fixed it by changing the default options in my rakefile:

MetricFu::Configuration.run do |config|
config.rcov[:rcov_opts] << "-Itest"
end

HTH

Matías

> I suppose it may not be finding my test files, because it looks like
> is searching for test/test_*.rb , and my tests are *_test.rb.
>
> I have tried to set the options on Rakefile so rcov searches the right
> test files, but I still got the same error.
>
> Any advices?



Reply all
Reply to author
Forward
0 new messages