Permalink
Browse files

improve .autotest

  • Loading branch information...
1 parent 79c1cb5 commit 50e4705a410c24057295525422a87a6d6d28ee50 Sven Fuchs committed Jan 20, 2010
Showing with 8 additions and 2 deletions.
  1. +1 −1 .autotest
  2. +7 −1 test/test_autotest.rb
View
2 .autotest
@@ -3,7 +3,7 @@
require 'test/test_autotest'
Autotest.add_hook :initialize do |config|
- config.add_mapping(%r(^lib\/.*rb$), true) do |filename, _|
+ config.add_mapping(%r(.*rb$), true) do |filename, _|
tests_for(filename)
end
end
View
8 test/test_autotest.rb
@@ -7,6 +7,8 @@ def tests_for(filename)
"test/#{dir}/{#{base},#{base}/**/*}_test.rb"
when %r(lib/cldr/.*\.rb)
"test/" + filename.gsub('lib/cldr/', '').gsub(/\.rb/, '_test.rb')
+ when %r(^test/.*_test\.rb)
+ filename
end
pattern ? Dir[pattern.gsub('//', '/')] : []
end
@@ -15,10 +17,14 @@ def tests_for(filename)
require 'test/unit'
class TestAutotestMatching < Test::Unit::TestCase
- define_method :"test: works" do
+ define_method :"test: default mapping for library files" do
assert tests_for("lib/cldr/format/date.rb").all? { |file| file =~ /date_test.rb/ }
assert tests_for("lib/cldr/format/decimal/fraction.rb").all? { |file| file =~ /fraction_test.rb/ }
assert tests_for("lib/cldr/format/decimal/base.rb").all? { |file| file =~ /decimal/ }
end
+
+ define_method :"test: default mapping for test files" do
+ assert_equal ["test/export_test.rb"], tests_for("test/export_test.rb")
+ end
end
end

0 comments on commit 50e4705

Please sign in to comment.