Changeset bee653c for tests/test.py


Ignore:
Timestamp:
Mar 28, 2019, 6:35:21 PM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
arm-eh, cleanup-dtors, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
2fabdc02, 9be2b60
Parents:
8a25be9 (diff), b611fc3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/test.py

    r8a25be9 rbee653c  
    88import re
    99import sys
     10import tempfile
    1011import time
    1112
     
    143144                make_ret, _ = make( test.target(), output=subprocess.DEVNULL, error=out_file, error_file = err_file )
    144145
    145         # if the make command succeds continue otherwise skip to diff
    146146        run_dur = None
    147         if success(make_ret):
    148                 with Timed() as run_dur:
    149                         if settings.dry_run or is_exe(exe_file):
    150                                 # run test
    151                                 retcode, _ = sh(exe_file, output=out_file, input=in_file, timeout=True)
     147        # run everything in a temp directory to make sure core file are handled properly
     148        with tempdir():
     149                # if the make command succeds continue otherwise skip to diff
     150                if success(make_ret):
     151                        with Timed() as run_dur:
     152                                if settings.dry_run or is_exe(exe_file):
     153                                        # run test
     154                                        retcode, _ = sh(exe_file, output=out_file, input=in_file, timeout=True)
     155                                else :
     156                                        # simply cat the result into the output
     157                                        retcode = cat(exe_file, out_file)
     158                else:
     159                        retcode = mv(err_file, out_file)
     160
     161                if success(retcode):
     162                        if settings.generating :
     163                                # if we are ounly generating the output we still need to check that the test actually exists
     164                                if no_rule(out_file, test.target()) :
     165                                        retcode = 1
     166                                        error = "\t\tNo make target for test %s!" % test.target()
     167                                        rm(out_file)
     168                                else:
     169                                        error = None
    152170                        else :
    153                                 # simply cat the result into the output
    154                                 retcode = cat(exe_file, out_file)
    155         else:
    156                 retcode = mv(err_file, out_file)
    157 
    158         if success(retcode):
    159                 if settings.generating :
    160                         # if we are ounly generating the output we still need to check that the test actually exists
    161                         if no_rule(out_file, test.target()) :
    162                                 retcode = 1
    163                                 error = "\t\tNo make target for test %s!" % test.target()
    164                                 rm(out_file)
    165                         else:
    166                                 error = None
    167                 else :
    168                         # fetch return code and error from the diff command
    169                         retcode, error = diff(cmp_file, out_file)
    170 
    171         else:
    172                 with open (out_file, "r") as myfile:
    173                         error = myfile.read()
    174 
    175                 ret, info = core_info(exe_file)
    176                 error = error + info if error else info
     171                                # fetch return code and error from the diff command
     172                                retcode, error = diff(cmp_file, out_file)
     173
     174                else:
     175                        with open (out_file, "r") as myfile:
     176                                error = myfile.read()
     177
     178                        ret, info = core_info(exe_file)
     179                        error = error + info if error else info
    177180
    178181
Note: See TracChangeset for help on using the changeset viewer.