In Ruby 1.9 Test::Unit::TestCase parse ARGV differently

O

Oliver Peng

After upgrading to Ruby 1.9, I found that class Test::Unit::TestCase
parse ARGV parameters in different way. Here is the sample code:

require 'test/unit'

class Test_Main < Test::Unit::TestCase

def test1
puts "ARGV[0] = %s" % ARGV[0]
puts "ARGV[1] = %s" % ARGV[1]
puts "ARGV[2] = %s" % ARGV[2]
end

end

On Ruby 1.8:

ruby ./test.rb -- a b c
Loaded suite ./test
Started
ARGV[0] = a
ARGV[1] = b
ARGV[2] = c

On Ruby 1.9:

ruby ./test.rb -- a b c
Loaded suite ./test
Started
ARGV[0] = --
ARGV[1] = a
ARGV[2] = b

Can anyone explain what happened and what is the best way to work around
this?

Thanks.
 
O

Oliver Peng

Find the reason. In Ruby 1.9, it uses new Unit Test framework
MiniTest::Unit to replace Test::Unit. They also added a compatibility
layer to MiniTest. But it looks that it doesn't work well because
parsing parameter is such an important logic for calling test code and
now it is not compatible.

It is impossible for me to change tons of Make file to be compatible
with new Unit Test framework and finally I have installed test-unit gem
to get the original Test::Unit framework back.
 
R

Roger Pack

On Ruby 1.8:

ruby ./test.rb -- a b c
Loaded suite ./test
Started
ARGV[0] = a
ARGV[1] = b
ARGV[2] = c

On Ruby 1.9:

ruby ./test.rb -- a b c
Loaded suite ./test
Started
ARGV[0] = --
ARGV[1] = a
ARGV[2] = b

Can anyone explain what happened and what is the best way to work around
this?

File a bug with minitest?
-r
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top