Test::Unit::AutoRunner ignores arguments given after -- (representing files holding tests to be executed). I found this when trying to use test/spec. I hesitated between test/unit and optparse when trying to assign the blame, but the following test indicates that it's a bug in test/unit motivated by incomplete documentation in optparse.rb: $ cat optparse-test.rb require 'optparse' foo = false opt = OptionParser.new do |o| o.on("-f", "--foo"){|foo| } end args = %w[blergh -f -- dsf sdf sdf dfg re f] opt.order!(args){|x| p x} puts "Remaining: #{args.inspect}" puts "----" args = %w[blergh -f -- dsf sdf sdf dfg re f] opt.permute!(args) p args $ ruby185-p12 -v optparse-test.rb ruby 1.8.5 (2006-12-25 patchlevel 12) [i686-linux] "blergh" Remaining: ["dsf", "sdf", "sdf", "dfg", "re", "f"] ---- ["blergh", "dsf", "sdf", "sdf", "dfg", "re", "f"] #permute!'s implementation proves that #order! behaves as meant by Nobu, so Test::Unit::AutoRunner is what needs to be fixed. The patch:
Index: lib/optparse.rb =================================================================== --- lib/optparse.rb (revision 11652) +++ lib/optparse.rb (working copy) @@ -1227,10 +1227,11 @@ end # - # Parses command line arguments +argv+ in order. When a block is given, - # each non-option argument is yielded. + # Parses command line arguments +argv+ in order. When a block is given, each + # non-option argument occurring before -- is yielded. Note that non-option + # arguments after -- will not be passed to the block. # - # Returns the rest of +argv+ left unparsed. + # Returns the rest of +argv+ (arguments after --) left unparsed. # def order(*argv, &block) argv = argv[0].dup if argv.size == 1 and Array === argv[0] Index: lib/test/unit/autorunner.rb =================================================================== --- lib/test/unit/autorunner.rb (revision 11652) +++ lib/test/unit/autorunner.rb (working copy) @@ -87,6 +87,7 @@ def process_args(args = ARGV) begin options.order!(args) {|arg| @to_run << arg} + @to_run[0,0] = args rescue OptionParser::ParseError => e puts e puts options
-- Mauricio Fernandez - http://eigenclass.org - singular Ruby