Changeset ca54499


Ignore:
Timestamp:
May 17, 2018, 4:37:40 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, with_gc
Children:
c7d8100c
Parents:
e9a7e90b
Message:

Tests now print compile time and run time for all tests

Location:
src/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/tests/pybin/test_run.py

    re9a7e90b rca54499  
    44
    55import pybin.settings
     6import datetime
     7
     8from string import Template
     9
     10class DeltaTemplate(Template):
     11    delimiter = "%"
     12
     13def strfdelta(tdelta, fmt):
     14    d["H"], rem = divmod(tdelta.seconds, 3600)
     15    d["M"], d["S"] = divmod(rem, 60)
     16    t = DeltaTemplate(fmt)
     17    return t.substitute(**d)
    618
    719# Test class that defines what a test is
     
    5769
    5870        @classmethod
    59         def toString( cls, retcode ):
     71        def toString( cls, retcode, duration ):
    6072                if settings.generating :
    61                         if   retcode == TestResult.SUCCESS:     return "Done"
    62                         elif retcode == TestResult.TIMEOUT:     return "TIMEOUT"
    63                         else :                                          return "ERROR code %d" % retcode
     73                        if   retcode == TestResult.SUCCESS:     text = "Done   "
     74                        elif retcode == TestResult.TIMEOUT:     text = "TIMEOUT"
     75                        else :                                          text = "ERROR code %d" % retcode
    6476                else :
    65                         if   retcode == TestResult.SUCCESS:     return "PASSED"
    66                         elif retcode == TestResult.TIMEOUT:     return "TIMEOUT"
    67                         else :                                          return "FAILED with code %d" % retcode
     77                        if   retcode == TestResult.SUCCESS:     text = "PASSED "
     78                        elif retcode == TestResult.TIMEOUT:     text = "TIMEOUT"
     79                        else :                                          text = "FAILED with code %d" % retcode
     80
     81                text += "    C%s - R%s" % (cls.fmtDur(duration[0]), cls.fmtDur(duration[1]))
     82                return text
     83
     84        @classmethod
     85        def fmtDur( cls, duration ):
     86                if duration :
     87                        hours, rem = divmod(duration, 3600)
     88                        minutes, rem = divmod(rem, 60)
     89                        seconds, millis = divmod(rem, 1)
     90                        return "%2d:%02d.%03d" % (minutes, seconds, millis * 1000)
     91                return " n/a"
  • src/tests/test.py

    re9a7e90b rca54499  
    99import re
    1010import sys
     11import time
    1112
    1213################################################################################
     
    136137
    137138        # build, skipping to next test on error
     139        before = time.time()
    138140        make_ret, _ = make( test.target(),
    139141                redirects  = "2> %s 1> /dev/null" % out_file,
    140142                error_file = err_file
    141143        )
     144        after = time.time()
     145
     146        comp_dur = after - before
     147
     148        run_dur = None
    142149
    143150        # if the make command succeds continue otherwise skip to diff
    144151        if make_ret == 0 or settings.dry_run:
     152                before = time.time()
    145153                if settings.dry_run or fileIsExecutable(test.target()) :
    146154                        # run test
     
    149157                        # simply cat the result into the output
    150158                        retcode, _ = sh("cat %s > %s" % (test.target(), out_file))
     159
     160                after = time.time()
     161                run_dur = after - before
    151162        else:
    152163                retcode, _ = sh("mv %s %s" % (err_file, out_file))
     
    174185        sh("rm -f %s > /dev/null 2>&1" % test.target())
    175186
    176         return retcode, error
     187        return retcode, error, [comp_dur, run_dur]
    177188
    178189# run a single test and handle the errors, outputs, printing, exception handling, etc.
     
    183194                name_txt = "%20s  " % t.name
    184195
    185                 retcode, error = run_single_test(t)
     196                retcode, error, duration = run_single_test(t)
    186197
    187198                # update output based on current action
    188                 result_txt = TestResult.toString( retcode )
     199                result_txt = TestResult.toString( retcode, duration )
    189200
    190201                #print result with error if needed
Note: See TracChangeset for help on using the changeset viewer.