diff --git a/features/cli/error_reporting.feature b/features/cli/error_reporting.feature index ab69d0f..0b54d95 100644 --- a/features/cli/error_reporting.feature +++ b/features/cli/error_reporting.feature @@ -25,3 +25,8 @@ Feature: CLI error reporting Given a recipe using a remote When I execute the recipe on unknown remote target Then the output must not contain "net-ssh" + + Scenario: excludes ruby standard library from backtrace + Given a recipe using a remote + When I execute the recipe on unknown remote target + Then the output must not contain ruby lib directory diff --git a/features/steps/output_steps.rb b/features/steps/output_steps.rb index 690dd57..ea1630c 100644 --- a/features/steps/output_steps.rb +++ b/features/steps/output_steps.rb @@ -25,3 +25,7 @@ end Then /^the error output must contain exactly "([^"]+)"$/ do |content| assert_exact_output content, all_stderr end + +Then /^the output must not contain ruby lib directory$/ do + assert_no_partial_output RbConfig::CONFIG['rubylibdir'], all_output +end diff --git a/lib/producer/core/error_formatter.rb b/lib/producer/core/error_formatter.rb index 08785ff..ceadfe5 100644 --- a/lib/producer/core/error_formatter.rb +++ b/lib/producer/core/error_formatter.rb @@ -3,6 +3,7 @@ module Producer class ErrorFormatter FILTERS = [ /\/producer-\w+/, + Regexp.new(RbConfig::CONFIG['rubylibdir']), /\/net-ssh/, /\/net-sftp/ ].freeze diff --git a/spec/producer/core/error_formatter_spec.rb b/spec/producer/core/error_formatter_spec.rb index 447370f..ff8576b 100644 --- a/spec/producer/core/error_formatter_spec.rb +++ b/spec/producer/core/error_formatter_spec.rb @@ -23,7 +23,8 @@ module Producer end describe '#format' do - let(:bt) { %W[backtrace /producer-core /net-ssh] } + let(:rubylibdir) { RbConfig::CONFIG['rubylibdir'] } + let(:bt) { %W[backtrace /producer-core /net-ssh #{rubylibdir}] } def exception begin fail 'original exception' rescue fail 'some exception' end @@ -49,6 +50,10 @@ module Producer expect(formatter.format exception).not_to include 'net-ssh' end + it 'excludes ruby lib directory from the backtrace' do + expect(formatter.format exception).not_to include rubylibdir + end + context 'when debug is enabled' do let(:debug) { true }