|
2 | 2 | # Use of this source code is governed by a BSD-style license that can be |
3 | 3 | # found in the LICENSE file. |
4 | 4 |
|
5 | | -import collections |
6 | 5 | import itertools |
7 | 6 |
|
| 7 | +from ..testproc.base import ( |
| 8 | + DROP_RESULT, DROP_OUTPUT, DROP_PASS_OUTPUT, DROP_PASS_STDOUT) |
8 | 9 | from ..local import statusfile |
9 | 10 | from ..testproc.result import Result |
10 | 11 |
|
|
14 | 15 |
|
15 | 16 |
|
16 | 17 | class BaseOutProc(object): |
17 | | - def process(self, output): |
18 | | - return Result(self.has_unexpected_output(output), output) |
| 18 | + def process(self, output, reduction=None): |
| 19 | + has_unexpected_output = self.has_unexpected_output(output) |
| 20 | + return self._create_result(has_unexpected_output, output, reduction) |
19 | 21 |
|
20 | 22 | def has_unexpected_output(self, output): |
21 | 23 | return self.get_outcome(output) not in self.expected_outcomes |
22 | 24 |
|
| 25 | + def _create_result(self, has_unexpected_output, output, reduction): |
| 26 | + """Creates Result instance. When reduction is passed it tries to drop some |
| 27 | + parts of the result to save memory and time needed to send the result |
| 28 | + across process boundary. None disables reduction and full result is created. |
| 29 | + """ |
| 30 | + if reduction == DROP_RESULT: |
| 31 | + return None |
| 32 | + if reduction == DROP_OUTPUT: |
| 33 | + return Result(has_unexpected_output, None) |
| 34 | + if not has_unexpected_output: |
| 35 | + if reduction == DROP_PASS_OUTPUT: |
| 36 | + return Result(has_unexpected_output, None) |
| 37 | + if reduction == DROP_PASS_STDOUT: |
| 38 | + return Result(has_unexpected_output, output.without_text()) |
| 39 | + |
| 40 | + return Result(has_unexpected_output, output) |
| 41 | + |
23 | 42 | def get_outcome(self, output): |
24 | 43 | if output.HasCrashed(): |
25 | 44 | return statusfile.CRASH |
|
0 commit comments