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

Side by Side Diff: build/android/pylib/gtest/gtest_test_instance_test.py

Issue 2014333002: [Android] Fix unknown handling in gtest_test_instance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: disable failing tests Created 4 years, 7 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import unittest 6 import unittest
7 7
8 from pylib.base import base_test_result
8 from pylib.gtest import gtest_test_instance 9 from pylib.gtest import gtest_test_instance
9 10
10 11
11 class GtestTestInstanceTests(unittest.TestCase): 12 class GtestTestInstanceTests(unittest.TestCase):
12 13
13 def testParseGTestListTests_simple(self): 14 def testParseGTestListTests_simple(self):
14 raw_output = [ 15 raw_output = [
15 'TestCaseOne.', 16 'TestCaseOne.',
16 ' testOne', 17 ' testOne',
17 ' testTwo', 18 ' testTwo',
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 ' testWithValueParam/0 # GetParam() = 0', 74 ' testWithValueParam/0 # GetParam() = 0',
74 ' testWithValueParam/1 # GetParam() = 1', 75 ' testWithValueParam/1 # GetParam() = 1',
75 ] 76 ]
76 actual = gtest_test_instance.ParseGTestListTests(raw_output) 77 actual = gtest_test_instance.ParseGTestListTests(raw_output)
77 expected = [ 78 expected = [
78 'VPTestCase.testWithValueParam/0', 79 'VPTestCase.testWithValueParam/0',
79 'VPTestCase.testWithValueParam/1', 80 'VPTestCase.testWithValueParam/1',
80 ] 81 ]
81 self.assertEqual(expected, actual) 82 self.assertEqual(expected, actual)
82 83
84 def testParseGTestOutput_pass(self):
85 raw_output = [
86 '[ RUN ] FooTest.Bar',
87 '[ OK ] FooTest.Bar (1 ms)',
88 ]
89 actual = gtest_test_instance.ParseGTestOutput(raw_output)
90 self.assertEquals(1, len(actual))
91 self.assertEquals('FooTest.Bar', actual[0].GetName())
92 self.assertEquals(1, actual[0].GetDuration())
93 self.assertEquals(base_test_result.ResultType.PASS, actual[0].GetType())
94
95 def testParseGTestOutput_fail(self):
96 raw_output = [
97 '[ RUN ] FooTest.Bar',
98 '[ FAILED ] FooTest.Bar (1 ms)',
99 ]
100 actual = gtest_test_instance.ParseGTestOutput(raw_output)
101 self.assertEquals(1, len(actual))
102 self.assertEquals('FooTest.Bar', actual[0].GetName())
103 self.assertEquals(1, actual[0].GetDuration())
104 self.assertEquals(base_test_result.ResultType.FAIL, actual[0].GetType())
105
106 def testParseGTestOutput_crash(self):
107 raw_output = [
108 '[ RUN ] FooTest.Bar',
109 '[ CRASHED ] FooTest.Bar (1 ms)',
110 ]
111 actual = gtest_test_instance.ParseGTestOutput(raw_output)
112 self.assertEquals(1, len(actual))
113 self.assertEquals('FooTest.Bar', actual[0].GetName())
114 self.assertEquals(1, actual[0].GetDuration())
115 self.assertEquals(base_test_result.ResultType.CRASH, actual[0].GetType())
116
117 def testParseGTestOutput_errorCrash(self):
118 raw_output = [
119 '[ RUN ] FooTest.Bar',
120 '[ERROR:blah] Currently running: FooTest.Bar',
121 ]
122 actual = gtest_test_instance.ParseGTestOutput(raw_output)
123 self.assertEquals(1, len(actual))
124 self.assertEquals('FooTest.Bar', actual[0].GetName())
125 self.assertEquals(0, actual[0].GetDuration())
126 self.assertEquals(base_test_result.ResultType.CRASH, actual[0].GetType())
127
128 def testParseGTestOutput_unknown(self):
129 raw_output = [
130 '[ RUN ] FooTest.Bar',
131 ]
132 actual = gtest_test_instance.ParseGTestOutput(raw_output)
133 self.assertEquals(1, len(actual))
134 self.assertEquals('FooTest.Bar', actual[0].GetName())
135 self.assertEquals(0, actual[0].GetDuration())
136 self.assertEquals(base_test_result.ResultType.UNKNOWN, actual[0].GetType())
137
138 def testParseGTestOutput_nonterminalUnknown(self):
139 raw_output = [
140 '[ RUN ] FooTest.Bar',
141 '[ RUN ] FooTest.Baz',
142 '[ OK ] FooTest.Baz (1 ms)',
143 ]
144 actual = gtest_test_instance.ParseGTestOutput(raw_output)
145 self.assertEquals(2, len(actual))
146
147 self.assertEquals('FooTest.Bar', actual[0].GetName())
148 self.assertEquals(0, actual[0].GetDuration())
149 self.assertEquals(base_test_result.ResultType.UNKNOWN, actual[0].GetType())
150
151 self.assertEquals('FooTest.Baz', actual[1].GetName())
152 self.assertEquals(1, actual[1].GetDuration())
153 self.assertEquals(base_test_result.ResultType.PASS, actual[1].GetType())
154
83 155
84 if __name__ == '__main__': 156 if __name__ == '__main__':
85 unittest.main(verbosity=2) 157 unittest.main(verbosity=2)
86 158
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/gtest_test_instance.py ('k') | build/android/pylib/local/device/local_device_gtest_run.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698