Write output from `sh' task action directly:

* Accept output as argument in Remote#execute;
* Modify ShellCommand so that env output is directly handled.
This commit is contained in:
Thibault Jouan
2014-03-05 06:06:42 +00:00
parent 400fa1ee3f
commit db3644a3e6
5 changed files with 22 additions and 8 deletions

View File

@@ -79,6 +79,7 @@ module Producer::Core
describe '#execute', :ssh do
let(:arguments) { 'some remote command' }
let(:command) { "echo #{arguments}" }
let(:output) { StringIO.new }
it 'executes the given command in a new channel' do
story_with_new_channel do |ch|
@@ -88,7 +89,7 @@ module Producer::Core
expect_story_completed { remote.execute command }
end
it 'returns the output' do
it 'returns the command standard output output' do
story_with_new_channel do |ch|
ch.sends_exec command
ch.gets_data arguments
@@ -96,6 +97,15 @@ module Producer::Core
expect(remote.execute command).to eq arguments
end
it 'writes command standard output to provided output' do
story_with_new_channel do |ch|
ch.sends_exec command
ch.gets_data arguments
end
remote.execute command, output
expect(output.string).to eq arguments
end
it 'raises an exception when the exit status code is not 0' do
story_with_new_channel do |ch|
ch.sends_exec command