diff --git a/src/test-dogtail/validator.py b/src/test-dogtail/validator.py index e59c992f13..1397565578 100644 --- a/src/test-dogtail/validator.py +++ b/src/test-dogtail/validator.py @@ -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\'")