lib/turn/command.rb in turn-0.8.1 vs lib/turn/command.rb in turn-0.8.2

- old
+ new

@@ -1,9 +1,9 @@ require 'optparse' -require 'turn/controller' module Turn + require 'turn/controller' # Turn - Pretty Unit Test Runner for Ruby # # SYNOPSIS # turn [OPTIONS] [RUN MODE] [OUTPUT MODE] [test globs...] @@ -44,10 +44,13 @@ attr :live # Only run tests matching this pattern. attr :pattern + # Only run testcases matching this pattern. + attr :matchcase + # List of paths to add to $LOAD_PATH attr :loadpath # Libraries to require before running tests. attr :requires @@ -64,10 +67,11 @@ # def initialize @live = nil @log = nil @pattern = nil + @matchcase = nil @loadpath = [] @requires = [] @runmode = nil @outmode = nil @framework = RUBY_VERSION >= "1.9" ? :minitest : :testunit @@ -93,13 +97,25 @@ opts.on('-r', '--require=LIBS', "require libraries") do |lib| @requires.concat(lib.split(':')) end opts.on('-n', '--name=PATTERN', "only run tests that match PATTERN") do |pattern| - @pattern = Regexp.new(pattern, Regexp::IGNORECASE) + if pattern =~ /\/(.*)\// + @pattern = Regexp.new($1) + else + @pattern = Regexp.new(pattern, Regexp::IGNORECASE) + end end + opts.on('-t', '--testcase=PATTERN', "only run testcases that match PATTERN") do |pattern| + if pattern =~ /\/(.*)\// + @matchcase = Regexp.new($1) + else + @matchcase = Regexp.new(pattern, Regexp::IGNORECASE) + end + end + opts.on('-m', '--minitest', "Force use of MiniTest framework") do @framework = :minitest end # Turn does not support Test::Unit 2.0+ @@ -167,10 +183,15 @@ opts.on('--debug', "turn debug mode on") do $VERBOSE = true $DEBUG = true end + opts.on_tail('--version', "display version") do + puts VERSION + exit + end + opts.on_tail('--help', '-h', "display this help information") do puts opts exit end end @@ -191,9 +212,10 @@ c.requires = requires c.tests = tests c.runmode = runmode c.format = outmode c.pattern = pattern + c.matchcase = matchcase c.framework = framework end result = controller.start