57
56
Input lines start with '<'.
58
57
Output lines start with nothing.
59
58
Error lines start with '2>'.
61
:return: A sequence of ([args], input, output, errors), where the args are
62
split in to words, and the input, output, and errors are just strings,
63
typically containing newlines.
81
76
input, output, error = None, None, None
82
77
text = textwrap.dedent(text)
83
lines = text.split('\n')
84
# to make use of triple-quoted strings easier, we ignore a blank line
85
# right at the start and right at the end; the rest are meaningful
86
if lines and lines[0] == '':
88
if lines and lines[-1] == '':
78
for line in text.split('\n'):
92
80
# Keep a copy for error reporting
94
82
comment = line.find('#')
97
# NB: this syntax means comments are allowed inside output, which
99
85
line = line[0:comment]
100
86
line = line.rstrip()
103
90
if line.startswith('$'):
104
91
# Time to output the current command
105
92
add_command(cmd_cur, input, output, error)
222
209
retcode, actual_output, actual_error = method(test_case,
226
self._check_output(output, actual_output, test_case)
227
except AssertionError, e:
228
raise AssertionError(str(e) + " in stdout of command %s" % cmd)
230
self._check_output(error, actual_error, test_case)
231
except AssertionError, e:
232
raise AssertionError(str(e) +
233
" in stderr of running command %s" % cmd)
212
self._check_output(output, actual_output, test_case)
213
self._check_output(error, actual_error, test_case)
234
214
if retcode and not error and actual_error:
235
215
test_case.fail('In \n\t%s\nUnexpected error: %s'
236
216
% (' '.join(cmd), actual_error))
237
217
return retcode, actual_output, actual_error
239
219
def _check_output(self, expected, actual, test_case):
243
elif expected == '...\n':
246
test_case.fail('expected output: %r, but found nothing'
248
expected = expected or ''
221
# Specifying None means: any output is accepted
224
test_case.fail('We expected output: %r, but found None'
249
226
matching = self.output_checker.check_output(
250
227
expected, actual, self.check_options)
255
232
# 'expected' parameter. So we just fallback to our good old
256
233
# assertEqualDiff since we know there *are* differences and the
257
234
# output should be decently readable.
259
# As a special case, we allow output that's missing a final
260
# newline to match an expected string that does have one, so that
261
# we can match a prompt printed on one line, then input given on
263
if expected == actual + '\n':
266
test_case.assertEqualDiff(expected, actual)
235
test_case.assertEqualDiff(expected, actual)
268
237
def _pre_process_args(self, args):