From ecfb547b05efe48fd55ee9690d8a86f0792b082e Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Sat, 25 Jun 2016 22:14:43 +0200 Subject: [PATCH] bugfix: run frozen string commands via ssh --- lib/train/transports/ssh_connection.rb | 2 +- test/integration/tests/run_command_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/train/transports/ssh_connection.rb b/lib/train/transports/ssh_connection.rb index b4864339..6d8f680d 100644 --- a/lib/train/transports/ssh_connection.rb +++ b/lib/train/transports/ssh_connection.rb @@ -73,7 +73,7 @@ def file(path) def run_command(cmd) stdout = stderr = '' exit_status = nil - cmd.force_encoding('binary') if cmd.respond_to?(:force_encoding) + cmd.dup.force_encoding('binary') if cmd.respond_to?(:force_encoding) logger.debug("[SSH] #{self} (#{cmd})") session.open_channel do |channel| diff --git a/test/integration/tests/run_command_test.rb b/test/integration/tests/run_command_test.rb index 5a86fd76..124c4894 100644 --- a/test/integration/tests/run_command_test.rb +++ b/test/integration/tests/run_command_test.rb @@ -10,6 +10,13 @@ res.exit_status.must_equal(0) end + it 'can run frozen commands' do + res = backend.run_command('echo hello world'.freeze) + res.stdout.must_equal("hello world\n") + res.stderr.must_equal('') + res.exit_status.must_equal(0) + end + it 'can echo commands to stderr' do # TODO: Specinfra often fails on this test. # Fix and re-enable it.