# Author:: Nicolas Pouillard . # Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved. # License:: LGPL # Revision:: $Id: /w/fey/uttk/trunk/lib/uttk/strategies/RMatch.rb 22102 2006-02-21T23:03:39.538964Z pouillar $ module Uttk module Strategies # I can be used with to test a test strategy. I will be merged soon with # the _Test_ strategy. class RMatch < Proxy include Concrete # # Methods # def prologue super @errors_must_match = @match.dup @errors_must_not_match = [] prefix = @log.path.to_regex_path_string @log.debug { @log.prefix = prefix ; nil } c = Class.new(Filters::RPathFilter) c.include Concrete @match.each do |rpath| c.match prefix + rpath do |filter, path| @errors_must_match.delete rpath c.disable_matcher() end end @dont_match.each do |rpath| c.match prefix + rpath do |filter, path| @errors_must_not_match << rpath c.disable_matcher() end end @c_filter = c.new @log.add_observer(@c_filter) create @test end protected :prologue def assertion if @errors_must_match.empty? and @errors_must_not_match.empty? pass else unless @errors_must_match.empty? @log.some_wanted_paths_are_missing = @errors_must_match end unless @errors_must_not_match.empty? @log.some_unwanted_paths_are_present = @errors_must_not_match end fail end end protected :assertion def epilogue @log.delete_observer @c_filter super end protected :epilogue # # Attributes # attribute :match, 'a list of regexp paths which must matched with ' + 'the test output', Array, [] attribute :dont_match, 'a list of regexp paths which must NOT matched with ' + 'the test output', Array, [] attribute :test, 'the test to run at each time', :mandatory, :invisible, :dont_expand end # class RMatch end # module Strategies end # module Uttk