Sam and Daniel -- Thanks very much. Extending --name does seem like a better route. This would certainly address all of my concerns at the moment. Awesome. jon Daniel Berger wrote: > Sam Roberts wrote: > > <snip> > >> >> One question, could the syntax of --name be extended, so if there is a # >> or a :: in it is referring to a specific test name in a specific test >> suite? I think it would be useful to just have a single option, a bit >> like rdoc, if it is specific enough it will run one test, if not it will >> run multiple. Just a thought. >> >> Thanks, >> Sam > > Hm, good idea, so I've attached a patch that does that. :) > > Note that it only works on strings passed to -n, not regular expressions. > > Anyway, given the following test file: > > # ts_all.rb > require 'test/unit' > > class Foo > def stuff > "foo" > end > end > > class Bar > def stuff > "bar" > end > end > > class TC_Foo < Test::Unit::TestCase > def setup > @foo = Foo.new > end > > def test_stuff > assert_equal("foo", @foo.stuff) > end > > def teardown > @foo = nil > end > end > > class TC_Bar < Test::Unit::TestCase > def setup > @bar = Bar.new > end > > def test_stuff > assert_equal("bar", @bar.stuff) > assert_equal(1,1) > end > > def teardown > @bar = nil > end > end > > You get these results: > > # Runs all tests that match 'test_stuff' > >ruby tstest.rb -n test_stuff > Loaded suite tstest > Started > .. > Finished in 0.002937 seconds. > > 2 tests, 3 assertions, 0 failures, 0 errors > > # Only runs test_stuff from TC_Bar > >ruby tstest.rb -n TC_Bar#test_stuff > Loaded suite tstest > Started > . > Finished in 0.002202 seconds. > > 1 tests, 2 assertions, 0 failures, 0 errors > > # Only runs test_stuff from TC_Foo > >ruby tstest.rb -n TC_Foo#test_stuff > Loaded suite tstest > Started > . > Finished in 0.002114 seconds. > > 1 tests, 1 assertions, 0 failures, 0 errors > > Enjoy! > > Dan > > > This communication is the property of Qwest and may contain confidential or > privileged information. Unauthorized use of this communication is > strictly prohibited and may be unlawful. If you have received this > communication in error, please immediately notify the sender by reply > e-mail and destroy all copies of the communication and any attachments. > > > ------------------------------------------------------------------------ > > --- autorunner.orig Thu Jul 13 12:50:03 2006 > +++ autorunner.rb Thu Jul 13 13:14:38 2006 > @@ -133,11 +133,23 @@ > "Runs tests matching NAME.", > "(patterns may be used).") do |n| > n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n) > + > case n > when Regexp > - @filters << proc{|t| n =~ t.method_name ? true : nil} > + @filters << proc{ |t| > + n =~ t.method_name ? true : nil > + } > else > - @filters << proc{|t| n == t.method_name ? true : nil} > + if n =~ /#/ > + klass, n = n.split('#') > + end > + @filters << proc{ |t| > + if klass > + klass == t.class.to_s && n == t.method_name ? true : nil > + else > + n == t.method_name ? true : nil > + end > + } > end > end >