2010-01-14 4 views
2

저는 작업중인 레일스 프로젝트에서 metric-fu를 실행하려고합니다. 메트릭의 rcov 부분을 실행할 때마다 다음과 같이 표시됩니다.Metric-Fu/Rcov "No File to Analyze"

** Invoke metrics:all (first_time) 
** Execute metrics:all 

No file to analyze was found. All the files loaded by rcov matched one of the 
following expressions, and were thus ignored: 
[/\A\/System\/Library\/Frameworks\/Ruby\.framework\/Versions\/1\.8\/usr\/lib/, 
/\btc_[^.]*.rb/, 
/_test\.rb\z/, 
/\btest\//, 
/\bvendor\//, 
/\A\/Library\/Ruby\/Gems\/1\.8\/gems\/rcov\-0\.9\.7\.1\/lib\/rcov\/formatters\/base_formatter\.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). 
rake aborted! 
NaN 
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/float/rounding.rb:19:in `round_without_precision' 
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/float/rounding.rb:19:in `round' 
/Library/Ruby/Gems/1.8/gems/metric_fu-1.2.0/lib/base/generator.rb:135:in `round_to_tenths' 
/Library/Ruby/Gems/1.8/gems/metric_fu-1.2.0/lib/generators/rcov.rb:84:in `to_h' 
/Library/Ruby/Gems/1.8/gems/metric_fu-1.2.0/lib/base/generator.rb:131:in `generate_report' 
/Library/Ruby/Gems/1.8/gems/metric_fu-1.2.0/lib/base/generator.rb:53:in `generate_report' 
/Library/Ruby/Gems/1.8/gems/metric_fu-1.2.0/lib/base/report.rb:54:in `add' 
/Library/Ruby/Gems/1.8/gems/metric_fu-1.2.0/lib/../tasks/metric_fu.rake:6 
/Library/Ruby/Gems/1.8/gems/metric_fu-1.2.0/lib/../tasks/metric_fu.rake:6:in `each' 
/Library/Ruby/Gems/1.8/gems/metric_fu-1.2.0/lib/../tasks/metric_fu.rake:6 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain' 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run' 
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31 
/usr/bin/rake:19:in `load' 
/usr/bin/rake:19 

rcov를 실행하면 동일한 문제가 발생합니다. 그게 도움이된다면 Rspec을 사용하고 TestUnit을 사용하지 않습니다.

+0

rcov를 실행하기위한 레이크 작업은 어떻게 생겼습니까? – BaroqueBobcat

+0

metric-fu로 할 때 http://metric-fu.rubyforge.org/에서 찾은 설정을 사용하고 있습니다 rake 사양을 실행할 때 rcov.opts : rcov에 다음 옵션이 있습니다 : --exclude "사양/*, 보석/* --rails 양쪽 끝의 모든 기본 물건,하지만 같은 결과 –

답변

4

당신이 조각과 경로를 rcov 어떤 디렉토리를 추가 할 수 있습니다 metric_fu 시작하는 레이크를 사용하는 경우 :

begin 
    require 'metric_fu' 
    MetricFu::Configuration.run do |config| 
    config.rcov[:rcov_opts] << "-Ispec" 
    end 
rescue LoadError 
end 

이 차례로 추가되는 옵션을 rcov하는 -Ispec에게 플래그를 추가합니다 'spec'디렉토리를 rcov의 경로에 추가하십시오.

0

그래서 rcov는 "분석 할 파일이 없습니다."라는 메시지를 표시합니다. 문제가 실제로 메시지 아래의 스택 추적 일 때 메시지. rcov의 버전을 업그레이드 할 수 있습니다 (현재 어떤 버전입니까?).

+0

내 보석의 목록을 보여준다 :. rcov (0.9.7.1) –

1

"test"디렉토리를 제거하고 "--include spec/spec_helper.rb"를 Rcov 구성 해시에 추가했습니다. 필자는 spec helper를 특별히 지적해야하고 test 디렉토리를 제거해야한다고 생각합니다. 그렇지 않으면 rspov가 아닌 testunit에서 rcov를 실행하려고 시도합니다.

희망이 있으면 다른 사람들에게 도움이됩니다.

관련 문제