Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/test.py

    r0c13238 r6044200  
    121121#               running test functions
    122122################################################################################
    123 def success(val):
    124         return val == 0 or settings.dry_run
    125 
    126 def isExe(file):
    127         return settings.dry_run or fileIsExecutable(file)
    128 
    129 def noRule(file, target):
    130         return not settings.dry_run and fileContainsOnly(file, "make: *** No rule to make target `%s'.  Stop." % target)
     123# fix the absolute paths in the output
     124def fixoutput( fname ):
     125        if not is_ascii(fname):
     126                return
     127
     128        file_replace(fname, "%s/" % settings.SRCDIR, "")
     129
    131130
    132131# logic to run a single test and return the result (No handling of printing or other test framework logic)
     
    144143
    145144        # build, skipping to next test on error
    146         with Timed() as comp_dur:
    147                 make_ret, _ = make( test.target(),      redirects  = ("2> %s 1> /dev/null" % out_file), error_file = err_file )
     145        before = time.time()
     146        make_ret, _ = make( test.target(),
     147                redirects  = "2> %s 1> /dev/null" % out_file,
     148                error_file = err_file
     149        )
     150        after = time.time()
     151
     152        comp_dur = after - before
     153
     154        run_dur = None
    148155
    149156        # if the make command succeds continue otherwise skip to diff
    150         run_dur = None
    151         if success(make_ret):
    152                 with Timed() as run_dur:
    153                         if isExe(exe_file):
    154                                 # run test
    155                                 retcode = run(exe_file, out_file, in_file)
    156                         else :
    157                                 # simply cat the result into the output
    158                                 retcode = cat(exe_file, out_file)
     157        if make_ret == 0 or settings.dry_run:
     158                before = time.time()
     159                if settings.dry_run or fileIsExecutable(exe_file) :
     160                        # run test
     161                        retcode, _ = sh("timeout %d %s > %s 2>&1" % (settings.timeout.single, exe_file, out_file), input = in_file)
     162                else :
     163                        # simply cat the result into the output
     164                        retcode, _ = sh("cat %s > %s" % (exe_file, out_file))
     165
     166                after = time.time()
     167                run_dur = after - before
    159168        else:
    160                 retcode = mv(err_file, out_file)
    161 
    162         if success(retcode):
     169                retcode, _ = sh("mv %s %s" % (err_file, out_file))
     170
     171
     172        if retcode == 0:
     173                # fixoutput(out_file)
    163174                if settings.generating :
    164175                        # if we are ounly generating the output we still need to check that the test actually exists
    165                         if noRule(out_file, test.target()) :
    166                                 retcode = 1
     176                        if not settings.dry_run and fileContainsOnly(out_file, "make: *** No rule to make target `%s'.  Stop." % test.target()) :
     177                                retcode = 1;
    167178                                error = "\t\tNo make target for test %s!" % test.target()
    168                                 rm(out_file)
     179                                sh("rm %s" % out_file, False)
    169180                        else:
    170181                                error = None
     
    177188                        error = myfile.read()
    178189
    179                 ret, info = coreInfo(exe_file)
    180                 error = error + info
    181 
    182 
    183190
    184191        # clean the executable
    185         rm(exe_file)
    186 
    187         return retcode, error, [comp_dur.duration, run_dur.duration if run_dur else None]
     192        sh("rm -f %s > /dev/null 2>&1" % test.target())
     193
     194        return retcode, error, [comp_dur, run_dur]
    188195
    189196# run a single test and handle the errors, outputs, printing, exception handling, etc.
     
    192199        with SignalHandling():
    193200                # print formated name
    194                 name_txt = "%24s  " % t.name
     201                name_txt = "%20s  " % t.name
    195202
    196203                retcode, error, duration = run_single_test(t)
     
    256263        allTests = listTests( options.include, options.exclude )
    257264
    258 
    259265        # if user wants all tests than no other treatement of the test list is required
    260266        if options.all or options.list or options.list_comp or options.include :
Note: See TracChangeset for help on using the changeset viewer.