Changeset 3d5701e for tests/test.py
- Timestamp:
- Feb 25, 2020, 1:17:33 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 7dc2e015
- Parents:
- 9fb8f01 (diff), dd9e1ca (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/test.py
r9fb8f01 r3d5701e 10 10 import tempfile 11 11 import time 12 13 import os 14 import psutil 15 import signal 12 16 13 17 ################################################################################ … … 143 147 # build, skipping to next test on error 144 148 with Timed() as comp_dur: 145 make_ret, _ = make( test.target(), output =subprocess.DEVNULL, error=out_file, error_file = err_file )149 make_ret, _ = make( test.target(), output_file=subprocess.DEVNULL, error=out_file, error_file = err_file ) 146 150 147 151 run_dur = None 148 152 # run everything in a temp directory to make sure core file are handled properly 149 153 with tempdir(): 150 # if the make command succe ds continue otherwise skip to diff154 # if the make command succeeds continue otherwise skip to diff 151 155 if success(make_ret): 152 156 with Timed() as run_dur: 153 157 if settings.dry_run or is_exe(exe_file): 154 158 # run test 155 retcode, _ = sh(exe_file, output =out_file, input=in_file, timeout=True)159 retcode, _ = sh(exe_file, output_file=out_file, input_file=in_file, timeout=True) 156 160 else : 157 161 # simply cat the result into the output … … 210 214 except KeyboardInterrupt: 211 215 return False, "" 212 except :213 print("Unexpected error in worker thread ", file=sys.stderr)216 except Exception as ex: 217 print("Unexpected error in worker thread: %s" % ex, file=sys.stderr) 214 218 sys.stderr.flush() 215 219 return False, "" … … 219 223 def run_tests(tests, jobs) : 220 224 # clean the sandbox from previous commands 221 make('clean', output=subprocess.DEVNULL, error=subprocess.DEVNULL) 225 make('clean', output_file=subprocess.DEVNULL, error=subprocess.DEVNULL) 226 227 # since python prints stacks by default on a interrupt, redo the interrupt handling to be silent 228 def worker_init(): 229 def sig_int(signal_num, frame): 230 pass 231 232 signal.signal(signal.SIGINT, sig_int) 222 233 223 234 # create the executor for our jobs and handle the signal properly 224 pool = multiprocessing.Pool(jobs )235 pool = multiprocessing.Pool(jobs, worker_init) 225 236 226 237 failed = False 238 239 def stop(x, y): 240 print("Tests interrupted by user", file=sys.stderr) 241 sys.exit(1) 242 signal.signal(signal.SIGINT, stop) 227 243 228 244 # for each test to run … … 260 276 261 277 # clean the workspace 262 make('clean', output =subprocess.DEVNULL, error=subprocess.DEVNULL)278 make('clean', output_file=subprocess.DEVNULL, error=subprocess.DEVNULL) 263 279 264 280 return 1 if failed else 0
Note:
See TracChangeset
for help on using the changeset viewer.