# Author:: Nicolas Pouillard . # Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved. # License:: LGPL # $Id: /w/fey/uttk/trunk/lib/uttk/strategies/Cmd.rb 22184 2006-02-23T16:12:25.225774Z pouillar $ module Uttk module Strategies # I can check many interaction with a command line based program, such as: # its standard output, exit status, standard error. I can specify to a # given command its arguments, environment variables and standard input. # # A tutorial introduces how to use this strategy at # http://uttk.org/shelf/documentation class Cmd < CmdBase include Concrete # # Methods # def assertion fail('wrong exit value') if !@exit.nil? and @exit.to_i != @my_exit.to_i super end protected :assertion def failed_hook super @log.my_exit = @my_exit end protected :failed_hook def son_hook env_sub = proc do |k,v| ENV[k.to_s] = v.do_symtbl_gsub(@symtbl).gsub(/\$(\w+)/) { ENV[$1] } end @env.each(&env_sub) @symtbl[:env].each(&env_sub) if @symtbl[:env] end protected :son_hook # # Attributes # attribute :exit, 'the exit status reference', Integer attribute :env, 'environment variables', Hash do {} end end # class Cmd end # module Strategies end # module Uttk