From dbe7fea204587ec81995fd76d97a6177a450ebef Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Sat, 4 Apr 2015 20:15:22 +0000 Subject: [PATCH] Fix backtrace filtering for producer own code Using /producer-\w+ as pattern is incorrect, we have no guarantee that the canonical repository or gem name will be included in the install path. Just use /producer pattern to match lib files or executables. --- features/cli/debug.feature | 2 +- lib/producer/core/error_formatter.rb | 2 +- spec/producer/core/error_formatter_spec.rb | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/features/cli/debug.feature b/features/cli/debug.feature index 2d6f25c..f22eee6 100644 --- a/features/cli/debug.feature +++ b/features/cli/debug.feature @@ -8,6 +8,6 @@ Feature: CLI debug option Scenario: does not exclude anything from backtrace Given a recipe using a remote When I execute the recipe on unknown remote target with option -d - Then the output must contain "producer-core" + Then the output must contain "producer" And the output must contain "net-ssh" And the output must contain ruby lib directory diff --git a/lib/producer/core/error_formatter.rb b/lib/producer/core/error_formatter.rb index 91b7c9e..ca40cf8 100644 --- a/lib/producer/core/error_formatter.rb +++ b/lib/producer/core/error_formatter.rb @@ -2,7 +2,7 @@ module Producer module Core class ErrorFormatter FILTERS = [ - /\/producer-\w+/, + /\/producer/, Regexp.new(RbConfig::CONFIG['rubylibdir']), /\/net-ssh/, /\/net-sftp/ diff --git a/spec/producer/core/error_formatter_spec.rb b/spec/producer/core/error_formatter_spec.rb index 3fbe932..775e039 100644 --- a/spec/producer/core/error_formatter_spec.rb +++ b/spec/producer/core/error_formatter_spec.rb @@ -24,7 +24,7 @@ module Producer describe '#format' do let(:rubylibdir) { RbConfig::CONFIG['rubylibdir'] } - let(:bt) { %W[backtrace /producer-core /net-ssh #{rubylibdir}] } + let(:bt) { %W[backtrace /producer /net-ssh #{rubylibdir}] } let(:exception) { RuntimeError.new('some exception').tap { |o| o.set_backtrace bt } } def exception_with_cause @@ -43,7 +43,7 @@ module Producer end it 'excludes producer code from the backtrace' do - expect(formatter.format exception).not_to include 'producer-core' + expect(formatter.format exception).not_to include 'producer' end it 'excludes net-ssh from the backtrace' do @@ -65,7 +65,7 @@ module Producer let(:debug) { true } it 'does not filter the backtrace' do - expect(formatter.format exception).to include 'producer-core' + expect(formatter.format exception).to include 'producer' end context 'when exception has a cause' do