~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/script.py

  • Committer: Martin Pool
  • Date: 2010-09-13 08:14:44 UTC
  • mto: (5416.1.8 ui-factory)
  • mto: This revision was merged to the branch mainline in revision 5422.
  • Revision ID: mbp@sourcefrog.net-20100913081444-63v2l3wqb9e45ab3
Better handling of blank lines in test scripts

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
    lineno = 0
80
80
    input, output, error = None, None, None
81
81
    text = textwrap.dedent(text)
82
 
    for line in text.split('\n'):
 
82
    lines = text.split('\n')
 
83
    # to make use of triple-quoted strings easier, we ignore a blank line
 
84
    # right at the start and right at the end; the rest are meaningful
 
85
    if lines and lines[0] == '':
 
86
        del lines[0]
 
87
    if lines and lines[-1] == '':
 
88
        del lines[-1]
 
89
    for line in lines:
83
90
        lineno += 1
84
91
        # Keep a copy for error reporting
85
92
        orig = line
86
93
        comment =  line.find('#')
87
94
        if comment >= 0:
88
95
            # Delete comments
 
96
            # NB: this syntax means comments are allowed inside output, which
 
97
            # may be confusing...
89
98
            line = line[0:comment]
90
99
            line = line.rstrip()
91
 
        if line == '':
92
 
            # Ignore empty lines
93
 
            continue
 
100
            if line == '':
 
101
                continue
94
102
        if line.startswith('$'):
95
103
            # Time to output the current command
96
104
            add_command(cmd_cur, input, output, error)