update validation to handle filtering,

add a new generic validator method which diff files only


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/dogtail@16449 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Ahmed Sayed
2007-08-18 21:44:21 +00:00
parent 3cf35dc624
commit e46c154ae7

View File

@@ -28,7 +28,7 @@ EXIT_SUCCESS = 0
EXIT_FAILURE = 1
EXIT_TROUBLE = 2
def validate_node (node, testname, ref_filename=None, act_filename=None):
def validate_node (node, testname, ref_filename=None, act_filename=None, filter_command=None):
"""
brows the children and out the result to file hold the same method name concatenated with _act to be diffed with the testcase name concatenated with _ref
if i have a testcase called test1
@@ -41,8 +41,26 @@ def validate_node (node, testname, ref_filename=None, act_filename=None):
act_file = open(act_filename, 'w')
generate_act_file (node, act_file)
act_file.close()
# get divided 265 to get the exact system status
error_code = os.system("diff %s %s" % (act_filename, ref_filename))/256
# divided by 265 to get the exact system status
if filter_command != None:
os.system("sed -n %s < %s >%s" % (filter_command, act_filename, act_filename+"_filtered"))
os.system("sed -n %s < %s >%s" % (filter_command, ref_filename, ref_filename+"_filtered"))
error_code = os.system("diff %s %s" % (act_filename+"_filtered", ref_filename+"_filtered"))/256
else:
error_code = os.system("diff %s %s" % (act_filename, ref_filename))/256
return error_code
def validate_files(testname, ref_filename=None, act_filename=None, filter_command=None):
if act_filename == None:
act_filename = 'act/%s_act' % (testname)
if ref_filename == None:
ref_filename = 'ref/%s_ref' % (testname)
if filter_command != None:
os.system("sed -n %s < %s > %s" % (filter_command, act_filename, act_filename+"_filtered"))
os.system("sed -n %s < %s > %s" % (filter_command, ref_filename, ref_filename+"_filtered"))
error_code = os.system("diff %s %s" % (act_filename+"_filtered", ref_filename+"_filtered"))/256
else:
error_code = os.system("diff %s %s" % (act_filename, ref_filename))/256
return error_code
def generate_act_file (node, file, depth = 0):
@@ -54,3 +72,5 @@ def generate_act_file (node, file, depth = 0):
except AttributeError:
pass
if __name__ == '__main__':
validate_files('/home/ahmed/act', '/home/ahmed/ref', "\'/TABLE/,/\/TABLE/p\'")