Changeset 3d5701e for tests/test.py


Ignore:
Timestamp:
Feb 25, 2020, 1:17:33 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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.
Message:

resolve conflict

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/test.py

    r9fb8f01 r3d5701e  
    1010import tempfile
    1111import time
     12
     13import os
     14import psutil
     15import signal
    1216
    1317################################################################################
     
    143147        # build, skipping to next test on error
    144148        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 )
    146150
    147151        run_dur = None
    148152        # run everything in a temp directory to make sure core file are handled properly
    149153        with tempdir():
    150                 # if the make command succeds continue otherwise skip to diff
     154                # if the make command succeeds continue otherwise skip to diff
    151155                if success(make_ret):
    152156                        with Timed() as run_dur:
    153157                                if settings.dry_run or is_exe(exe_file):
    154158                                        # 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)
    156160                                else :
    157161                                        # simply cat the result into the output
     
    210214        except KeyboardInterrupt:
    211215                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)
    214218                sys.stderr.flush()
    215219                return False, ""
     
    219223def run_tests(tests, jobs) :
    220224        # 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)
    222233
    223234        # create the executor for our jobs and handle the signal properly
    224         pool = multiprocessing.Pool(jobs)
     235        pool = multiprocessing.Pool(jobs, worker_init)
    225236
    226237        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)
    227243
    228244        # for each test to run
     
    260276
    261277        # clean the workspace
    262         make('clean', output=subprocess.DEVNULL, error=subprocess.DEVNULL)
     278        make('clean', output_file=subprocess.DEVNULL, error=subprocess.DEVNULL)
    263279
    264280        return 1 if failed else 0
Note: See TracChangeset for help on using the changeset viewer.