OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import sys | 5 import sys |
6 import time | 6 import time |
7 import collections | 7 import collections |
8 | 8 |
9 from cStringIO import StringIO | 9 from cStringIO import StringIO |
10 | 10 |
11 from .type_definitions import Handler, Failure | 11 from .type_definitions import Handler, Failure |
12 from .serialize import GetCurrentData, DiffData, NonExistant | 12 from .serialize import GetCurrentData, DiffData, NonExistant |
13 | 13 |
14 | 14 |
15 Missing = collections.namedtuple('Missing', 'test log_lines') | 15 Missing = collections.namedtuple('Missing', 'test log_lines') |
16 Fail = collections.namedtuple('Fail', 'test diff log_lines') | 16 Fail = collections.namedtuple('Fail', 'test diff log_lines') |
17 Pass = collections.namedtuple('Pass', 'test') | 17 Pass = collections.namedtuple('Pass', 'test') |
18 | 18 |
19 | 19 |
20 class TestHandler(Handler): | 20 class TestHandler(Handler): |
21 """Run the tests.""" | 21 """Run the tests.""" |
22 @classmethod | 22 @classmethod |
23 def run_stage_loop(cls, _opts, results, put_next_stage): | 23 def run_stage_loop(cls, _opts, results, put_next_stage): |
24 for test, result, log_lines in results: | 24 for test, result, log_lines in results: |
25 current, _ = GetCurrentData(test) | 25 current, _ = GetCurrentData(test) |
26 if current is NonExistant: | 26 if current is NonExistant and result.data is not None: |
27 put_next_stage(Missing(test, log_lines)) | 27 put_next_stage(Missing(test, log_lines)) |
28 else: | 28 else: |
29 diff = DiffData(current, result.data) | 29 diff = DiffData(current, result.data) |
30 if not diff: | 30 if not diff: |
31 put_next_stage(Pass(test)) | 31 put_next_stage(Pass(test)) |
32 else: | 32 else: |
33 put_next_stage(Fail(test, diff, log_lines)) | 33 put_next_stage(Fail(test, diff, log_lines)) |
34 | 34 |
35 class ResultStageHandler(Handler.ResultStageHandler): | 35 class ResultStageHandler(Handler.ResultStageHandler): |
36 def __init__(self, *args): | 36 def __init__(self, *args): |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 self.num_tests, time.time() - self.start) | 104 self.num_tests, time.time() - self.start) |
105 print | 105 print |
106 if aborted: | 106 if aborted: |
107 print 'ABORTED' | 107 print 'ABORTED' |
108 elif self.errors: | 108 elif self.errors: |
109 print 'FAILED (%s)' % (', '.join('%s=%d' % i | 109 print 'FAILED (%s)' % (', '.join('%s=%d' % i |
110 for i in self.errors.iteritems())) | 110 for i in self.errors.iteritems())) |
111 elif not self.opts.quiet: | 111 elif not self.opts.quiet: |
112 print 'OK' | 112 print 'OK' |
113 | 113 |
OLD | NEW |