Skip to content

[0.7.0.dev] TESTOPT not working as expected anymore #93

Closed
@Earlopain

Description

@Earlopain

Hi,

with the changes to 0.7.0.dev, ruby-head has picked it up and CI started to fail when TESTOPT is specified. With this simple project structure:

# Rakefile
require "rake/testtask"
task default: %i[test]

Rake::TestTask.new(:test) do |t|
  t.test_files = FileList["test.rb"]
end
# Gemfile
source 'https://rubygems.org'

gem 'test-unit'
gem 'rake'
# test.rb
require "test/unit"

class FooTest < Test::Unit::TestCase
  def test_foo
    assert true
  end
end

Executing rake with TESTOPT=-v used to work and print the following:

$ TESTOPT=-v bundle exec rake
Loaded suite /home/user/.rbenv/versions/3.4.2/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/rake_test_loader
Started
FooTest: 
  test_foo:                                                                                                                             .: (0.000244)

Finished in 0.000784639 seconds.
----------------------------------------------------------------------------------------------------------------------------------------------------------
1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
----------------------------------------------------------------------------------------------------------------------------------------------------------
1274.47 tests/s, 1274.47 assertions/s

Now, when using optparse from master the following is printed:

$ TESTOPT=-v bundle exec rake
invalid argument: -v 
Test::Unit automatic runner.
Usage: /home/user/.rbenv/versions/3.4.2/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb [options] [-- untouched arguments]
    -r, --runner=RUNNER              Use the given RUNNER.
                                     (c[onsole], e[macs], x[ml])
        (more available options)
    -h, --help                       Display this help.

Deprecated options:
        --console                    Console runner (use --runner).

rake aborted!
Command failed with status (1)
/home/user/.rbenv/versions/3.4.2/bin/bundle:25:in 'Kernel#load'
/home/user/.rbenv/versions/3.4.2/bin/bundle:25:in '<main>'
Tasks: TOP => default => test
(See full trace by running task with --trace)

I have bisected it to the following commit: 050a87d (#91)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions