Changeset 1144
- Timestamp:
- 06/18/21 14:24:16 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tester/tester.py
r1011 r1144 65 65 # print stdout 66 66 stderr = stderrdata.split(os.linesep) 67 ok = check(stdnet if len(output_net) > 0 else stdout, output_list if len(output_list) > 0 else output_net, output_msg )67 ok = check(stdnet if len(output_net) > 0 else stdout, output_list if len(output_list) > 0 else output_net, output_msg, not args.nodiff) 68 68 69 69 if p.returncode != 0 and p.returncode is not None: … … 75 75 # ==2176== ERROR SUMMARY: 597 errors from 50 contexts (suppressed: 35 from 8) 76 76 # ==3488== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 35 from 8) 77 if ( not args.valgrind) or ("ERROR SUMMARY:" in stderrdata and " 0 errors" not in stderrdata) or (args.always_show_stderr):77 if ((not args.valgrind) or ("ERROR SUMMARY:" in stderrdata and " 0 errors" not in stderrdata) or (args.always_show_stderr)) and not args.never_show_stderr: 78 78 print(stderrdata) 79 79 … … 83 83 84 84 85 def compare(jest, goal, was_compared_to ):85 def compare(jest, goal, was_compared_to, showdiff): 86 86 compare = comparison.Comparison(jest, goal) 87 87 if compare.equal: … … 89 89 else: 90 90 print("\r", globals.ANSI_SETRED + " FAIL\7" + globals.ANSI_RESET) 91 try: 92 print(compare.result) 93 except UnicodeEncodeError: 94 print(compare.result.encode("utf-8")) #only encode as utf8 when it is actually used, but this looks incorrect and perhaps should not be needed if the console supports utf8? 91 if showdiff: 92 try: 93 print(compare.result) 94 except UnicodeEncodeError: 95 print(compare.result.encode("utf-8")) #only encode as utf8 when it is actually used, but this looks incorrect and perhaps should not be needed if the console supports utf8? 95 96 #sys.stdout.buffer.write(compare.result.encode("utf-8")) #prints nothing (on cygwin) 96 97 failed_result_filename = compare.list2_file + was_compared_to … … 108 109 109 110 110 def check(stdout, output_net, output_msg ):111 def check(stdout, output_net, output_msg, showdiff): 111 112 actual_out_msg = [] 112 113 if len(output_net) > 0: # in case of the server, there is no filtering 113 114 for line in stdout: 114 115 actual_out_msg.append(line) 115 return compare(actual_out_msg, output_net, '' )116 return compare(actual_out_msg, output_net, '', showdiff) 116 117 else: 117 118 FROMSCRIPT = "Script.Message: " … … 134 135 if actual_out_msg[-1] == '': # empty line at the end which is not present in our "goal" contents 135 136 actual_out_msg.pop() 136 return compare(actual_out_msg, output_msg, '' )137 return compare(actual_out_msg, output_msg, '', showdiff) 137 138 138 139 … … 198 199 parser.add_argument("-n", "--name", help="Test name (regexp)") # e.g. '^((?!python).)*$' = these tests which don't have the word "python" in their name 199 200 parser.add_argument("-s", "--stop", help="Stops on first difference", action="store_true") 201 parser.add_argument("-d", "--nodiff", help="Don't show individual line differences, just test results", action="store_true") 200 202 parser.add_argument("-ds", "--diffslashes", help="Discriminate between slashes (consider / and \\ different)", action="store_true") 201 203 parser.add_argument("-err", "--always-show-stderr", help="Always print stderr (by default it is hidden if 0 errors in valgrind)", action="store_true") 204 parser.add_argument("-noerr", "--never-show-stderr", help="Never print stderr", action="store_true") 202 205 parser.add_argument("-e", "--exe", help="Regexp 'search=replace' rule(s) transforming executable name(s) into paths (eg. '(.*)=path/to/\\1.exe')", action='append') # in the example, double backslash is just for printing 203 206 parser.add_argument("-p", "--platform", help="Override platform identifier (referencing platform specific files " + globals.SPEC_INSERTPLATFORMDEPENDENTFILE + "), default:sys.platform (win32,linux2)") … … 273 276 for line in main_test_filename: 274 277 contents.append(globals.stripEOL(line)) 275 ok = compare(contents, outfile, '_file' ) # +line[1]278 ok = compare(contents, outfile, '_file', not args.nodiff) # +line[1] 276 279 except Exception as e: # could also 'raise' for some types of exceptions if we wanted 277 280 print_exception(e)
Note: See TracChangeset
for help on using the changeset viewer.