updated test / regex library
git-svn-id: file:///home/svn/framework3/trunk@11475 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
a79092a0d3
commit
41732344f0
|
@ -1,41 +1,42 @@
|
|||
## This class consists of assert helper methods for regexing logs
|
||||
##
|
||||
## $Id$
|
||||
##
|
||||
|
||||
$:.unshift(File.expand_path(File.dirname(__FILE__)))
|
||||
|
||||
require 'regexr'
|
||||
require 'test/unit'
|
||||
|
||||
class MsfTestCase < Test::Unit::TestCase
|
||||
module MsfTest
|
||||
|
||||
def assert_complete(data,first,last)
|
||||
@regexr = Regexr.new(true)
|
||||
assert_not_nil @regexr.verify_start(data,first), "The start string " + data.split("\n").first + " did not match the expected string: " + first
|
||||
assert_not_nil @regexr.verify_end(data,last), "The end string " + data.split("\n").last + " did not match the expected string: " + last
|
||||
class MsfTestCaseHelper
|
||||
|
||||
## This module consists of assert helper methods for regexing logs
|
||||
## Use it in conjunction with test/unit
|
||||
|
||||
def initialize
|
||||
@debug = false
|
||||
@regexr = Regexr.new(@debug)
|
||||
end
|
||||
|
||||
def complete?(data,first,last)
|
||||
@regexr.verify_start_and_end(data,first,last)
|
||||
end
|
||||
|
||||
def assert_all_successes(data, regex_strings)
|
||||
@regexr = Regexr.new(true)
|
||||
def all_successes_exist?(data, regex_strings)
|
||||
if regex_strings
|
||||
regex_strings.each { |regex_string|
|
||||
puts "Making sure " + regex_string + " is included."
|
||||
assert_true @regexr.ensure_exists_in_data(data,regex_string), "The string " + regex_string + " was not found in the data."
|
||||
return false unless @regexr.ensure_exists_in_data(data,regex_string)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def scan_for_errors(data)
|
||||
scan_for_failures(data,['exception'],[])
|
||||
end
|
||||
|
||||
def assert_no_failures(data, regex_strings, exception_strings)
|
||||
@regexr = Regexr.new(true)
|
||||
def no_failures_exist?(data, regex_strings, exception_strings)
|
||||
if regex_strings
|
||||
regex_strings.each { |regex_string|
|
||||
puts "Making sure " + regex_string + " isn't included."
|
||||
assert_true @regexr.ensure_doesnt_exist_in_data_unless(data,regex_string,exception_strings), "The string " + regex_string + " was found in the the data, and no exception was found."
|
||||
return false unless @regexr.ensure_doesnt_exist_in_data_unless(data,regex_string,exception_strings)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -18,6 +18,7 @@ class Regexr
|
|||
if @verbose
|
||||
puts "Testing: " + the_start + " =~ " + data_lines.first
|
||||
end
|
||||
|
||||
return regex_start =~ data_lines.first
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue