Skip to content

TestTask fails with -n but works with --name #490

@akostadinov

Description

@akostadinov

Just noticed an issue with TestTask that it doesn't properly recognize the -n option as a shorthand of --n as documented:

$ bundle exec rake test TESTOPTS='--help'
...
    -n, --name=NAME                  Runs tests matching NAME.
                                     Use '/PATTERN/' for NAME to use regular expression.
                                     Regular expression accepts options.
                                     Example: '/taRget/i' matches 'target' and 'TARGET'
...

It works when I run:

🐚 bundle exec rake test TEST=test/gnuplot_printer_test.rb TESTOPTS='--name=/write/'
/home/user/.asdf/installs/ruby/3.2.2/bin/ruby -w -I"lib" /home/user/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb "test/gnuplot_printer_test.rb" --name=/write/
Loaded suite /home/user/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/rake_test_loader
Started
.
Finished in 0.001170365 seconds.
--------------------------------------------------------------------------------
1 tests, 4 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
--------------------------------------------------------------------------------

But it fails when I use a shorthand:

🐚 bundle exec rake test TEST=test/gnuplot_printer_test.rb TESTOPTS='-n /write/'
/home/user/.asdf/installs/ruby/3.2.2/bin/ruby -w -I"lib" /home/user/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb "test/gnuplot_printer_test.rb" -n /write/
File does not exist: /write
rake aborted!
Command failed with status (1): [ruby -w -I"lib" /home/user/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb "test/gnuplot_printer_test.rb" -n /write/]
/home/user/.asdf/installs/ruby/3.2.2/bin/bundle:25:in `load'
/home/user/.asdf/installs/ruby/3.2.2/bin/bundle:25:in `<main>'
Tasks: TOP => test
(See full trace by running task with --trace)

In case that matters, using Test::Unit 3.5.7 framework.

-- rake, version 13.0.6

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