Permalink
Browse files

fix backtrace suppression for rubinius

  • Loading branch information...
1 parent de88a99 commit 7c841a3ca7c84d3f1a627628f19a98238ba80596 @jimweirich committed Nov 9, 2012
Showing with 24 additions and 10 deletions.
  1. +2 −1 lib/rake/backtrace.rb
  2. +0 −1 test/test_rake_application.rb
  3. +22 −8 test/test_rake_backtrace.rb
View
@@ -5,8 +5,9 @@ module Backtrace
keys.grep(/(prefix|libdir)/)) + [
File.join(File.dirname(__FILE__), ".."),
].map { |f| Regexp.quote(File.expand_path(f)) }
+ SUPPRESSED_PATHS.reject! { |s| s.nil? || s =~ /^ *$/ }
- SUPPRESS_PATTERN = %r!(\A#{SUPPRESSED_PATHS.join('|')}|bin/rake:\d+)!
+ SUPPRESS_PATTERN = %r!(\A#{SUPPRESSED_PATHS.join('|')}|bin/rake:\d+)!i
def self.collapse(backtrace)
pattern = Rake.application.options.suppress_backtrace_pattern ||
@@ -498,4 +498,3 @@ def loader.make_dummy
end
end
-
@@ -24,8 +24,8 @@ def test_single_collapse
assert_equal "rake aborted!", lines[0]
assert_equal "foooo!", lines[1]
- assert_match %r!\A#{Regexp.quote Dir.pwd}/Rakefile:3!, lines[2]
- assert_match %r!\ATasks:!, lines[3]
+ assert_something_matches %r!\A#{Regexp.quote Dir.pwd}/Rakefile:3!i, lines
+ assert_something_matches %r!\ATasks:!, lines
end
def test_multi_collapse
@@ -42,9 +42,9 @@ def test_multi_collapse
assert_equal "rake aborted!", lines[0]
assert_equal "barrr!", lines[1]
- assert_match %r!\A#{Regexp.quote Dir.pwd}/Rakefile:6!, lines[2]
- assert_match %r!\A#{Regexp.quote Dir.pwd}/Rakefile:3!, lines[3]
- assert_match %r!\ATasks:!, lines[4]
+ assert_something_matches %r!\A#{Regexp.quote Dir.pwd}/Rakefile:6!i, lines
+ assert_something_matches %r!\A#{Regexp.quote Dir.pwd}/Rakefile:3!i, lines
+ assert_something_matches %r!\ATasks:!, lines
end
def test_suppress_option
@@ -57,11 +57,25 @@ def test_suppress_option
lines = rake("baz").split("\n")
assert_equal "rake aborted!", lines[0]
assert_equal "bazzz!", lines[1]
- assert_match %r!Rakefile!, lines[2]
+ assert_something_matches %r!Rakefile!i, lines
- lines = rake("--suppress-backtrace", "R.k.file", "baz").split("\n")
+ lines = rake("--suppress-backtrace", ".ak.file", "baz").split("\n")
assert_equal "rake aborted!", lines[0]
assert_equal "bazzz!", lines[1]
- refute_match %r!Rakefile!, lines[2]
+ refute_match %r!Rakefile!i, lines[2]
end
+
+ private
+
+ # Assert that the pattern matches at least one line in +lines+.
+ def assert_something_matches(pattern, lines)
+ lines.each do |ln|
+ if pattern =~ ln
+ assert_match pattern, ln
+ return
+ end
+ end
+ flunk "expected #{pattern.inspect} to match something in:\n #{lines.join("\n ")}"
+ end
+
end

0 comments on commit 7c841a3

Please sign in to comment.