Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/test.py

    r103c292 rdcfedca  
    1010import tempfile
    1111import time
    12 
    13 import os
    14 import psutil
    15 import signal
    1612
    1713################################################################################
     
    147143        # build, skipping to next test on error
    148144        with Timed() as comp_dur:
    149                 make_ret, _ = make( test.target(), output_file=subprocess.DEVNULL, error=out_file, error_file = err_file )
     145                make_ret, _ = make( test.target(), output=subprocess.DEVNULL, error=out_file, error_file = err_file )
    150146
    151147        run_dur = None
    152148        # run everything in a temp directory to make sure core file are handled properly
    153149        with tempdir():
    154                 # if the make command succeeds continue otherwise skip to diff
     150                # if the make command succeds continue otherwise skip to diff
    155151                if success(make_ret):
    156152                        with Timed() as run_dur:
    157153                                if settings.dry_run or is_exe(exe_file):
    158154                                        # run test
    159                                         retcode, _ = sh(exe_file, output_file=out_file, input_file=in_file, timeout=True)
     155                                        retcode, _ = sh(exe_file, output=out_file, input=in_file, timeout=True)
    160156                                else :
    161157                                        # simply cat the result into the output
     
    214210        except KeyboardInterrupt:
    215211                return False, ""
    216         except Exception as ex:
    217                 print("Unexpected error in worker thread: %s" % ex, file=sys.stderr)
     212        except:
     213                print("Unexpected error in worker thread", file=sys.stderr)
    218214                sys.stderr.flush()
    219215                return False, ""
     
    223219def run_tests(tests, jobs) :
    224220        # clean the sandbox from previous commands
    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)
     221        make('clean', output=subprocess.DEVNULL, error=subprocess.DEVNULL)
    233222
    234223        # create the executor for our jobs and handle the signal properly
    235         pool = multiprocessing.Pool(jobs, worker_init)
     224        pool = multiprocessing.Pool(jobs)
    236225
    237226        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)
    243227
    244228        # for each test to run
     
    276260
    277261        # clean the workspace
    278         make('clean', output_file=subprocess.DEVNULL, error=subprocess.DEVNULL)
     262        make('clean', output=subprocess.DEVNULL, error=subprocess.DEVNULL)
    279263
    280264        return 1 if failed else 0
Note: See TracChangeset for help on using the changeset viewer.