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

Side by Side Diff: build/android/pylib/instrumentation/instrumentation_parser_test.py

Issue 2101243005: Add a snapshot of flutter/engine/src/build to our sdk (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add README.dart Created 4 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
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6
7 """Unit tests for instrumentation.InstrumentationParser."""
8
9 import unittest
10
11 from pylib.instrumentation import instrumentation_parser
12
13
14 class InstrumentationParserTest(unittest.TestCase):
15
16 def testInstrumentationParser_nothing(self):
17 parser = instrumentation_parser.InstrumentationParser([''])
18 statuses = list(parser.IterStatus())
19 code, bundle = parser.GetResult()
20 self.assertEqual(None, code)
21 self.assertEqual({}, bundle)
22 self.assertEqual([], statuses)
23
24 def testInstrumentationParser_noMatchingStarts(self):
25 raw_output = [
26 '',
27 'this.is.a.test.package.TestClass:.',
28 'Test result for =.',
29 'Time: 1.234',
30 '',
31 'OK (1 test)',
32 ]
33
34 parser = instrumentation_parser.InstrumentationParser(raw_output)
35 statuses = list(parser.IterStatus())
36 code, bundle = parser.GetResult()
37 self.assertEqual(None, code)
38 self.assertEqual({}, bundle)
39 self.assertEqual([], statuses)
40
41 def testInstrumentationParser_resultAndCode(self):
42 raw_output = [
43 'INSTRUMENTATION_RESULT: shortMsg=foo bar',
44 'INSTRUMENTATION_RESULT: longMsg=a foo',
45 'walked into',
46 'a bar',
47 'INSTRUMENTATION_CODE: -1',
48 ]
49
50 parser = instrumentation_parser.InstrumentationParser(raw_output)
51 statuses = list(parser.IterStatus())
52 code, bundle = parser.GetResult()
53 self.assertEqual(-1, code)
54 self.assertEqual(
55 {'shortMsg': 'foo bar', 'longMsg': 'a foo\nwalked into\na bar'}, bundle)
56 self.assertEqual([], statuses)
57
58 def testInstrumentationParser_oneStatus(self):
59 raw_output = [
60 'INSTRUMENTATION_STATUS: foo=1',
61 'INSTRUMENTATION_STATUS: bar=hello',
62 'INSTRUMENTATION_STATUS: world=false',
63 'INSTRUMENTATION_STATUS: class=this.is.a.test.package.TestClass',
64 'INSTRUMENTATION_STATUS: test=testMethod',
65 'INSTRUMENTATION_STATUS_CODE: 0',
66 ]
67
68 parser = instrumentation_parser.InstrumentationParser(raw_output)
69 statuses = list(parser.IterStatus())
70
71 expected = [
72 (0, {
73 'foo': '1',
74 'bar': 'hello',
75 'world': 'false',
76 'class': 'this.is.a.test.package.TestClass',
77 'test': 'testMethod',
78 })
79 ]
80 self.assertEqual(expected, statuses)
81
82 def testInstrumentationParser_multiStatus(self):
83 raw_output = [
84 'INSTRUMENTATION_STATUS: class=foo',
85 'INSTRUMENTATION_STATUS: test=bar',
86 'INSTRUMENTATION_STATUS_CODE: 1',
87 'INSTRUMENTATION_STATUS: test_skipped=true',
88 'INSTRUMENTATION_STATUS_CODE: 0',
89 'INSTRUMENTATION_STATUS: class=hello',
90 'INSTRUMENTATION_STATUS: test=world',
91 'INSTRUMENTATION_STATUS: stack=',
92 'foo/bar.py (27)',
93 'hello/world.py (42)',
94 'test/file.py (1)',
95 'INSTRUMENTATION_STATUS_CODE: -1',
96 ]
97
98 parser = instrumentation_parser.InstrumentationParser(raw_output)
99 statuses = list(parser.IterStatus())
100
101 expected = [
102 (1, {'class': 'foo', 'test': 'bar',}),
103 (0, {'test_skipped': 'true'}),
104 (-1, {
105 'class': 'hello',
106 'test': 'world',
107 'stack': '\nfoo/bar.py (27)\nhello/world.py (42)\ntest/file.py (1)',
108 }),
109 ]
110 self.assertEqual(expected, statuses)
111
112 def testInstrumentationParser_statusResultAndCode(self):
113 raw_output = [
114 'INSTRUMENTATION_STATUS: class=foo',
115 'INSTRUMENTATION_STATUS: test=bar',
116 'INSTRUMENTATION_STATUS_CODE: 1',
117 'INSTRUMENTATION_RESULT: result=hello',
118 'world',
119 '',
120 '',
121 'INSTRUMENTATION_CODE: 0',
122 ]
123
124 parser = instrumentation_parser.InstrumentationParser(raw_output)
125 statuses = list(parser.IterStatus())
126 code, bundle = parser.GetResult()
127
128 self.assertEqual(0, code)
129 self.assertEqual({'result': 'hello\nworld\n\n'}, bundle)
130 self.assertEqual([(1, {'class': 'foo', 'test': 'bar'})], statuses)
131
132
133 if __name__ == '__main__':
134 unittest.main(verbosity=2)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698