OLD | NEW |
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 |
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 | |
30 """Unit tests for manager.py.""" | 29 """Unit tests for manager.py.""" |
31 | 30 |
32 import sys | 31 import sys |
33 import time | 32 import time |
34 import unittest | 33 import unittest |
35 | 34 |
36 from webkitpy.common.host_mock import MockHost | 35 from webkitpy.common.host_mock import MockHost |
37 from webkitpy.layout_tests.controllers.manager import Manager | 36 from webkitpy.layout_tests.controllers.manager import Manager |
38 from webkitpy.layout_tests.models import test_expectations | 37 from webkitpy.layout_tests.models import test_expectations |
39 from webkitpy.layout_tests.models.test_run_results import TestRunResults | 38 from webkitpy.layout_tests.models.test_run_results import TestRunResults |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 self.assertEqual(self.websocket_stopped, True) | 100 self.assertEqual(self.websocket_stopped, True) |
102 | 101 |
103 self.http_started = self.http_stopped = self.websocket_started = self.we
bsocket_stopped = False | 102 self.http_started = self.http_stopped = self.websocket_started = self.we
bsocket_stopped = False |
104 manager._start_servers(['fast/html/foo.html']) | 103 manager._start_servers(['fast/html/foo.html']) |
105 self.assertEqual(self.http_started, False) | 104 self.assertEqual(self.http_started, False) |
106 self.assertEqual(self.websocket_started, False) | 105 self.assertEqual(self.websocket_started, False) |
107 manager._stop_servers() | 106 manager._stop_servers() |
108 self.assertEqual(self.http_stopped, False) | 107 self.assertEqual(self.http_stopped, False) |
109 self.assertEqual(self.websocket_stopped, False) | 108 self.assertEqual(self.websocket_stopped, False) |
110 | 109 |
111 | |
112 def test_look_for_new_crash_logs(self): | 110 def test_look_for_new_crash_logs(self): |
113 def get_manager(): | 111 def get_manager(): |
114 host = MockHost() | 112 host = MockHost() |
115 port = host.port_factory.get('test-mac-mac10.10') | 113 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()) | 114 manager = Manager(port, options=MockOptions(test_list=None, http=Tru
e, max_locked_shards=1), printer=FakePrinter()) |
117 return manager | 115 return manager |
| 116 |
118 host = MockHost() | 117 host = MockHost() |
119 port = host.port_factory.get('test-mac-mac10.10') | 118 port = host.port_factory.get('test-mac-mac10.10') |
120 tests = ['failures/expected/crash.html'] | 119 tests = ['failures/expected/crash.html'] |
121 expectations = test_expectations.TestExpectations(port, tests) | 120 expectations = test_expectations.TestExpectations(port, tests) |
122 run_results = TestRunResults(expectations, len(tests)) | 121 run_results = TestRunResults(expectations, len(tests)) |
123 manager = get_manager() | 122 manager = get_manager() |
124 manager._look_for_new_crash_logs(run_results, time.time()) | 123 manager._look_for_new_crash_logs(run_results, time.time()) |
125 | 124 |
126 def _make_fake_test_result(self, host, results_directory): | 125 def _make_fake_test_result(self, host, results_directory): |
127 host.filesystem.maybe_make_directory(results_directory) | 126 host.filesystem.maybe_make_directory(results_directory) |
128 host.filesystem.write_binary_file(results_directory + '/results.html', '
This is a test results file') | 127 host.filesystem.write_binary_file(results_directory + '/results.html', '
This is a test results file') |
129 | 128 |
130 def test_rename_results_folder(self): | 129 def test_rename_results_folder(self): |
131 host = MockHost() | 130 host = MockHost() |
132 port = host.port_factory.get('test-mac-mac10.10') | 131 port = host.port_factory.get('test-mac-mac10.10') |
133 | 132 |
134 def get_manager(): | 133 def get_manager(): |
135 manager = Manager(port, options=MockOptions(max_locked_shards=1), pr
inter=FakePrinter()) | 134 manager = Manager(port, options=MockOptions(max_locked_shards=1), pr
inter=FakePrinter()) |
136 return manager | 135 return manager |
| 136 |
137 self._make_fake_test_result(port.host, '/tmp/layout-test-results') | 137 self._make_fake_test_result(port.host, '/tmp/layout-test-results') |
138 self.assertTrue(port.host.filesystem.exists('/tmp/layout-test-results')) | 138 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'))) | 139 timestamp = time.strftime("%Y-%m-%d-%H-%M-%S", |
| 140 time.localtime(port.host.filesystem.mtime('/tm
p/layout-test-results/results.html'))) |
140 archived_file_name = '/tmp/layout-test-results' + '_' + timestamp | 141 archived_file_name = '/tmp/layout-test-results' + '_' + timestamp |
141 manager = get_manager() | 142 manager = get_manager() |
142 manager._rename_results_folder() | 143 manager._rename_results_folder() |
143 self.assertFalse(port.host.filesystem.exists('/tmp/layout-test-results')
) | 144 self.assertFalse(port.host.filesystem.exists('/tmp/layout-test-results')
) |
144 self.assertTrue(port.host.filesystem.exists(archived_file_name)) | 145 self.assertTrue(port.host.filesystem.exists(archived_file_name)) |
145 | 146 |
146 def test_clobber_old_results(self): | 147 def test_clobber_old_results(self): |
147 host = MockHost() | 148 host = MockHost() |
148 port = host.port_factory.get('test-mac-mac10.10') | 149 port = host.port_factory.get('test-mac-mac10.10') |
149 | 150 |
150 def get_manager(): | 151 def get_manager(): |
151 manager = Manager(port, options=MockOptions(max_locked_shards=1), pr
inter=FakePrinter()) | 152 manager = Manager(port, options=MockOptions(max_locked_shards=1), pr
inter=FakePrinter()) |
152 return manager | 153 return manager |
| 154 |
153 self._make_fake_test_result(port.host, '/tmp/layout-test-results') | 155 self._make_fake_test_result(port.host, '/tmp/layout-test-results') |
154 self.assertTrue(port.host.filesystem.exists('/tmp/layout-test-results')) | 156 self.assertTrue(port.host.filesystem.exists('/tmp/layout-test-results')) |
155 manager = get_manager() | 157 manager = get_manager() |
156 manager._clobber_old_results() | 158 manager._clobber_old_results() |
157 self.assertFalse(port.host.filesystem.exists('/tmp/layout-test-results')
) | 159 self.assertFalse(port.host.filesystem.exists('/tmp/layout-test-results')
) |
158 | 160 |
159 def test_limit_archived_results_count(self): | 161 def test_limit_archived_results_count(self): |
160 host = MockHost() | 162 host = MockHost() |
161 port = host.port_factory.get('test-mac-mac10.10') | 163 port = host.port_factory.get('test-mac-mac10.10') |
162 | 164 |
163 def get_manager(): | 165 def get_manager(): |
164 manager = Manager(port, options=MockOptions(max_locked_shards=1), pr
inter=FakePrinter()) | 166 manager = Manager(port, options=MockOptions(max_locked_shards=1), pr
inter=FakePrinter()) |
165 return manager | 167 return manager |
| 168 |
166 for x in range(1, 31): | 169 for x in range(1, 31): |
167 dir_name = '/tmp/layout-test-results' + '_' + str(x) | 170 dir_name = '/tmp/layout-test-results' + '_' + str(x) |
168 self._make_fake_test_result(port.host, dir_name) | 171 self._make_fake_test_result(port.host, dir_name) |
169 manager = get_manager() | 172 manager = get_manager() |
170 manager._limit_archived_results_count() | 173 manager._limit_archived_results_count() |
171 deleted_dir_count = 0 | 174 deleted_dir_count = 0 |
172 for x in range(1, 31): | 175 for x in range(1, 31): |
173 dir_name = '/tmp/layout-test-results' + '_' + str(x) | 176 dir_name = '/tmp/layout-test-results' + '_' + str(x) |
174 if not port.host.filesystem.exists(dir_name): | 177 if not port.host.filesystem.exists(dir_name): |
175 deleted_dir_count = deleted_dir_count + 1 | 178 deleted_dir_count = deleted_dir_count + 1 |
176 self.assertEqual(deleted_dir_count, 5) | 179 self.assertEqual(deleted_dir_count, 5) |
OLD | NEW |