Changes in / [c7d8100c:4358c1e]
- Location:
- src/tests
- Files:
-
- 2 edited
-
pybin/test_run.py (modified) (2 diffs)
-
test.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/tests/pybin/test_run.py
rc7d8100c r4358c1e 4 4 5 5 import pybin.settings 6 import datetime7 8 from string import Template9 10 class DeltaTemplate(Template):11 delimiter = "%"12 13 def 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)18 6 19 7 # Test class that defines what a test is … … 69 57 70 58 @classmethod 71 def toString( cls, retcode , duration):59 def toString( cls, retcode ): 72 60 if settings.generating : 73 if retcode == TestResult.SUCCESS: text = "Done"74 elif retcode == TestResult.TIMEOUT: text ="TIMEOUT"75 else : text ="ERROR code %d" % retcode61 if retcode == TestResult.SUCCESS: return "Done" 62 elif retcode == TestResult.TIMEOUT: return "TIMEOUT" 63 else : return "ERROR code %d" % retcode 76 64 else : 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" 65 if retcode == TestResult.SUCCESS: return "PASSED" 66 elif retcode == TestResult.TIMEOUT: return "TIMEOUT" 67 else : return "FAILED with code %d" % retcode -
src/tests/test.py
rc7d8100c r4358c1e 9 9 import re 10 10 import sys 11 import time12 11 13 12 ################################################################################ … … 137 136 138 137 # build, skipping to next test on error 139 before = time.time()140 138 make_ret, _ = make( test.target(), 141 139 redirects = "2> %s 1> /dev/null" % out_file, 142 140 error_file = err_file 143 141 ) 144 after = time.time()145 146 comp_dur = after - before147 148 run_dur = None149 142 150 143 # if the make command succeds continue otherwise skip to diff 151 144 if make_ret == 0 or settings.dry_run: 152 before = time.time()153 145 if settings.dry_run or fileIsExecutable(test.target()) : 154 146 # run test … … 157 149 # simply cat the result into the output 158 150 retcode, _ = sh("cat %s > %s" % (test.target(), out_file)) 159 160 after = time.time()161 run_dur = after - before162 151 else: 163 152 retcode, _ = sh("mv %s %s" % (err_file, out_file)) … … 185 174 sh("rm -f %s > /dev/null 2>&1" % test.target()) 186 175 187 return retcode, error , [comp_dur, run_dur]176 return retcode, error 188 177 189 178 # run a single test and handle the errors, outputs, printing, exception handling, etc. … … 194 183 name_txt = "%20s " % t.name 195 184 196 retcode, error , duration= run_single_test(t)185 retcode, error = run_single_test(t) 197 186 198 187 # update output based on current action 199 result_txt = TestResult.toString( retcode , duration)188 result_txt = TestResult.toString( retcode ) 200 189 201 190 #print result with error if needed
Note:
See TracChangeset
for help on using the changeset viewer.