Changeset e791851


Ignore:
Timestamp:
Jun 25, 2019, 3:19:49 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
ab8315f
Parents:
8ecb590
Message:

Tests now print progress as they go if run in a tty

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/test.py

    r8ecb590 re791851  
    202202                if error :
    203203                        text = text + '\n' + error
    204                         out = sys.stderr
    205 
    206                 print(text, file = out)
    207                 sys.stdout.flush()
    208                 sys.stderr.flush()
    209 
    210                 return retcode != TestResult.SUCCESS
     204
     205                return retcode == TestResult.SUCCESS, text
    211206        except KeyboardInterrupt:
    212                 False
     207                False, ""
    213208
    214209# run the given list of tests with the given parameters
     
    220215        pool = multiprocessing.Pool(jobs)
    221216
     217        failed = False
     218
    222219        # for each test to run
    223220        try :
    224                 results = pool.map_async(
     221                num = len(tests)
     222                fancy = sys.stdout.isatty()
     223                for i, (succ, txt) in enumerate(pool.imap(
    225224                        run_test_worker,
    226225                        tests,
    227226                        chunksize = 1
    228                 ).get(settings.timeout.total)
     227                )) :
     228                        if not succ :
     229                                failed = True
     230
     231                        print("       " + txt)
     232
     233                        if(fancy and i != num):
     234                                print("%d/%d" % (i, num), end='\r')
     235                                sys.stdout.flush()
     236
    229237        except KeyboardInterrupt:
    230238                pool.terminate()
    231                 print("Tests interrupted by user")
    232                 sys.exit(1)
     239                print("Tests interrupted by user", file=sys.stderr)
     240                failed = True
     241        except multiprocessing.TimeoutError:
     242                pool.terminate()
     243                print("ERROR: Test suite timed out", file=sys.stderr)
     244                failed = True
    233245
    234246        # clean the workspace
    235247        make('clean', output=subprocess.DEVNULL, error=subprocess.DEVNULL)
    236248
    237         for failed in results:
    238                 if failed :
    239                         return 1
    240 
    241         return 0
     249        return 1 if failed else 0
    242250
    243251
Note: See TracChangeset for help on using the changeset viewer.