| Class | Uttk::Strategies::SubCmd |
| In: |
lib/uttk/strategies/SubCmd.rb
|
| Parent: | Strategy |
I run a sub Uttk or an another program that can behave like it.
# File lib/uttk/strategies/SubCmd.rb, line 61 def abort_hook @runner.abort @data if @runner and defined? @data super end
# File lib/uttk/strategies/SubCmd.rb, line 48 def assertion @data_error_contents = @data.error.read ref = { :exit => (/^[02]$/) } matcher_result = command_matcher[UM::StreamMatcher, ref, @data] raise_error 'bad exit status' if matcher_result.failure? raise_error 'bad status output' unless @run_impl_status.is_a? Status raise_error 'uttk stderr not empty' unless @data_error_contents.empty? @status = @run_impl_status raise_status @status end
# File lib/uttk/strategies/SubCmd.rb, line 68 def error_hook if defined? @data @log.my_stdout = @data.output.to_s_for_uttk_log unless @data.output.nil? if defined? @data_error_contents and not @data_error_contents.empty? @log.my_stderr = @data_error_contents.to_s_for_uttk_log end @log.my_exit = @data.status.exitstatus unless @data.status.nil? end super end
# File lib/uttk/strategies/SubCmd.rb, line 15 def prologue super hooker = StrategyHooker.new @symtbl, @log, @env @runner = OCmd::Runners::Popen.new.hooker_subscribe hooker @command = @symtbl[:uttk].to_ocmd @command.dir = @symtbl[:pwd] @command.input = @input @command += @args.to_ocmd_args @command << '-F' << 'Path' << '--dump-status' end
# File lib/uttk/strategies/SubCmd.rb, line 28 def run_impl @data = @command.run @runner @run_impl_status = nil root_path = @log.path YAML.load_from_io @data.output do |notification| case notification when Array path, leaf = notification @log.update(:new_leaf, root_path + path, leaf) when Status @run_impl_status = notification else raise_error 'bad sub commad output' end end @data.waitpid end