2016-04-28 108 views
0

當我嘗試使用rake在ruby上運行一些基本的單元測試時,它似乎會在ruby解釋器上啓用調試。這最終導致我在STDOUT中看到大量的警告消息。我不知道爲什麼會發生這種情況,是否應該如此?Ruby Rake - 默認運行Ruby -w?

D:\dev\git_repos\app_folder>ruby -v 
ruby 2.0.0p647 (2015-08-18) [i386-mingw32] 

D:\dev\git_repos\app_folder>rake test TEST=test/midrange_portal_test.rb 

像4頁的警告

輸出,使我相信調試翻起:

Command failed with status (2): [ruby -w -I"lib;test" - 
I"D:/apps/Ruby200/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib" 
"D:/apps/Ruby200/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/rake_test_loader.rb" "test/midrange_portal_test.rb" ] 

D:\dev\git_repos\app_folder>gem environment 
RubyGems Environment: 
    - RUBYGEMS VERSION: 2.0.14.1 
    - RUBY VERSION: 2.0.0 (2015-08-18 patchlevel 647) [i386-mingw32] 
    - INSTALLATION DIRECTORY: D:/apps/Ruby200/lib/ruby/gems/2.0.0 
    - RUBY EXECUTABLE: D:/apps/Ruby200/bin/ruby.exe 
    - EXECUTABLE DIRECTORY: D:/apps/Ruby200/bin 
    - RUBYGEMS PLATFORMS: 
    - ruby 
    - x86-mingw32 
    - GEM PATHS: 
    - D:/apps/Ruby200/lib/ruby/gems/2.0.0 
    - H:/.gem/ruby/2.0.0 
    - GEM CONFIGURATION: 
    - :update_sources => true 
    - :verbose => true 
    - :backtrace => false 
    - :bulk_threshold => 1000 
    - REMOTE SOURCES: 
    - https://rubygems.org/ 

通知命令是如何 「紅寶石-w」。我不知道爲什麼它默認這個級別的調試?任何幫助將不勝感激,因爲我很難過。

回答

0

所以經過大量的挖掘後發現rake im的版本默認使用運行ruby和-w標誌。如果您在/gems/rake-11.1.2/lib/rake/testtask.rb看那裏是一個布爾值,這臺紅寶石警告標誌:

def initialize(name=:test) 
    @name = name 
    @libs = ["lib"] 
    @pattern = nil 
    @options = nil 
    @test_files = nil 
    @verbose = false 
    @warning = true <-------------------------- 
    @loader = :rake 
    @ruby_opts = [] 
    @description = "Run tests" + (@name == :test ? "" : " for #{@name}") 
    yield self if block_given? 
    @pattern = 'test/test*.rb' if @pattern.nil? && @test_files.nil? 
    define 
end 

您可以猴補丁此將其關閉,但在所有誠實它可能只是一個好主意,離開它,只是修復你的警告。在我的情況下,我正在處理大量的遺留代碼,這些代碼只是每隔一段時間更新一次,所以不值得。