~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to buildout-templates/bin/retest.in

  • Committer: Launchpad Patch Queue Manager
  • Date: 2012-01-05 16:22:45 UTC
  • mfrom: (14584.1.3 fix-retest-colorize)
  • Revision ID: launchpad@pqm.canonical.com-20120105162245-cvhcg00ousz00rtu
[r=allenap][no-qa] Remove terminal color codes from input in
 bin/retest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
import os
29
29
import re
30
30
import sys
31
 
from itertools import takewhile
 
31
from itertools import takewhile, imap
32
32
 
33
33
${python-relative-path-setup}
34
34
 
38
38
# Regular expression to match numbered stories.
39
39
STORY_RE = re.compile("(.*)/\d{2}-.*")
40
40
 
 
41
# Regular expression to remove terminal color escapes.
 
42
COLOR_RE = re.compile("\x1b[[][0-9;]+m")
 
43
 
 
44
 
 
45
def decolorize(text):
 
46
    """Remove all ANSI terminal color escapes from `text`."""
 
47
    return COLOR_RE.sub("", text)
 
48
 
41
49
 
42
50
def get_test_name(test):
43
51
    """Get the test name of a failed test.
91
99
 
92
100
 
93
101
if __name__ == '__main__':
94
 
    tests = extract_tests(fileinput.input())
 
102
    lines = imap(decolorize, fileinput.input())
 
103
    tests = extract_tests(lines)
95
104
    if len(tests) >= 1:
96
105
        run_tests(tests)
97
106
    else: