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: [])