Index: Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py |
diff --git a/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py b/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py |
index 9c0ba86031e44fb555a388e63a20e2214f61820c..d74cb57feaa2a55abd454894249bdc0ce29ff1e8 100644 |
--- a/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py |
+++ b/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py |
@@ -122,3 +122,55 @@ class ManagerTest(unittest.TestCase): |
run_results = TestRunResults(expectations, len(tests)) |
manager = get_manager() |
manager._look_for_new_crash_logs(run_results, time.time()) |
+ |
+ def _make_fake_test_result(self, host, results_directory): |
+ host.filesystem.maybe_make_directory(results_directory) |
+ host.filesystem.write_binary_file(results_directory + '/results.html', 'This is a test results file') |
+ |
+ def test_rename_results_folder(self): |
+ host = MockHost() |
+ port = host.port_factory.get('test-mac-leopard') |
+ |
+ def get_manager(): |
+ manager = Manager(port, options=MockOptions(max_locked_shards=1), printer=FakePrinter()) |
+ return manager |
+ self._make_fake_test_result(port.host, '/tmp/layout-test-results') |
+ self.assertTrue(port.host.filesystem.exists('/tmp/layout-test-results')) |
+ timestamp = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime(port.host.filesystem.mtime('/tmp/layout-test-results/results.html'))) |
+ archived_file_name = '/tmp/layout-test-results' + '_' + timestamp |
+ manager = get_manager() |
+ manager._rename_results_folder() |
+ self.assertFalse(port.host.filesystem.exists('/tmp/layout-test-results')) |
+ self.assertTrue(port.host.filesystem.exists(archived_file_name)) |
+ |
+ def test_clobber_old_results(self): |
+ host = MockHost() |
+ port = host.port_factory.get('test-mac-leopard') |
+ |
+ def get_manager(): |
+ manager = Manager(port, options=MockOptions(max_locked_shards=1), printer=FakePrinter()) |
+ return manager |
+ self._make_fake_test_result(port.host, '/tmp/layout-test-results') |
+ self.assertTrue(port.host.filesystem.exists('/tmp/layout-test-results')) |
+ manager = get_manager() |
+ manager._clobber_old_results() |
+ self.assertFalse(port.host.filesystem.exists('/tmp/layout-test-results')) |
+ |
+ def test_limit_archived_results_count(self): |
+ host = MockHost() |
+ port = host.port_factory.get('test-mac-leopard') |
+ |
+ def get_manager(): |
+ manager = Manager(port, options=MockOptions(max_locked_shards=1), printer=FakePrinter()) |
+ return manager |
+ for x in range(1, 31): |
+ dir_name = '/tmp/layout-test-results' + '_' + str(x) |
+ self._make_fake_test_result(port.host, dir_name) |
+ manager = get_manager() |
+ manager._limit_archived_results_count() |
+ deleted_dir_count = 0 |
+ for x in range(1, 31): |
+ dir_name = '/tmp/layout-test-results' + '_' + str(x) |
+ if not port.host.filesystem.exists(dir_name): |
+ deleted_dir_count = deleted_dir_count + 1 |
+ self.assertEqual(deleted_dir_count, 5) |