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

Side by Side Diff: build/android/pylib/base/base_test_result.py

Issue 18323020: Updates the test runner script exit codes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removes exit_code module, makes sharder handle exit codes Created 7 years, 5 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 | build/android/pylib/base/shard.py » ('j') | build/android/pylib/base/shard.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 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 """Module containing base test results classes.""" 5 """Module containing base test results classes."""
6 6
7 from pylib import constants
frankf 2013/07/04 00:46:19 Remove this
gkanwar 2013/07/08 18:50:25 Done.
7 8
8 class ResultType(object): 9 class ResultType(object):
9 """Class enumerating test types.""" 10 """Class enumerating test types."""
10 PASS = 'PASS' 11 PASS = 'PASS'
11 FAIL = 'FAIL' 12 FAIL = 'FAIL'
12 CRASH = 'CRASH' 13 CRASH = 'CRASH'
13 TIMEOUT = 'TIMEOUT' 14 TIMEOUT = 'TIMEOUT'
14 UNKNOWN = 'UNKNOWN' 15 UNKNOWN = 'UNKNOWN'
15 16
16 @staticmethod 17 @staticmethod
17 def GetTypes(): 18 def GetTypes():
18 """Get a list of all test types.""" 19 """Get a list of all test types."""
19 return [ResultType.PASS, ResultType.FAIL, ResultType.CRASH, 20 return [ResultType.PASS, ResultType.FAIL, ResultType.CRASH,
20 ResultType.TIMEOUT, ResultType.UNKNOWN] 21 ResultType.TIMEOUT, ResultType.UNKNOWN]
21 22
22 23
23 class BaseTestResult(object): 24 class BaseTestResult(object):
24 """Base class for a single test result.""" 25 """Base class for a single test result."""
26
25 def __init__(self, name, test_type, log=''): 27 def __init__(self, name, test_type, log=''):
26 """Construct a BaseTestResult. 28 """Construct a BaseTestResult.
27 29
28 Args: 30 Args:
29 name: Name of the test which defines uniqueness. 31 name: Name of the test which defines uniqueness.
30 test_type: Type of the test result as defined in ResultType. 32 test_type: Type of the test result as defined in ResultType.
31 log: An optional string listing any errors. 33 log: An optional string listing any errors.
32 """ 34 """
33 assert name 35 assert name
34 assert test_type in ResultType.GetTypes() 36 assert test_type in ResultType.GetTypes()
(...skipping 22 matching lines...) Expand all
57 """Get the test result type.""" 59 """Get the test result type."""
58 return self._test_type 60 return self._test_type
59 61
60 def GetLog(self): 62 def GetLog(self):
61 """Get the test log.""" 63 """Get the test log."""
62 return self._log 64 return self._log
63 65
64 66
65 class TestRunResults(object): 67 class TestRunResults(object):
66 """Set of results for a test run.""" 68 """Set of results for a test run."""
69
67 def __init__(self): 70 def __init__(self):
68 self._results = set() 71 self._results = set()
69 72
70 def GetLogs(self): 73 def GetLogs(self):
71 """Get the string representation of all test logs.""" 74 """Get the string representation of all test logs."""
72 s = [] 75 s = []
73 for test_type in ResultType.GetTypes(): 76 for test_type in ResultType.GetTypes():
74 if test_type != ResultType.PASS: 77 if test_type != ResultType.PASS:
75 for t in sorted(self._GetType(test_type)): 78 for t in sorted(self._GetType(test_type)):
76 log = t.GetLog() 79 log = t.GetLog()
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 """Get the set of all unknown test results.""" 161 """Get the set of all unknown test results."""
159 return self._GetType(ResultType.UNKNOWN) 162 return self._GetType(ResultType.UNKNOWN)
160 163
161 def GetNotPass(self): 164 def GetNotPass(self):
162 """Get the set of all non-passed test results.""" 165 """Get the set of all non-passed test results."""
163 return self.GetAll() - self.GetPass() 166 return self.GetAll() - self.GetPass()
164 167
165 def DidRunPass(self): 168 def DidRunPass(self):
166 """Return whether the test run was successful.""" 169 """Return whether the test run was successful."""
167 return not self.GetNotPass() 170 return not self.GetNotPass()
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/base/shard.py » ('j') | build/android/pylib/base/shard.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698