run.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:stestr 作者: mtreinish 项目源码 文件源码
def _run_tests(cmd, failing, analyze_isolation, isolated, until_failure,
               subunit_out=False, combine_id=None, repo_type='file',
               repo_url=None, pretty_out=True, color=False, stdout=sys.stdout,
               abbreviate=False):
    """Run the tests cmd was parameterised with."""
    cmd.setUp()
    try:
        def run_tests():
            run_procs = [('subunit',
                          output.ReturnCodeToSubunit(
                              proc)) for proc in cmd.run_tests()]
            if not run_procs:
                stdout.write("The specified regex doesn't match with anything")
                return 1
            return load.load((None, None), in_streams=run_procs,
                             subunit_out=subunit_out,
                             repo_type=repo_type,
                             repo_url=repo_url, run_id=combine_id,
                             pretty_out=pretty_out, color=color, stdout=stdout,
                             abbreviate=abbreviate)

        if not until_failure:
            return run_tests()
        else:
            while True:
                result = run_tests()
                # If we're using subunit output we want to make sure to check
                # the result from the repository because load() returns 0
                # always on subunit output
                if subunit_out:
                    repo = util.get_repo_open(repo_type, repo_url)
                    summary = testtools.StreamSummary()
                    last_run = repo.get_latest_run().get_subunit_stream()
                    stream = subunit.ByteStreamToStreamResult(last_run)
                    summary.startTestRun()
                    try:
                        stream.run(summary)
                    finally:
                        summary.stopTestRun()
                    if not summary.wasSuccessful():
                        result = 1
                if result:
                    return result
    finally:
        cmd.cleanUp()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号