Changeset 472ca32 for src/tests


Ignore:
Timestamp:
Jun 28, 2016, 2:42:16 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
66999e7
Parents:
2e04c7b3
Message:

test script now formats errors to be much more readable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/test.py

    r2e04c7b3 r472ca32  
    2121        return list
    2222
    23 def sh(cmd, dry_run):
     23def sh(cmd, dry_run = False, print2stdout = True):
    2424        if dry_run :
    2525                print("cmd: %s" % cmd)
    26                 return 0
     26                return 0, None
    2727        else :
    28                 proc = Popen(cmd, stderr=STDOUT, shell=True)
    29                 proc.communicate()
    30                 return proc.returncode
     28                proc = Popen(cmd, stdout=None if print2stdout else PIPE, stderr=STDOUT, shell=True)
     29                out, err = proc.communicate()
     30                return proc.returncode, out
    3131
    3232def file_replace(fname, pat, s_after):
     
    6161
    6262        # build, skipping to next test on error
    63         make_ret = sh("%s %s 2> %s 1> /dev/null" % (make_cmd, test, out_file), dry_run)
     63        make_ret, _ = sh("%s %s 2> %s 1> /dev/null" % (make_cmd, test, out_file), dry_run)
    6464
    6565        if make_ret == 0 :
     
    7171
    7272        retcode = 0
     73        error = None
    7374
    7475        fix_MakeLevel(out_file)
     
    7677        if not generate :
    7778                # diff the output of the files
    78                 retcode = sh("diff .expect/%s.txt .out/%s.log" % (test, test), dry_run)
     79                diff_cmd = ("diff --old-group-format='\t\tmissing lines :\n"
     80                                        "%%<' \\\n"
     81                                        "--new-group-format='\t\tnew lines :\n"
     82                                        "%%>' \\\n"
     83                                        "--unchanged-group-format='%%=' \\"
     84                                        "--changed-group-format='\t\texpected :\n"
     85                                        "%%<\n"
     86                                        "\t\tgot :\n"
     87                                        "%%>' \\\n"
     88                                        "--new-line-format='\t\t%%dn\t%%L' \\\n"
     89                                        "--old-line-format='\t\t%%dn\t%%L' \\\n"
     90                                        "--unchanged-line-format='' \\\n"
     91                                        ".expect/%s.txt .out/%s.log")
     92
     93                retcode, error = sh(diff_cmd % (test, test), dry_run, False)
    7994
    8095        # clean the executable
    8196        sh("rm -f %s > /dev/null 2>&1" % test, dry_run)
    8297
    83         return retcode
     98        return retcode, error
    8499
    85100def run_tests(tests, generate, dry_run) :
     
    94109                print("%20s  " % t, end="")
    95110                sys.stdout.flush()
    96                 test_failed = run_test_instance(t, generate, dry_run)
     111                test_failed, error = run_test_instance(t, generate, dry_run)
    97112                failed = test_failed or failed
    98113
    99114                if not generate :
    100115                        print("FAILED" if test_failed else "PASSED")
     116                        if error :
     117                                print(error)
    101118                else :
    102119                        print( "Done" )
Note: See TracChangeset for help on using the changeset viewer.