Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: expect_tests/handle_list.py

Issue 560173002: Simplify objects passed to the result stage (Closed) Base URL: https://chromium.googlesource.com/infra/testing/expect_tests@subprocess
Patch Set: Fixed one line length Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | expect_tests/type_definitions.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 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_Test(test): 17 def handle_TestInfo(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_MultiTest(multi_test): 24 def handle_MultiTestInfo(multi_test):
25 print 'MultiTest(%r, atomic=%r)' % (multi_test.name, multi_test.atomic) 25 print 'MultiTestInfo(%r, atomic=%r)' % (
26 multi_test.name, multi_test.atomic)
26 for test in multi_test.tests: 27 for test in multi_test.tests:
27 if ListHandler.COMPLETION_LIST is not None: 28 if ListHandler.COMPLETION_LIST is not None:
28 ListHandler.COMPLETION_LIST.append(test.name) 29 ListHandler.COMPLETION_LIST.append(test.name)
29 else: 30 else:
30 print '|', test.name 31 print '|', test.name
31 32
32 # TODO(iannucci): group tests by dir? 33 # TODO(iannucci): group tests by dir?
33 # TODO(iannucci): print more data about the test in verbose mode? 34 # TODO(iannucci): print more data about the test in verbose mode?
35
36 @classmethod
37 def gen_stage_loop(cls, _opts, tests, put_next_stage, _put_result_stage):
38 """Called in the GenStage portion of the pipeline.
39
40 @param opts: Parsed CLI options
41 @param tests:
42 Iterable of type_definitions.Test or type_definitions.MultiTest
43 objects.
44 @param put_next_stage:
45 Function to push an object to the next stage of the pipeline (RunStage).
46 Note that you should push the item you got from |tests|, not the
47 subtests, in the case that the item is a MultiTest.
48 @param put_result_stage:
49 Function to push an object to the result stage of the pipeline.
50 """
51 for test in tests:
52 if isinstance(test, (Test, MultiTest)):
53 test = test.get_info()
54
55 else:
56 raise TypeError('ListHandler.gen_stage_loop cannot handle type %s'
57 % test.__class__.__name__)
58 put_next_stage(test)
OLDNEW
« no previous file with comments | « no previous file | expect_tests/type_definitions.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698