开发者

Ruby: How to pass options to test::unit in 1.9.3

开发者 https://www.devze.com 2023-04-09 03:49 出处:网络
I want to run a test file: # xxx.rb require \'test/unit\'; class XTest < Test::Unit::TestCase; def test_xxx; end; end

I want to run a test file:

# xxx.rb
require 'test/unit'; class XTest < Test::Unit::TestCase; def test_xxx; end; end

Until ruby 1.9.2

ruby -Itest -e "require './xxx.rb'" - -v

did the job, with 1.9.3 I suddenly get:

/usr/local/rvm/rubies/ruby-1.9.3-rc1/lib/ruby/1.9.1/test/unit.rb:167:in
`block in non_options': file not found: - (ArgumentError)

(it tries to load the file '-' which does not exist)

Any ideas how to get the verbose mode back / to pass options to test::unit ?

Co开发者_如何学Crrect output would look like:

Loaded suite -e
Started
test_xxx(XTest): .


Try it with a double-dash:

ruby -Itest -e "require './xxx.rb'" -- -v

Or like this (no dashes, no require):

ruby -Itest xxx.rb -v

To explain, I think that in your example you are using a single dash which commonly means 'use stdin as a file'. You could do this, for example:

cat xxx.rb | ruby -Itest - -v

Double-dashes are used to stop argument parsing and hence pass the -v to test unit. As to why your example with a single dash worked up to 1.9.3... I'm guessing that prior to 1.9.3 ruby wasn't as strict when you specify stdin but don't have anything coming in on stdin (as you don't).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号