Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Another fix for mu_pp_for_diff on machines with really wide addresses.

Fixed _run_suite's method filter to allow for method-only matches to work again.
Fixed filter to work with strings again.

[git-p4: depot-paths = "//src/minitest/dev/": change = 8163]
  • Loading branch information...
commit a6564d183cf5934460dcc07d3e021831286cc4ef 1 parent b5a48b0
@zenspider zenspider authored
Showing with 43 additions and 9 deletions.
  1. +3 −2 lib/minitest/unit.rb
  2. +40 −7 test/minitest/test_minitest_unit.rb
View
5 lib/minitest/unit.rb
@@ -173,7 +173,7 @@ def mu_pp obj
# uses mu_pp to do the first pass and then cleans it up.
def mu_pp_for_diff obj
- mu_pp(obj).gsub(/\\n/, "\n").gsub(/:0x[a-f0-9]{4,12}/m, ':0xXXXXXX')
+ mu_pp(obj).gsub(/\\n/, "\n").gsub(/:0x[a-fA-F0-9]{4,}/m, ':0xXXXXXX')
end
def _assertions= n # :nodoc:
@@ -909,8 +909,9 @@ def _run_suite suite, type
filter = Regexp.new $1 if filter =~ /\/(.*)\//
all_test_methods = suite.send "#{type}_methods"
+
filtered_test_methods = all_test_methods.find_all { |m|
- "#{suite}##{m}" =~ filter
+ filter === m || filter === "#{suite}##{m}"
}
assertions = filtered_test_methods.map { |method|
View
47 test/minitest/test_minitest_unit.rb
@@ -389,21 +389,30 @@ def test_failure
assert_report expected, %w[--name /some|thing/ --seed 42]
end
- def test_run_filtered_including_suite_name
+ def assert_filtering name, expected, a = false
+ args = %W[--name #{name} --seed 42]
+
alpha = Class.new MiniTest::Unit::TestCase do
- def test_something
- assert false
+ define_method :test_something do
+ assert a
end
end
- self.class.const_set(:Alpha, alpha)
+ Object.const_set(:Alpha, alpha)
beta = Class.new MiniTest::Unit::TestCase do
- def test_something
+ define_method :test_something do
assert true
end
end
- self.class.const_set(:Beta, beta)
+ Object.const_set(:Beta, beta)
+
+ assert_report expected, args
+ ensure
+ Object.send :remove_const, :Alpha
+ Object.send :remove_const, :Beta
+ end
+ def test_run_filtered_including_suite_name
expected = clean <<-EOM
.
@@ -412,7 +421,31 @@ def test_something
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
- assert_report expected, %w[--name /Beta#test_something/ --seed 42]
+ assert_filtering "/Beta#test_something/", expected
+ end
+
+ def test_run_filtered_including_suite_name_string
+ expected = clean <<-EOM
+ .
+
+ Finished tests in 0.00
+
+ 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
+ EOM
+
+ assert_filtering "Beta#test_something", expected
+ end
+
+ def test_run_filtered_string_method_only
+ expected = clean <<-EOM
+ ..
+
+ Finished tests in 0.00
+
+ 2 tests, 2 assertions, 0 failures, 0 errors, 0 skips
+ EOM
+
+ assert_filtering "test_something", expected, :pass
end
def test_run_passing
Please sign in to comment.
Something went wrong with that request. Please try again.