Question

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 ?

Correct output would look like:

Loaded suite -e
Started
test_xxx(XTest): .
Was it helpful?

Solution

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top