tests/heredoctest.py
author Augie Fackler <raf@durin42.com>
Tue, 29 Dec 2015 18:11:14 -0500
changeset 27556 1df9b8b2abda
parent 27297 4179d054b3e9
child 29485 6a98f9408a50
permissions -rw-r--r--
test-glog: avoid check-code violation after next patch Danek's patch will help us avoid spurious test breakages on Solaris. This test wasn't broken on Solaris because of the grep(1) use, but it will upset check-code. Use cmp to silence check-code since it doesn't matter.

from __future__ import absolute_import

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, globalvars)
        except Exception as inst:
            print(repr(inst))