| OLD | NEW |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 # pylint: disable=invalid-name | 5 # pylint: disable=invalid-name |
| 6 # pylint complains about the assertXXX methods and the usage of short variables | 6 # pylint complains about the assertXXX methods and the usage of short variables |
| 7 # m/a/b/d in the tests. | 7 # m/a/b/d in the tests. |
| 8 | 8 |
| 9 import types | 9 import types |
| 10 import unittest | 10 import unittest |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 mock_filesystem = MockFileSystem({'/s1/file1': 'a', '/s2/file1': 'b', '/
s3/file1': 'c'}, dirs=['/output']) | 264 mock_filesystem = MockFileSystem({'/s1/file1': 'a', '/s2/file1': 'b', '/
s3/file1': 'c'}, dirs=['/output']) |
| 265 | 265 |
| 266 merger = merge_results.MergeFilesKeepFiles(mock_filesystem) | 266 merger = merge_results.MergeFilesKeepFiles(mock_filesystem) |
| 267 | 267 |
| 268 with self.assertFilesAdded(mock_filesystem, {'/output/out_0': 'a', '/out
put/out_1': 'b', '/output/out_2': 'c'}): | 268 with self.assertFilesAdded(mock_filesystem, {'/output/out_0': 'a', '/out
put/out_1': 'b', '/output/out_2': 'c'}): |
| 269 merger('/output/out', ['/s1/file1', '/s2/file1', '/s3/file1']) | 269 merger('/output/out', ['/s1/file1', '/s2/file1', '/s3/file1']) |
| 270 | 270 |
| 271 | 271 |
| 272 class DirMergerTests(FileSystemTestCase): | 272 class DirMergerTests(FileSystemTestCase): |
| 273 | 273 |
| 274 def test_failure_on_output_existing(self): | |
| 275 mock_filesystem = MockFileSystem({}, dirs=['/output']) | |
| 276 d = merge_results.DirMerger(mock_filesystem) | |
| 277 with self.assertRaises(OSError): | |
| 278 d.merge('/output', []) | |
| 279 | |
| 280 self.assertDictEqual({}, mock_filesystem.files, "No new files should exi
st!") | |
| 281 | |
| 282 def test_success_no_overlapping_files(self): | 274 def test_success_no_overlapping_files(self): |
| 283 mock_filesystem = MockFileSystem({'/shard0/file1': '1', '/shard1/file2':
'2'}) | 275 mock_filesystem = MockFileSystem({'/shard0/file1': '1', '/shard1/file2':
'2'}) |
| 284 d = merge_results.DirMerger(mock_filesystem) | 276 d = merge_results.DirMerger(mock_filesystem) |
| 285 with self.assertFilesAdded(mock_filesystem, {'/output/file1': '1', '/out
put/file2': '2'}): | 277 with self.assertFilesAdded(mock_filesystem, {'/output/file1': '1', '/out
put/file2': '2'}): |
| 286 d.merge('/output', ['/shard0', '/shard1']) | 278 d.merge('/output', ['/shard0', '/shard1']) |
| 287 | 279 |
| 288 def test_success_no_overlapping_files_but_matching_contents(self): | 280 def test_success_no_overlapping_files_but_matching_contents(self): |
| 289 mock_filesystem = MockFileSystem({'/shard0/file1': '1', '/shard1/file2':
'1'}) | 281 mock_filesystem = MockFileSystem({'/shard0/file1': '1', '/shard1/file2':
'1'}) |
| 290 d = merge_results.DirMerger(mock_filesystem) | 282 d = merge_results.DirMerger(mock_filesystem) |
| 291 with self.assertFilesAdded(mock_filesystem, {'/output/file1': '1', '/out
put/file2': '1'}): | 283 with self.assertFilesAdded(mock_filesystem, {'/output/file1': '1', '/out
put/file2': '1'}): |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 | 1055 |
| 1064 def test(self): | 1056 def test(self): |
| 1065 fs = MockFileSystem(self.layout_test_filesystem) | 1057 fs = MockFileSystem(self.layout_test_filesystem) |
| 1066 | 1058 |
| 1067 merger = merge_results.LayoutTestDirMerger(fs, results_json_value_overri
des={'layout_tests_dir': 'src'}) | 1059 merger = merge_results.LayoutTestDirMerger(fs, results_json_value_overri
des={'layout_tests_dir': 'src'}) |
| 1068 merger.merge('/out', ['/shards/0', '/shards/1']) | 1060 merger.merge('/out', ['/shards/0', '/shards/1']) |
| 1069 | 1061 |
| 1070 for fname, contents in self.layout_test_output_filesystem.items(): | 1062 for fname, contents in self.layout_test_output_filesystem.items(): |
| 1071 self.assertIn(fname, fs.files) | 1063 self.assertIn(fname, fs.files) |
| 1072 self.assertMultiLineEqual(contents, fs.files[fname]) | 1064 self.assertMultiLineEqual(contents, fs.files[fname]) |
| OLD | NEW |