view tests/silenttestrunner.py @ 50179:9e1debbb477e

status: simplify the post status fixup phases With the wlock automatically discarding changes when applicable, we can simplify the code a bit. * we perform the fixup operation before trying to grab the lock to narrow the `try/except` * we no longer need to explicitly complare dirstate identities. We can trust the dirstate internal refresh for that. It would invalidate dirty data when needed. * detect still data invalidation by checking the dirty flag before and after taking the lock. Doing this is actually only necessary to issue the debug message, we could blindy trust the dirstate internal to ignore the `write` call on a non-dirty dirstate.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 21 Feb 2023 16:20:11 +0100
parents 6000f5b25c9b
children
line wrap: on
line source

import os
import sys
import unittest


def main(modulename):
    '''run the tests found in module, printing nothing when all tests pass'''
    module = sys.modules[modulename]
    suite = unittest.defaultTestLoader.loadTestsFromModule(module)
    results = unittest.TestResult()
    suite.run(results)
    if results.errors or results.failures:
        for tc, exc in results.errors:
            print('ERROR:', tc)
            print()
            sys.stdout.write(exc)
        for tc, exc in results.failures:
            print('FAIL:', tc)
            print()
            sys.stdout.write(exc)
        sys.exit(1)


if os.environ.get('SILENT_BE_NOISY'):
    main = unittest.main