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 from expect_tests.type_definitions import Handler, Test, MultiTest | 5 from expect_tests.type_definitions import Handler, Test, MultiTest |
6 | 6 |
7 | 7 |
8 class ListHandler(Handler): | 8 class ListHandler(Handler): |
9 """List all of the tests instead of running them.""" | 9 """List all of the tests instead of running them.""" |
10 SKIP_RUNLOOP = True | 10 SKIP_RUNLOOP = True |
11 | 11 |
12 # Used to collect all bare test names for command line test name completion. | 12 # Used to collect all bare test names for command line test name completion. |
13 COMPLETION_LIST = None | 13 COMPLETION_LIST = None |
14 | 14 |
15 class ResultStageHandler(Handler.ResultStageHandler): | 15 class ResultStageHandler(Handler.ResultStageHandler): |
16 @staticmethod | 16 @staticmethod |
17 def handle_TestInfo(test): | 17 def handle_Test(test): |
18 if ListHandler.COMPLETION_LIST is not None: | 18 if ListHandler.COMPLETION_LIST is not None: |
19 ListHandler.COMPLETION_LIST.append(test.name) | 19 ListHandler.COMPLETION_LIST.append(test.name) |
20 else: | 20 else: |
21 print test.name | 21 print test.name |
22 | 22 |
23 @staticmethod | 23 @staticmethod |
24 def handle_MultiTestInfo(multi_test): | 24 def handle_MultiTest(multi_test): |
25 print 'MultiTestInfo(%r, atomic=%r)' % ( | 25 print 'MultiTestInfo(%r, atomic=%r)' % ( |
26 multi_test.name, multi_test.atomic) | 26 multi_test.name, multi_test.atomic) |
27 for test in multi_test.tests: | 27 for test in multi_test.tests: |
28 if ListHandler.COMPLETION_LIST is not None: | 28 if ListHandler.COMPLETION_LIST is not None: |
29 ListHandler.COMPLETION_LIST.append(test.name) | 29 ListHandler.COMPLETION_LIST.append(test.name) |
30 else: | 30 else: |
31 print '|', test.name | 31 print '|', test.name |
32 | 32 |
33 # TODO(iannucci): group tests by dir? | 33 # TODO(iannucci): group tests by dir? |
34 # TODO(iannucci): print more data about the test in verbose mode? | 34 # TODO(iannucci): print more data about the test in verbose mode? |
(...skipping 14 matching lines...) Expand all Loading... |
49 Function to push an object to the result stage of the pipeline. | 49 Function to push an object to the result stage of the pipeline. |
50 """ | 50 """ |
51 for test in tests: | 51 for test in tests: |
52 if isinstance(test, (Test, MultiTest)): | 52 if isinstance(test, (Test, MultiTest)): |
53 test = test.get_info() | 53 test = test.get_info() |
54 | 54 |
55 else: | 55 else: |
56 raise TypeError('ListHandler.gen_stage_loop cannot handle type %s' | 56 raise TypeError('ListHandler.gen_stage_loop cannot handle type %s' |
57 % test.__class__.__name__) | 57 % test.__class__.__name__) |
58 put_next_stage(test) | 58 put_next_stage(test) |
OLD | NEW |