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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py

Issue 1783073002: Run auto-formatter on files in webkitpy/layout_tests/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 9 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) 2010 Google Inc. All rights reserved. 1 # Copyright (C) 2010 Google Inc. All rights reserved.
2 # Copyright (C) 2010 Gabor Rapcsanyi (rgabor@inf.u-szeged.hu), University of Sze ged 2 # Copyright (C) 2010 Gabor Rapcsanyi (rgabor@inf.u-szeged.hu), University of Sze ged
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
(...skipping 23 matching lines...) Expand all
34 import unittest 34 import unittest
35 35
36 from webkitpy.common.host_mock import MockHost 36 from webkitpy.common.host_mock import MockHost
37 from webkitpy.layout_tests.controllers.manager import Manager 37 from webkitpy.layout_tests.controllers.manager import Manager
38 from webkitpy.layout_tests.models import test_expectations 38 from webkitpy.layout_tests.models import test_expectations
39 from webkitpy.layout_tests.models.test_run_results import TestRunResults 39 from webkitpy.layout_tests.models.test_run_results import TestRunResults
40 from webkitpy.tool.mocktool import MockOptions 40 from webkitpy.tool.mocktool import MockOptions
41 41
42 42
43 class FakePrinter(object): 43 class FakePrinter(object):
44
44 def write_update(self, s): 45 def write_update(self, s):
45 pass 46 pass
46 47
47 48
48 class ManagerTest(unittest.TestCase): 49 class ManagerTest(unittest.TestCase):
50
49 def test_needs_servers(self): 51 def test_needs_servers(self):
50 def get_manager(): 52 def get_manager():
51 host = MockHost() 53 host = MockHost()
52 port = host.port_factory.get('test-mac-mac10.10') 54 port = host.port_factory.get('test-mac-mac10.10')
53 manager = Manager(port, options=MockOptions(http=True, max_locked_sh ards=1), printer=FakePrinter()) 55 manager = Manager(port, options=MockOptions(http=True, max_locked_sh ards=1), printer=FakePrinter())
54 return manager 56 return manager
55 57
56 manager = get_manager() 58 manager = get_manager()
57 self.assertFalse(manager.needs_servers(['fast/html'])) 59 self.assertFalse(manager.needs_servers(['fast/html']))
58 60
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 self.assertEqual(self.websocket_stopped, True) 103 self.assertEqual(self.websocket_stopped, True)
102 104
103 self.http_started = self.http_stopped = self.websocket_started = self.we bsocket_stopped = False 105 self.http_started = self.http_stopped = self.websocket_started = self.we bsocket_stopped = False
104 manager._start_servers(['fast/html/foo.html']) 106 manager._start_servers(['fast/html/foo.html'])
105 self.assertEqual(self.http_started, False) 107 self.assertEqual(self.http_started, False)
106 self.assertEqual(self.websocket_started, False) 108 self.assertEqual(self.websocket_started, False)
107 manager._stop_servers() 109 manager._stop_servers()
108 self.assertEqual(self.http_stopped, False) 110 self.assertEqual(self.http_stopped, False)
109 self.assertEqual(self.websocket_stopped, False) 111 self.assertEqual(self.websocket_stopped, False)
110 112
111
112 def test_look_for_new_crash_logs(self): 113 def test_look_for_new_crash_logs(self):
113 def get_manager(): 114 def get_manager():
114 host = MockHost() 115 host = MockHost()
115 port = host.port_factory.get('test-mac-mac10.10') 116 port = host.port_factory.get('test-mac-mac10.10')
116 manager = Manager(port, options=MockOptions(test_list=None, http=Tru e, max_locked_shards=1), printer=FakePrinter()) 117 manager = Manager(port, options=MockOptions(test_list=None, http=Tru e, max_locked_shards=1), printer=FakePrinter())
117 return manager 118 return manager
118 host = MockHost() 119 host = MockHost()
119 port = host.port_factory.get('test-mac-mac10.10') 120 port = host.port_factory.get('test-mac-mac10.10')
120 tests = ['failures/expected/crash.html'] 121 tests = ['failures/expected/crash.html']
121 expectations = test_expectations.TestExpectations(port, tests) 122 expectations = test_expectations.TestExpectations(port, tests)
122 run_results = TestRunResults(expectations, len(tests)) 123 run_results = TestRunResults(expectations, len(tests))
123 manager = get_manager() 124 manager = get_manager()
124 manager._look_for_new_crash_logs(run_results, time.time()) 125 manager._look_for_new_crash_logs(run_results, time.time())
125 126
126 def _make_fake_test_result(self, host, results_directory): 127 def _make_fake_test_result(self, host, results_directory):
127 host.filesystem.maybe_make_directory(results_directory) 128 host.filesystem.maybe_make_directory(results_directory)
128 host.filesystem.write_binary_file(results_directory + '/results.html', ' This is a test results file') 129 host.filesystem.write_binary_file(results_directory + '/results.html', ' This is a test results file')
129 130
130 def test_rename_results_folder(self): 131 def test_rename_results_folder(self):
131 host = MockHost() 132 host = MockHost()
132 port = host.port_factory.get('test-mac-mac10.10') 133 port = host.port_factory.get('test-mac-mac10.10')
133 134
134 def get_manager(): 135 def get_manager():
135 manager = Manager(port, options=MockOptions(max_locked_shards=1), pr inter=FakePrinter()) 136 manager = Manager(port, options=MockOptions(max_locked_shards=1), pr inter=FakePrinter())
136 return manager 137 return manager
137 self._make_fake_test_result(port.host, '/tmp/layout-test-results') 138 self._make_fake_test_result(port.host, '/tmp/layout-test-results')
138 self.assertTrue(port.host.filesystem.exists('/tmp/layout-test-results')) 139 self.assertTrue(port.host.filesystem.exists('/tmp/layout-test-results'))
139 timestamp = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime(port.host. filesystem.mtime('/tmp/layout-test-results/results.html'))) 140 timestamp = time.strftime(
141 "%Y-%m-%d-%H-%M-%S", time.localtime(port.host.filesystem.mtime('/tmp /layout-test-results/results.html')))
140 archived_file_name = '/tmp/layout-test-results' + '_' + timestamp 142 archived_file_name = '/tmp/layout-test-results' + '_' + timestamp
141 manager = get_manager() 143 manager = get_manager()
142 manager._rename_results_folder() 144 manager._rename_results_folder()
143 self.assertFalse(port.host.filesystem.exists('/tmp/layout-test-results') ) 145 self.assertFalse(port.host.filesystem.exists('/tmp/layout-test-results') )
144 self.assertTrue(port.host.filesystem.exists(archived_file_name)) 146 self.assertTrue(port.host.filesystem.exists(archived_file_name))
145 147
146 def test_clobber_old_results(self): 148 def test_clobber_old_results(self):
147 host = MockHost() 149 host = MockHost()
148 port = host.port_factory.get('test-mac-mac10.10') 150 port = host.port_factory.get('test-mac-mac10.10')
149 151
(...skipping 17 matching lines...) Expand all
167 dir_name = '/tmp/layout-test-results' + '_' + str(x) 169 dir_name = '/tmp/layout-test-results' + '_' + str(x)
168 self._make_fake_test_result(port.host, dir_name) 170 self._make_fake_test_result(port.host, dir_name)
169 manager = get_manager() 171 manager = get_manager()
170 manager._limit_archived_results_count() 172 manager._limit_archived_results_count()
171 deleted_dir_count = 0 173 deleted_dir_count = 0
172 for x in range(1, 31): 174 for x in range(1, 31):
173 dir_name = '/tmp/layout-test-results' + '_' + str(x) 175 dir_name = '/tmp/layout-test-results' + '_' + str(x)
174 if not port.host.filesystem.exists(dir_name): 176 if not port.host.filesystem.exists(dir_name):
175 deleted_dir_count = deleted_dir_count + 1 177 deleted_dir_count = deleted_dir_count + 1
176 self.assertEqual(deleted_dir_count, 5) 178 self.assertEqual(deleted_dir_count, 5)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698