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

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

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « build/android/gyp/process_resources.py ('k') | build/android/pylib/base/base_test_runner.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 (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 class ResultType(object): 7 class ResultType(object):
8 """Class enumerating test types.""" 8 """Class enumerating test types."""
9 PASS = 'PASS' 9 PASS = 'PASS'
10 SKIP = 'SKIP' 10 SKIP = 'SKIP'
11 FAIL = 'FAIL' 11 FAIL = 'FAIL'
12 CRASH = 'CRASH' 12 CRASH = 'CRASH'
13 TIMEOUT = 'TIMEOUT' 13 TIMEOUT = 'TIMEOUT'
14 UNKNOWN = 'UNKNOWN' 14 UNKNOWN = 'UNKNOWN'
15 15
16 @staticmethod 16 @staticmethod
17 def GetTypes(): 17 def GetTypes():
18 """Get a list of all test types.""" 18 """Get a list of all test types."""
19 return [ResultType.PASS, ResultType.SKIP, ResultType.FAIL, 19 return [ResultType.PASS, ResultType.SKIP, ResultType.FAIL,
20 ResultType.CRASH, ResultType.TIMEOUT, ResultType.UNKNOWN] 20 ResultType.CRASH, ResultType.TIMEOUT, ResultType.UNKNOWN]
21 21
22 22
23 class BaseTestResult(object): 23 class BaseTestResult(object):
24 """Base class for a single test result.""" 24 """Base class for a single test result."""
25 25
26 def __init__(self, name, test_type, log=''): 26 def __init__(self, name, test_type, duration=0, log=''):
27 """Construct a BaseTestResult. 27 """Construct a BaseTestResult.
28 28
29 Args: 29 Args:
30 name: Name of the test which defines uniqueness. 30 name: Name of the test which defines uniqueness.
31 test_type: Type of the test result as defined in ResultType. 31 test_type: Type of the test result as defined in ResultType.
32 duration: Time it took for the test to run in milliseconds.
32 log: An optional string listing any errors. 33 log: An optional string listing any errors.
33 """ 34 """
34 assert name 35 assert name
35 assert test_type in ResultType.GetTypes() 36 assert test_type in ResultType.GetTypes()
36 self._name = name 37 self._name = name
37 self._test_type = test_type 38 self._test_type = test_type
39 self._duration = duration
38 self._log = log 40 self._log = log
39 41
40 def __str__(self): 42 def __str__(self):
41 return self._name 43 return self._name
42 44
43 def __repr__(self): 45 def __repr__(self):
44 return self._name 46 return self._name
45 47
46 def __cmp__(self, other): 48 def __cmp__(self, other):
47 # pylint: disable=W0212 49 # pylint: disable=W0212
(...skipping 11 matching lines...) Expand all
59 self._name = name 61 self._name = name
60 62
61 def GetName(self): 63 def GetName(self):
62 """Get the test name.""" 64 """Get the test name."""
63 return self._name 65 return self._name
64 66
65 def GetType(self): 67 def GetType(self):
66 """Get the test result type.""" 68 """Get the test result type."""
67 return self._test_type 69 return self._test_type
68 70
71 def GetDuration(self):
72 """Get the test duration."""
73 return self._duration
74
69 def GetLog(self): 75 def GetLog(self):
70 """Get the test log.""" 76 """Get the test log."""
71 return self._log 77 return self._log
72 78
73 79
74 class TestRunResults(object): 80 class TestRunResults(object):
75 """Set of results for a test run.""" 81 """Set of results for a test run."""
76 82
77 def __init__(self): 83 def __init__(self):
78 self._results = set() 84 self._results = set()
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 return self._GetType(ResultType.UNKNOWN) 198 return self._GetType(ResultType.UNKNOWN)
193 199
194 def GetNotPass(self): 200 def GetNotPass(self):
195 """Get the set of all non-passed test results.""" 201 """Get the set of all non-passed test results."""
196 return self.GetAll() - self.GetPass() 202 return self.GetAll() - self.GetPass()
197 203
198 def DidRunPass(self): 204 def DidRunPass(self):
199 """Return whether the test run was successful.""" 205 """Return whether the test run was successful."""
200 return not (self.GetNotPass() - self.GetSkip()) 206 return not (self.GetNotPass() - self.GetSkip())
201 207
OLDNEW
« no previous file with comments | « build/android/gyp/process_resources.py ('k') | build/android/pylib/base/base_test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698