OLD | NEW |
1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 command_constructor = RebaselineOMatic | 1200 command_constructor = RebaselineOMatic |
1201 | 1201 |
1202 def setUp(self): | 1202 def setUp(self): |
1203 super(TestRebaselineOMatic, self).setUp() | 1203 super(TestRebaselineOMatic, self).setUp() |
1204 self._logs = [] | 1204 self._logs = [] |
1205 | 1205 |
1206 def _mock_log_to_server(self, log='', is_new_entry=False): | 1206 def _mock_log_to_server(self, log='', is_new_entry=False): |
1207 self._logs.append({'log': log, 'newentry': is_new_entry}) | 1207 self._logs.append({'log': log, 'newentry': is_new_entry}) |
1208 | 1208 |
1209 def test_run_logged_command(self): | 1209 def test_run_logged_command(self): |
| 1210 self.command._verbose = False |
1210 self.command._log_to_server = self._mock_log_to_server | 1211 self.command._log_to_server = self._mock_log_to_server |
1211 self.command._run_logged_command(['echo', 'foo']) | 1212 self.command._run_logged_command(['echo', 'foo']) |
1212 self.assertEqual(self.tool.executive.calls, [['echo', 'foo']]) | 1213 self.assertEqual(self.tool.executive.calls, [['echo', 'foo']]) |
1213 self.assertEqual(self._logs, [{'log': 'MOCK STDOUT\n', 'newentry': False
}]) | 1214 self.assertEqual(self._logs, [{'log': 'MOCK STDOUT', 'newentry': False}]
) |
1214 | 1215 |
1215 def test_do_one_rebaseline(self): | 1216 def test_do_one_rebaseline(self): |
| 1217 self.command._verbose = False |
1216 self.command._log_to_server = self._mock_log_to_server | 1218 self.command._log_to_server = self._mock_log_to_server |
1217 self.command._do_one_rebaseline(verbose=False) | 1219 |
| 1220 oc = OutputCapture() |
| 1221 oc.capture_output() |
| 1222 self.command._do_one_rebaseline() |
| 1223 out, _, _ = oc.restore_output() |
| 1224 |
| 1225 self.assertEqual(out, '') |
1218 self.assertEqual(self.tool.executive.calls, [ | 1226 self.assertEqual(self.tool.executive.calls, [ |
1219 ['git', 'pull'], | 1227 ['git', 'pull'], |
1220 ['/mock-checkout/third_party/WebKit/Tools/Scripts/webkit-patch', 'au
to-rebaseline'], | 1228 ['/mock-checkout/third_party/WebKit/Tools/Scripts/webkit-patch', 'au
to-rebaseline'], |
1221 ]) | 1229 ]) |
1222 self.assertEqual(self._logs, [ | 1230 self.assertEqual(self._logs, [ |
1223 {'log': '', 'newentry': True}, | 1231 {'log': '', 'newentry': True}, |
1224 {'log': 'MOCK STDOUT\n', 'newentry': False}, | 1232 {'log': 'MOCK STDOUT', 'newentry': False}, |
1225 ]) | 1233 ]) |
1226 | 1234 |
1227 def test_do_one_rebaseline_verbose(self): | 1235 def test_do_one_rebaseline_verbose(self): |
| 1236 self.command._verbose = True |
1228 self.command._log_to_server = self._mock_log_to_server | 1237 self.command._log_to_server = self._mock_log_to_server |
1229 self.command._do_one_rebaseline(verbose=True) | 1238 |
| 1239 oc = OutputCapture() |
| 1240 oc.capture_output() |
| 1241 self.command._do_one_rebaseline() |
| 1242 out, _, _ = oc.restore_output() |
| 1243 |
| 1244 self.assertEqual(out, 'MOCK STDOUT\n') |
1230 self.assertEqual(self.tool.executive.calls, [ | 1245 self.assertEqual(self.tool.executive.calls, [ |
1231 ['git', 'pull'], | 1246 ['git', 'pull'], |
1232 ['/mock-checkout/third_party/WebKit/Tools/Scripts/webkit-patch', 'au
to-rebaseline', '--verbose'], | 1247 ['/mock-checkout/third_party/WebKit/Tools/Scripts/webkit-patch', 'au
to-rebaseline', '--verbose'], |
1233 ]) | 1248 ]) |
1234 self.assertEqual(self._logs, [ | 1249 self.assertEqual(self._logs, [ |
1235 {'log': '', 'newentry': True}, | 1250 {'log': '', 'newentry': True}, |
1236 {'log': 'MOCK STDOUT\n', 'newentry': False}, | 1251 {'log': 'MOCK STDOUT', 'newentry': False}, |
1237 ]) | 1252 ]) |
OLD | NEW |