Changeset 172a88d


Ignore:
Timestamp:
Sep 30, 2021, 2:17:03 PM (2 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
master
Children:
96f01d7f
Parents:
056cbdb
Message:

Tests now count failures, passes, timeouts and report the number

Location:
tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tests/pybin/test_run.py

    r056cbdb r172a88d  
    6565        def toString( cls, retcode, duration ):
    6666                if settings.generating :
    67                         if   retcode == TestResult.SUCCESS:     text = "Done   "
    68                         elif retcode == TestResult.TIMEOUT:     text = "TIMEOUT"
    69                         else :                                          text = "ERROR code %d" % retcode
     67                        if   retcode == TestResult.SUCCESS:     key = 'pass'; text = "Done   "
     68                        elif retcode == TestResult.TIMEOUT:     key = 'time'; text = "TIMEOUT"
     69                        else :  key = 'fail';   text = "ERROR code %d" % retcode
    7070                else :
    71                         if   retcode == TestResult.SUCCESS:     text = "PASSED "
    72                         elif retcode == TestResult.TIMEOUT:     text = "TIMEOUT"
    73                         else :                                          text = "FAILED with code %d" % retcode
     71                        if   retcode == TestResult.SUCCESS:     key = 'pass'; text = "PASSED "
     72                        elif retcode == TestResult.TIMEOUT:     key = 'time'; text = "TIMEOUT"
     73                        else :  key = 'fail';   text = "FAILED with code %d" % retcode
    7474
    7575                text += "    C%s - R%s" % (fmtDur(duration[0]), fmtDur(duration[1]))
    76                 return text
     76                return key, text
  • tests/test.py

    r056cbdb r172a88d  
    257257
    258258                # update output based on current action
    259                 result_txt = TestResult.toString( retcode, duration )
     259                result_key, result_txt = TestResult.toString( retcode, duration )
    260260
    261261                #print result with error if needed
     
    265265                        text = text + '\n' + error
    266266
    267                 return retcode == TestResult.SUCCESS, text
     267                return retcode == TestResult.SUCCESS, result_key, text
    268268        except KeyboardInterrupt:
    269                 return False, ""
     269                return False, 'keybrd', ""
    270270        # except Exception as ex:
    271271        #       print("Unexpected error in worker thread running {}: {}".format(t.target(), ex), file=sys.stderr)
     
    283283
    284284        failed = False
     285        rescnts = {     'pass': 0, 'fail': 0, 'time': 0, 'keybrd': 0 }
     286        other = 0
    285287
    286288        # for each test to run
     
    294296                )
    295297
    296                 for i, (succ, txt) in enumerate(timed(results, timeout = settings.timeout.total), 1) :
     298                for i, (succ, code, txt) in enumerate(timed(results, timeout = settings.timeout.total), 1) :
     299                        if code in rescnts.keys():
     300                                rescnts[code] += 1
     301                        else:
     302                                other += 1
     303
    297304                        if not succ :
    298305                                failed = True
     
    319326        # clean the workspace
    320327        make('clean', output_file=subprocess.DEVNULL, error=subprocess.DEVNULL)
     328
     329        print("{} passes, {} failures, {} timeouts, {} cancelled, {} other".format(rescnts['pass'], rescnts['fail'], rescnts['time'], rescnts['keybrd'], other))
    321330
    322331        return failed
     
    443452                        failed = run_tests(local_tests, options.jobs)
    444453                        if failed:
    445                                 result = 1
    446454                                if not settings.continue_:
    447455                                        break
Note: See TracChangeset for help on using the changeset viewer.