Skip to content

Commit

Permalink
The best we can do with Open3 is always return true.
Browse files Browse the repository at this point in the history
Open3 doesn't know the return value of executing the system command,
and some programs like to output to stderr during normal execution
(git clones/updates, nginx restarts, etc.) so stop returning false
if any lines are output to stderr since it's not correct.
  • Loading branch information
vandrijevik committed Mar 31, 2010
1 parent 4d4831d commit 956e985
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/simpleton/command_runners/open3.rb
Expand Up @@ -15,7 +15,7 @@ def self.run(host, command)
puts err_lines.map { |error_line| "[#{host}]E #{error_line}" }.join
end

err_lines.empty? ? true : false
true
end
end
end
Expand Down
12 changes: 2 additions & 10 deletions test/command_runners/open3_test.rb
Expand Up @@ -96,17 +96,9 @@
true
end

asserts "that when there was error output, its return value" do
asserts "that its return value" do
stub(::Open3).popen3("ssh", "#{host}", "#{command}") do
[ StringIO.new, StringIO.new, StringIO.new("error") ]
end

topic.run(host, command)
end.equals(false)

asserts "that when there was no error output, its return value" do
stub(::Open3).popen3("ssh", "#{host}", "#{command}") do
[ StringIO.new, StringIO.new, StringIO.new ]
[ StringIO.new, StringIO.new("output"), StringIO.new("error") ]
end

topic.run(host, command)
Expand Down

0 comments on commit 956e985

Please sign in to comment.