Feature #1599

ruby test_foo.rb --help do not show help message

Added by okkez _ over 2 years ago. Updated 10 months ago.

[ruby-core:23793]
Status:Closed Start date:06/11/2009
Priority:Normal Due date:
Assignee:Ryan Davis % Done:

0%

Category:lib
Target version:1.9.2

Description

I execute below command.
I think it shows help messages, but execute tests only.

$ ruby test_foo.rb --help

For convenience, I want it to show help messages.

# Why not use optparse library?

History

Updated by Lin Jen-Shin over 2 years ago

Then what should this produce?

$ ruby `which gem` --help

Updated by Roger Pack over 2 years ago

+1
having mini test tests output help information would be great.
-=r

Updated by Akira Tanaka over 2 years ago

help message with --help is good.

But don't use optparse to keeptest system small.

Updated by Yuki Sonoda over 2 years ago

  • Assignee set to Yukihiro Matsumoto

Updated by Yusuke Endoh almost 2 years ago

  • Assignee changed from Yukihiro Matsumoto to Ryan Davis
Hi,

> I execute below command.
> I think it shows help messages, but execute tests only.
>
> $ ruby test_foo.rb --help
>
> For convenience, I want it to show help messages.


Ryan, what do you think about this feature request?


diff --git a/lib/minitest/unit.rb b/lib/minitest/unit.rb
index 1570b7f..67b789a 100644
--- a/lib/minitest/unit.rb
+++ b/lib/minitest/unit.rb
@@ -383,15 +383,25 @@ module MiniTest
     # Top level driver, controls all output and filtering.

     def run args = []
-      @verbose = args.delete('-v')
-
-      filter = if args.first =~ /^(-n|--name)$/ then
-                 args.shift
-                 arg = args.shift
-                 arg =~ /\/(.*)\// ? Regexp.new($1) : arg
-               else
-                 /./ # anything - ^test_ already filtered by #tests
-               end
+      @verbose = false
+
+      filter = /./
+      while arg = args.shift
+        case arg
+        when "-v"
+          @verbose = true
+        when "-n", "--name"
+          arg = args.shift
+          filter =~ /\/(.*)\// ? Regexp.new($1) : arg
+        when "-h", "--help"
+          puts <<END
+usage: ruby #{ $0 }
+  -v                   verbose mode
+  -n, --name PATTERN   filter tests by PATTERN (which is a Regexp or String)
+END
+          exit
+        end
+      end

       @@out.puts "Loaded suite #{$0.sub(/\.rb$/, '')}\nStarted"


-- 
Yusuke Endoh <mame@tsg.ne.jp>

Updated by Ryan Davis almost 2 years ago

On Mar 21, 2010, at 20:00 , Yusuke Endoh wrote:

> Issue #1599 has been updated by Yusuke Endoh.
> 
> Assigned to changed from Yukihiro Matsumoto to Ryan Davis
> 
> Hi,
> 
>> I execute below command.
>> I think it shows help messages, but execute tests only.
>> 
>> $ ruby test_foo.rb --help
>> 
>> For convenience, I want it to show help messages.
> 
> 
> Ryan, what do you think about this feature request?

Sorry I took so long to get back to you.

I've already implemented this in minitest w/ OptionParser. I just released minitest (and a bunch of other stuff) and also imported it into ruby-trunk.

Thanks

Updated by Yuki Sonoda almost 2 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF