From dc561de047ad9072f4cf4b85fb5927771fe5609e Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Fri, 3 Apr 2015 21:33:29 +0000 Subject: [PATCH] Fix backtrace filtering for net-ssh Improve our filter pattern so it works for this kind of error: SocketError: getaddrinfo: hostname nor servname provided, or not known /usr/local/lib/ruby/2.2/timeout.rb:74:in `timeout' /usr/local/lib/ruby/2.2/timeout.rb:125:in `timeout' /home/tj/.gem/ruby/22/gems/net-ssh-2.9.2/lib/net/ssh.rb:207:in `new' /home/tj/.gem/ruby/22/gems/net-ssh-2.9.2/lib/net/ssh.rb:207:in `start' --- features/cli/error_reporting.feature | 10 ++++------ features/steps/recipe_steps.rb | 9 +++++++++ lib/producer/core/error_formatter.rb | 4 ++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/features/cli/error_reporting.feature b/features/cli/error_reporting.feature index 707189c..01ddb2d 100644 --- a/features/cli/error_reporting.feature +++ b/features/cli/error_reporting.feature @@ -1,24 +1,22 @@ Feature: CLI error reporting - Background: - Given a recipe with: - """ - task(:trigger_error) { fail 'some error' } - """ - Scenario: reports recipe errors + Given a recipe with an error When I execute the recipe Then the exit status must be 70 And the output must match /\ARuntimeError: some error\n/ Scenario: reports errors with a backtrace + Given a recipe with an error When I execute the recipe Then the output must match /^\s+recipe\.rb:\d+:in / Scenario: prepends recipe file path in the backtrace + Given a recipe with an error When I execute the recipe Then the output must match /^\s+recipe\.rb \(recipe\)\n\s+recipe\.rb:/ Scenario: excludes net-ssh from backtrace + Given a recipe using a remote When I execute the recipe on unknown remote target Then the output must not contain "net-ssh" diff --git a/features/steps/recipe_steps.rb b/features/steps/recipe_steps.rb index d2960f1..93ed953 100644 --- a/features/steps/recipe_steps.rb +++ b/features/steps/recipe_steps.rb @@ -2,6 +2,14 @@ Given /^a recipe with:$/ do |recipe_body| write_file 'recipe.rb', recipe_body end +Given /^a recipe with an error$/ do + write_file 'recipe.rb', "task(:trigger_error) { fail 'some error' }\n" +end + +Given /^a recipe using a remote$/ do + write_file 'recipe.rb', "task(:some_task) { sh 'echo hello' }\n" +end + Given /^a recipe named "([^"]+)" with:$/ do |recipe_path, recipe_body| write_file recipe_path, recipe_body end @@ -16,6 +24,7 @@ end When /^I execute the recipe on unknown remote target$/ do run_simple 'producer recipe.rb -t #unknown_host.test', false + assert_matching_output '\ASocketError', all_output end When /^I successfully execute the recipe$/ do diff --git a/lib/producer/core/error_formatter.rb b/lib/producer/core/error_formatter.rb index 4da7b3e..5ac1e05 100644 --- a/lib/producer/core/error_formatter.rb +++ b/lib/producer/core/error_formatter.rb @@ -3,8 +3,8 @@ module Producer class ErrorFormatter FILTERS = [ /\/producer-\w+\/(?:bin|lib)\//, - /\/net\/ssh\//, - /\/net\/sftp\// + /\/net-ssh/, + /\/net-sftp/ ].freeze def initialize(debug: false, force_cause: [])