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

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.

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.

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs