Changeset 1144


Ignore:
Timestamp:
06/18/21 14:24:16 (3 months ago)
Author:
sz
Message:

new options:

-d, --nodiff: Don't show individual line differences, just test results
-noerr, --never-show-stderr: Never print stderr

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tester/tester.py

    r1011 r1144  
    6565        # print stdout
    6666        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)
    6868
    6969        if p.returncode != 0 and p.returncode is not None:
     
    7575                # ==2176== ERROR SUMMARY: 597 errors from 50 contexts (suppressed: 35 from 8)
    7676                # ==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:
    7878                        print(stderrdata)
    7979
     
    8383
    8484
    85 def compare(jest, goal, was_compared_to):
     85def compare(jest, goal, was_compared_to, showdiff):
    8686        compare = comparison.Comparison(jest, goal)
    8787        if compare.equal:
     
    8989        else:
    9090                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?
    9596                        #sys.stdout.buffer.write(compare.result.encode("utf-8")) #prints nothing (on cygwin)
    9697                failed_result_filename = compare.list2_file + was_compared_to
     
    108109
    109110
    110 def check(stdout, output_net, output_msg):
     111def check(stdout, output_net, output_msg, showdiff):
    111112        actual_out_msg = []
    112113        if len(output_net) > 0:  # in case of the server, there is no filtering
    113114                for line in stdout:
    114115                        actual_out_msg.append(line)
    115                 return compare(actual_out_msg, output_net, '')
     116                return compare(actual_out_msg, output_net, '', showdiff)
    116117        else:
    117118                FROMSCRIPT = "Script.Message: "
     
    134135                if actual_out_msg[-1] == '':  # empty line at the end which is not present in our "goal" contents
    135136                        actual_out_msg.pop()
    136                 return compare(actual_out_msg, output_msg, '')
     137                return compare(actual_out_msg, output_msg, '', showdiff)
    137138
    138139
     
    198199        parser.add_argument("-n", "--name", help="Test name (regexp)")  # e.g. '^((?!python).)*$' = these tests which don't have the word "python" in their name
    199200        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")
    200202        parser.add_argument("-ds", "--diffslashes", help="Discriminate between slashes (consider / and \\ different)", action="store_true")
    201203        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")
    202205        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
    203206        parser.add_argument("-p", "--platform", help="Override platform identifier (referencing platform specific files " + globals.SPEC_INSERTPLATFORMDEPENDENTFILE + "), default:sys.platform (win32,linux2)")
     
    273276                                                for line in main_test_filename:
    274277                                                        contents.append(globals.stripEOL(line))
    275                                         ok = compare(contents, outfile, '_file') # +line[1]
     278                                        ok = compare(contents, outfile, '_file', not args.nodiff) # +line[1]
    276279                                except Exception as e: # could also 'raise' for some types of exceptions if we wanted
    277280                                        print_exception(e)
Note: See TracChangeset for help on using the changeset viewer.