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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/queries_unittest.py

Issue 2192403002: Remove MockOptions, and replace all usages of it with optparse.Values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 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 # Copyright (C) 2009 Google Inc. All rights reserved. 1 # Copyright (C) 2009 Google Inc. All rights reserved.
2 # Copyright (C) 2012 Intel Corporation. All rights reserved. 2 # Copyright (C) 2012 Intel Corporation. All rights reserved.
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer 11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the 12 # in the documentation and/or other materials provided with the
13 # distribution. 13 # distribution.
14 # * Neither the name of Google Inc. nor the names of its 14 # * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived from 15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission. 16 # this software without specific prior written permission.
17 # 17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 import optparse
30 import unittest 31 import unittest
31 32
32 from webkitpy.common.system.outputcapture import OutputCapture 33 from webkitpy.common.system.outputcapture import OutputCapture
33 from webkitpy.tool.commands.queries import * 34 from webkitpy.tool.commands.queries import PrintBaselines
34 from webkitpy.tool.mock_tool import MockWebKitPatch, MockOptions 35 from webkitpy.tool.commands.queries import PrintExpectations
36 from webkitpy.tool.mock_tool import MockWebKitPatch
35 37
36 38
37 class PrintExpectationsTest(unittest.TestCase): 39 class PrintExpectationsTest(unittest.TestCase):
38 40
39 def run_test(self, tests, expected_stdout, platform='test-win-win7', **kwarg s): 41 def run_test(self, tests, expected_stdout, platform='test-win-win7', **kwarg s):
40 options_defaults = { 42 options_defaults = {
41 'all': False, 'csv': False, 'full': False, 'platform': platform, 43 'all': False, 'csv': False, 'full': False, 'platform': platform,
42 'include_keyword': [], 'exclude_keyword': [], 'paths': False, 44 'include_keyword': [], 'exclude_keyword': [], 'paths': False,
43 } 45 }
44 options_defaults.update(kwargs) 46 options_defaults.update(kwargs)
45 options = MockOptions(**options_defaults) 47 options = optparse.Values(dict(**options_defaults))
46 tool = MockWebKitPatch() 48 tool = MockWebKitPatch()
47 tool.port_factory.all_port_names = lambda: [ 49 tool.port_factory.all_port_names = lambda: [
48 'test-linux-trusty', 'test-linux-precise', 50 'test-linux-trusty', 'test-linux-precise',
49 'test-mac-mac10.11', 'test-mac-mac10.10', 51 'test-mac-mac10.11', 'test-mac-mac10.10',
50 'test-win-win10', 'test-win-win7' 52 'test-win-win10', 'test-win-win7'
51 ] 53 ]
52 command = PrintExpectations() 54 command = PrintExpectations()
53 command.bind_to_tool(tool) 55 command.bind_to_tool(tool)
54 56
55 oc = OutputCapture() 57 oc = OutputCapture()
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 136
135 def restore_output(self): 137 def restore_output(self):
136 stdout, stderr, logs = self.oc.restore_output() 138 stdout, stderr, logs = self.oc.restore_output()
137 self.oc = None 139 self.oc = None
138 return (stdout, stderr, logs) 140 return (stdout, stderr, logs)
139 141
140 def test_basic(self): 142 def test_basic(self):
141 command = PrintBaselines() 143 command = PrintBaselines()
142 command.bind_to_tool(self.tool) 144 command.bind_to_tool(self.tool)
143 self.capture_output() 145 self.capture_output()
144 command.execute(MockOptions(all=False, include_virtual_tests=False, 146 options = optparse.Values({'all': False, 'include_virtual_tests': False, 'csv': False, 'platform': None})
145 csv=False, platform=None), ['passes/text.htm l'], self.tool) 147 command.execute(options, ['passes/text.html'], self.tool)
146 stdout, _, _ = self.restore_output() 148 stdout, _, _ = self.restore_output()
147 self.assertMultiLineEqual(stdout, 149 self.assertMultiLineEqual(stdout,
148 ('// For test-win-win7\n' 150 ('// For test-win-win7\n'
149 'passes/text-expected.png\n' 151 'passes/text-expected.png\n'
150 'passes/text-expected.txt\n')) 152 'passes/text-expected.txt\n'))
151 153
152 def test_multiple(self): 154 def test_multiple(self):
153 command = PrintBaselines() 155 command = PrintBaselines()
154 command.bind_to_tool(self.tool) 156 command.bind_to_tool(self.tool)
155 self.capture_output() 157 self.capture_output()
156 command.execute(MockOptions(all=False, include_virtual_tests=False, csv= False, 158 options = optparse.Values({'all': False, 'include_virtual_tests': False, 'csv': False, 'platform': 'test-win-*'})
157 platform='test-win-*'), ['passes/text.html'] , self.tool) 159 command.execute(options, ['passes/text.html'], self.tool)
158 stdout, _, _ = self.restore_output() 160 stdout, _, _ = self.restore_output()
159 self.assertMultiLineEqual(stdout, 161 self.assertMultiLineEqual(stdout,
160 ('// For test-win-win10\n' 162 ('// For test-win-win10\n'
161 'passes/text-expected.png\n' 163 'passes/text-expected.png\n'
162 'passes/text-expected.txt\n' 164 'passes/text-expected.txt\n'
163 '\n' 165 '\n'
164 '// For test-win-win7\n' 166 '// For test-win-win7\n'
165 'passes/text-expected.png\n' 167 'passes/text-expected.png\n'
166 'passes/text-expected.txt\n')) 168 'passes/text-expected.txt\n'))
167 169
168 def test_csv(self): 170 def test_csv(self):
169 command = PrintBaselines() 171 command = PrintBaselines()
170 command.bind_to_tool(self.tool) 172 command.bind_to_tool(self.tool)
171 self.capture_output() 173 self.capture_output()
172 command.execute(MockOptions(all=False, platform='*win7', csv=True, 174 options = optparse.Values({'all': False, 'platform': '*win7', 'csv': Tru e, 'include_virtual_tests': False})
173 include_virtual_tests=False), ['passes/text. html'], self.tool) 175 command.execute(options, ['passes/text.html'], self.tool)
174 stdout, _, _ = self.restore_output() 176 stdout, _, _ = self.restore_output()
175 self.assertMultiLineEqual(stdout, 177 self.assertMultiLineEqual(stdout,
176 ('test-win-win7,passes/text.html,None,png,pass es/text-expected.png,None\n' 178 ('test-win-win7,passes/text.html,None,png,pass es/text-expected.png,None\n'
177 'test-win-win7,passes/text.html,None,txt,pass es/text-expected.txt,None\n')) 179 'test-win-win7,passes/text.html,None,txt,pass es/text-expected.txt,None\n'))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698