Permalink
Browse files

add --suppress-backtrace option

  • Loading branch information...
1 parent 47c6d8a commit 1b53296711e36c599193fb4c6fb4a6cd61a7b656 @quix committed Aug 6, 2011
Showing with 26 additions and 2 deletions.
  1. +5 −0 lib/rake/application.rb
  2. +3 −2 lib/rake/backtrace.rb
  3. +18 −0 test/test_rake_backtrace.rb
View
@@ -376,6 +376,11 @@ def standard_rake_options
options.silent = true
}
],
+ ['--suppress-backtrace PATTERN', "Suppress backtrace lines matching regexp PATTERN. Ignored if --trace is on.",
+ lambda { |value|
+ options.suppress_backtrace_pattern = Regexp.new(value)
+ }
+ ],
['--system', '-g',
"Using system wide (global) rakefiles (usually '~/.rake/*.rake').",
lambda { |value| options.load_system = true }
View
@@ -7,9 +7,10 @@ module Backtrace
SUPPRESS_PATTERN = %r!(\A#{SUPPRESSED_PATHS.join('|')}|bin/rake:\d+)!
- # Elide backtrace elements which match one of SUPPRESS_PATHS.
def self.collapse(backtrace)
- backtrace.reject { |elem| elem =~ SUPPRESS_PATTERN }
+ pattern = Rake.application.options.suppress_backtrace_pattern ||
+ SUPPRESS_PATTERN
+ backtrace.reject { |elem| elem =~ pattern }
end
end
end
@@ -46,4 +46,22 @@ def test_multi_collapse
assert_match %r!\A#{Regexp.quote Dir.pwd}/Rakefile:3!, lines[3]
assert_match %r!\ATasks:!, lines[4]
end
+
+ def test_suppress_option
+ rakefile %q{
+ task :baz do
+ raise "bazzz!"
+ end
+ }
+
+ lines = rake("baz").split("\n")
+ assert_equal "rake aborted!", lines[0]
+ assert_equal "bazzz!", lines[1]
+ assert_match %r!Rakefile!, lines[2]
+
+ lines = rake("--suppress-backtrace", "R.k.file", "baz").split("\n")
+ assert_equal "rake aborted!", lines[0]
+ assert_equal "bazzz!", lines[1]
+ refute_match %r!Rakefile!, lines[2]
+ end
end

0 comments on commit 1b53296

Please sign in to comment.