tests/heredoctest.py
author Augie Fackler <augie@google.com>
Fri, 13 Mar 2015 12:50:53 -0400
changeset 24331 d3bdd8c7174f
parent 22565 8d45a42b0c0f
child 25032 1db2127d2373
permissions -rw-r--r--
run-tests: stop storing start/stop times in a dict by test name This resolves the last breakage in run-tests that prevented me from running a single test many times in several threads in parallel. This will be useful for testing potential fixes to flaky tests.

import sys

globalvars = {}
lines = sys.stdin.readlines()
while lines:
    l = lines.pop(0)
    if l.startswith('SALT'):
        print l[:-1]
    elif l.startswith('>>> '):
        snippet = l[4:]
        while lines and lines[0].startswith('... '):
            l = lines.pop(0)
            snippet += l[4:]
        c = compile(snippet, '<heredoc>', 'single')
        try:
            exec c in globalvars
        except Exception, inst:
            print repr(inst)