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'
This commit is contained in:
Thibault Jouan 2015-04-03 21:33:29 +00:00
parent e361b6d174
commit dc561de047
3 changed files with 15 additions and 8 deletions

View File

@ -1,24 +1,22 @@
Feature: CLI error reporting Feature: CLI error reporting
Background:
Given a recipe with:
"""
task(:trigger_error) { fail 'some error' }
"""
Scenario: reports recipe errors Scenario: reports recipe errors
Given a recipe with an error
When I execute the recipe When I execute the recipe
Then the exit status must be 70 Then the exit status must be 70
And the output must match /\ARuntimeError: some error\n/ And the output must match /\ARuntimeError: some error\n/
Scenario: reports errors with a backtrace Scenario: reports errors with a backtrace
Given a recipe with an error
When I execute the recipe When I execute the recipe
Then the output must match /^\s+recipe\.rb:\d+:in / Then the output must match /^\s+recipe\.rb:\d+:in /
Scenario: prepends recipe file path in the backtrace Scenario: prepends recipe file path in the backtrace
Given a recipe with an error
When I execute the recipe When I execute the recipe
Then the output must match /^\s+recipe\.rb \(recipe\)\n\s+recipe\.rb:/ Then the output must match /^\s+recipe\.rb \(recipe\)\n\s+recipe\.rb:/
Scenario: excludes net-ssh from backtrace Scenario: excludes net-ssh from backtrace
Given a recipe using a remote
When I execute the recipe on unknown remote target When I execute the recipe on unknown remote target
Then the output must not contain "net-ssh" Then the output must not contain "net-ssh"

View File

@ -2,6 +2,14 @@ Given /^a recipe with:$/ do |recipe_body|
write_file 'recipe.rb', recipe_body write_file 'recipe.rb', recipe_body
end 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| Given /^a recipe named "([^"]+)" with:$/ do |recipe_path, recipe_body|
write_file recipe_path, recipe_body write_file recipe_path, recipe_body
end end
@ -16,6 +24,7 @@ end
When /^I execute the recipe on unknown remote target$/ do When /^I execute the recipe on unknown remote target$/ do
run_simple 'producer recipe.rb -t #unknown_host.test', false run_simple 'producer recipe.rb -t #unknown_host.test', false
assert_matching_output '\ASocketError', all_output
end end
When /^I successfully execute the recipe$/ do When /^I successfully execute the recipe$/ do

View File

@ -3,8 +3,8 @@ module Producer
class ErrorFormatter class ErrorFormatter
FILTERS = [ FILTERS = [
/\/producer-\w+\/(?:bin|lib)\//, /\/producer-\w+\/(?:bin|lib)\//,
/\/net\/ssh\//, /\/net-ssh/,
/\/net\/sftp\// /\/net-sftp/
].freeze ].freeze
def initialize(debug: false, force_cause: []) def initialize(debug: false, force_cause: [])