Skip to content

Commit

Permalink
fix: always download files even if verifier fails
Browse files Browse the repository at this point in the history
Fixes #1643

Signed-off-by: Bryce Kahle <github@brycekahle.com>
  • Loading branch information
brycekahle committed Oct 21, 2022
1 parent 0c93887 commit 129da36
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/kitchen/verifier/base.rb
Expand Up @@ -73,14 +73,17 @@ def call(state)
conn.upload(sandbox_dirs, config[:root_path])
debug("Transfer complete")
conn.execute(prepare_command)
conn.execute(run_command)

info("Downloading files from #{instance.to_str}")
config[:downloads].to_h.each do |remotes, local|
debug("Downloading #{Array(remotes).join(", ")} to #{local}")
conn.download(remotes, local)

begin
conn.execute(run_command)
ensure
info("Downloading files from #{instance.to_str}")
config[:downloads].to_h.each do |remotes, local|
debug("Downloading #{Array(remotes).join(", ")} to #{local}")
conn.download(remotes, local)
end
debug("Download complete")
end
debug("Download complete")
end
rescue Kitchen::Transport::TransportFailed => ex
raise ActionFailed, ex.message
Expand Down
16 changes: 16 additions & 0 deletions spec/kitchen/verifier/base_spec.rb
Expand Up @@ -250,6 +250,22 @@ class Dodgy < Kitchen::Verifier::Base
cmd
end

it "downloads files when run fails" do
connection.expects(:download).with(
["/tmp/kitchen/nodes", "/tmp/kitchen/data_bags"],
"./test/fixtures"
)

connection.expects(:download).with("/remote", "/local")

connection.expects(:execute).with("run").raises

begin
cmd
rescue
end
end

it "raises an ActionFailed on transfer when TransportFailed is raised" do
connection.stubs(:upload)
.raises(Kitchen::Transport::TransportFailed.new("dang"))
Expand Down

0 comments on commit 129da36

Please sign in to comment.