OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import cStringIO | 6 import cStringIO |
7 import hashlib | 7 import hashlib |
8 import json | 8 import json |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 self._expect_results(['symlink_partial.py'], None, None) | 599 self._expect_results(['symlink_partial.py'], None, None) |
600 | 600 |
601 | 601 |
602 class Isolate_trace_read_merge(IsolateModeBase): | 602 class Isolate_trace_read_merge(IsolateModeBase): |
603 # Tests both trace, read and merge. | 603 # Tests both trace, read and merge. |
604 # Warning: merge updates .isolate files. But they are currently in their | 604 # Warning: merge updates .isolate files. But they are currently in their |
605 # canonical format so they shouldn't be changed. | 605 # canonical format so they shouldn't be changed. |
606 LEVEL = isolate.STATS_ONLY | 606 LEVEL = isolate.STATS_ONLY |
607 | 607 |
608 def _check_merge(self, filename): | 608 def _check_merge(self, filename): |
609 filepath = os.path.join(ROOT_DIR, 'data', 'isolate', filename) | 609 filepath = isolate.trace_inputs.get_native_path_case( |
| 610 os.path.join(ROOT_DIR, 'data', 'isolate', filename)) |
610 expected = 'Updating %s\n' % filepath | 611 expected = 'Updating %s\n' % filepath |
611 with open(filepath, 'rb') as f: | 612 with open(filepath, 'rb') as f: |
612 old_content = f.read() | 613 old_content = f.read() |
613 out = self._execute('merge', filename, [], True) or '' | 614 out = self._execute('merge', filename, [], True) or '' |
614 self.assertEquals(expected, out) | 615 self.assertEquals(expected, out) |
615 with open(filepath, 'rb') as f: | 616 with open(filepath, 'rb') as f: |
616 new_content = f.read() | 617 new_content = f.read() |
617 self.assertEquals(old_content, new_content) | 618 self.assertEquals(old_content, new_content) |
618 | 619 |
619 def test_fail(self): | 620 def test_fail(self): |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 output = self._execute('read', [], True) | 877 output = self._execute('read', [], True) |
877 expected = { | 878 expected = { |
878 isolate.isolate_common.KEY_TRACKED: [ | 879 isolate.isolate_common.KEY_TRACKED: [ |
879 '../../isolate.py', | 880 '../../isolate.py', |
880 'touch_root.py', | 881 'touch_root.py', |
881 ], | 882 ], |
882 } | 883 } |
883 self.assertEquals(self._wrap_in_condition(expected), output) | 884 self.assertEquals(self._wrap_in_condition(expected), output) |
884 | 885 |
885 output = self._execute('merge', [], True) | 886 output = self._execute('merge', [], True) |
886 expected = 'Updating %s\n' % os.path.join( | 887 expected = 'Updating %s\n' % isolate.trace_inputs.get_native_path_case( |
887 self.root, 'data', 'isolate', 'touch_root.isolate') | 888 os.path.join(self.root, 'data', 'isolate', 'touch_root.isolate')) |
888 self.assertEquals(expected, output) | 889 self.assertEquals(expected, output) |
889 # In theory the file is going to be updated but in practice its content | 890 # In theory the file is going to be updated but in practice its content |
890 # won't change. | 891 # won't change. |
891 | 892 |
892 # Clean the directory from the logs, which are OS-specific. | 893 # Clean the directory from the logs, which are OS-specific. |
893 isolate.trace_inputs.get_api().clean_trace( | 894 isolate.trace_inputs.get_api().clean_trace( |
894 os.path.join(self.tempdir, 'isolate_smoke_test.results.log')) | 895 os.path.join(self.tempdir, 'isolate_smoke_test.results.log')) |
895 files = [ | 896 files = [ |
896 'isolate_smoke_test.results', | 897 'isolate_smoke_test.results', |
897 'isolate_smoke_test.state', | 898 'isolate_smoke_test.state', |
898 os.path.join('root', 'data', 'isolate', 'touch_root.isolate'), | 899 os.path.join('root', 'data', 'isolate', 'touch_root.isolate'), |
899 os.path.join('root', 'data', 'isolate', 'touch_root.py'), | 900 os.path.join('root', 'data', 'isolate', 'touch_root.py'), |
900 os.path.join('root', 'isolate.py'), | 901 os.path.join('root', 'isolate.py'), |
901 ] | 902 ] |
902 self.assertEquals(files, list_files_tree(self.tempdir)) | 903 self.assertEquals(files, list_files_tree(self.tempdir)) |
903 | 904 |
904 | 905 |
905 if __name__ == '__main__': | 906 if __name__ == '__main__': |
906 VERBOSE = '-v' in sys.argv | 907 VERBOSE = '-v' in sys.argv |
907 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) | 908 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) |
908 unittest.main() | 909 unittest.main() |
OLD | NEW |