Please review pull request #147: (#12673) Add a Result#output member that combines stdout and stderr opened by (justinstoller)
Description:
Prior to this we had Result#stdout, #Result#stderr, and #Result#exit_code for checking the output of a test.
This patch adds a Result#output that combines both stderr and stdout in the order in which they occur. Allowing for better UX testing of output.
- Opened: Thu Feb 16 23:24:10 UTC 2012
- Based on: puppetlabs:master (e4cf3647f6a55f36e7e00d2a9d18c043507c2149)
- Requested merge: justinstoller:feature/master/12673-add_result.output (7f09e4b175892dee2c48b4876134a92567cd47a0)
Diff follows:
diff --git a/lib/Result.rb b/lib/Result.rb
index 0240f7b..9f6f08a 100644
--- a/lib/Result.rb
+++ b/lib/Result.rb
@@ -1,11 +1,13 @@
class Result
- attr_accessor :host, :cmd, :stdout, :stderr, :exit_code
- def initialize(host=nil, cmd=nil, stdout=nil, stderr=nil, exit_code=nil)
+ attr_accessor :host, :cmd, :stdout, :stderr, :exit_code, :output
+ def initialize(host = nil, cmd = nil, stdout = '', stderr = '',
+ exit_code = nil, output = '')
@host = host
@cmd = cmd
@stdout = stdout
@stderr = stderr
@exit_code = exit_code
+ @output = output
end
def log
diff --git a/lib/host.rb b/lib/host.rb
index e7b3a83..0912559 100644
--- a/lib/host.rb
+++ b/lib/host.rb
@@ -77,8 +77,16 @@ def exec(command, options)
channel.exec(command) do |terminal, success|
abort "FAILED: to execute command on a new channel on #{@name}" unless success
- terminal.on_data { |ch, data| result.stdout << data }
- terminal.on_extended_data { |ch, type, data| result.stderr << data if type == 1 }
+ terminal.on_data do |ch, data|
+ result.stdout << data
+ result.output << data
+ end
+ terminal.on_extended_data do |ch, type, data|
+ if type == 1
+ result.stderr << data
+ result.output << data
+ end
+ end
terminal.on_request("exit-status") { |ch, data| result.exit_code = data.read_long }
# queue stdin data, force it to packets, and signal eof: this
-- You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
