Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/test.py

    rced2e989 r38736854  
    22from __future__ import print_function
    33
    4 from functools import partial
    5 from multiprocessing import Pool
    64from os import listdir, environ
    75from os.path import isfile, join, splitext
     
    104102#               running test functions
    105103################################################################################
    106 def run_single_test(test, generate, dry_run):
     104def run_test_instance(test, generate, dry_run):
    107105
    108106        # find the output file based on the test name and options flag
     
    165163        return retcode, error
    166164
    167 def run_test_instance(t, generate, dry_run) :
    168         # print formated name
    169         name_txt = "%20s  " % t.name
    170 
    171         #run the test instance and collect the result
    172         test_failed, error = run_single_test(t, generate, dry_run)
    173 
    174         # update output based on current action
    175         if generate :
    176                 failed_txt = "ERROR"
    177                 success_txt = "Done"
    178         else :
    179                 failed_txt = "FAILED"
    180                 success_txt = "PASSED"
    181 
    182         #print result with error if needed
    183         text = name_txt + (failed_txt if test_failed else success_txt)
    184         out = sys.stdout
    185         if error :
    186                 text = text + "\n" + error
    187                 out = sys.stderr
    188 
    189         print(text, file = out);
    190         sys.stdout.flush()
    191         sys.stderr.flush()
    192 
    193         return test_failed
    194 
    195165# run the given list of tests with the given parameters
    196166def run_tests(tests, generate, dry_run, jobs) :
     
    204174                print( "Regenerate tests for: " )
    205175
    206         # for each test to run
    207         pool = Pool(jobs)
    208         try :
    209                 results = pool.map_async(partial(run_test_instance, generate=generate, dry_run=dry_run), tests ).get(99999999)
    210         except KeyboardInterrupt:
    211                 pool.terminate()
    212                 print("Tests interrupted by user")
    213                 sys.exit(1)
     176        failed = False;
     177        # for eeach test to run
     178        for t in tests:
     179                # print formated name
     180                name_txt = "%20s  " % t.name
     181
     182                #run the test instance and collect the result
     183                test_failed, error = run_test_instance(t, generate, dry_run)
     184
     185                # aggregate test suite result
     186                failed = test_failed or failed
     187
     188                # update output based on current action
     189                if generate :
     190                        failed_txt = "ERROR"
     191                        success_txt = "Done"
     192                else :
     193                        failed_txt = "FAILED"
     194                        success_txt = "PASSED"
     195
     196                #print result with error if needed
     197                text = name_txt + (failed_txt if test_failed else success_txt)
     198                out = sys.stdout
     199                if error :
     200                        text = text + "\n" + error
     201                        out = sys.stderr
     202
     203                print(text, file = out);
     204                sys.stdout.flush()
     205                sys.stderr.flush()
     206
    214207
    215208        #clean the workspace
    216209        sh("%s clean > /dev/null 2>&1" % make_cmd, dry_run)
    217210
    218         for failed in results:
    219                 if failed :
    220                         return 1
    221 
    222         return 0
     211        return 1 if failed else 0
    223212
    224213################################################################################
     
    290279
    291280# make sure we have a valid number of jobs that corresponds to user input
    292 options.jobs = int(make_max_jobs) if make_max_jobs else (options.jobs if options.jobs else 1)
     281options.jobs = int(make_max_jobs) if make_max_jobs else options.jobs
    293282if options.jobs <= 0 :
    294283        print('ERROR: Invalid number of jobs', file=sys.stderr)
    295284        sys.exit(1)
    296285
    297 print('Running on %i cores' % options.jobs)
    298 
    299286# users may want to simply list the tests
    300287if options.list :
Note: See TracChangeset for help on using the changeset viewer.