OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 """Generate fake repositories for testing.""" | 6 """Generate fake repositories for testing.""" |
7 | 7 |
8 import atexit | 8 import atexit |
9 import datetime | 9 import datetime |
10 import errno | 10 import errno |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 def assertTree(self, tree, tree_root=None): | 876 def assertTree(self, tree, tree_root=None): |
877 """Diff the checkout tree with a dict.""" | 877 """Diff the checkout tree with a dict.""" |
878 if not tree_root: | 878 if not tree_root: |
879 tree_root = self.root_dir | 879 tree_root = self.root_dir |
880 actual = read_tree(tree_root) | 880 actual = read_tree(tree_root) |
881 diff = dict_diff(tree, actual) | 881 diff = dict_diff(tree, actual) |
882 if diff: | 882 if diff: |
883 logging.debug('Actual %s\n%s' % (tree_root, pprint.pformat(actual))) | 883 logging.debug('Actual %s\n%s' % (tree_root, pprint.pformat(actual))) |
884 logging.debug('Expected\n%s' % pprint.pformat(tree)) | 884 logging.debug('Expected\n%s' % pprint.pformat(tree)) |
885 logging.debug('Diff\n%s' % pprint.pformat(diff)) | 885 logging.debug('Diff\n%s' % pprint.pformat(diff)) |
886 self.assertEquals(diff, []) | 886 self.assertEquals(diff, {}) |
887 | 887 |
888 def mangle_svn_tree(self, *args): | 888 def mangle_svn_tree(self, *args): |
889 """Creates a 'virtual directory snapshot' to compare with the actual result | 889 """Creates a 'virtual directory snapshot' to compare with the actual result |
890 on disk.""" | 890 on disk.""" |
891 result = {} | 891 result = {} |
892 for item, new_root in args: | 892 for item, new_root in args: |
893 old_root, rev = item.split('@', 1) | 893 old_root, rev = item.split('@', 1) |
894 tree = self.FAKE_REPOS.svn_revs[int(rev)] | 894 tree = self.FAKE_REPOS.svn_revs[int(rev)] |
895 for k, v in tree.iteritems(): | 895 for k, v in tree.iteritems(): |
896 if not k.startswith(old_root): | 896 if not k.startswith(old_root): |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 fake.set_up_git() | 929 fake.set_up_git() |
930 print('Fake setup, press enter to quit or Ctrl-C to keep the checkouts.') | 930 print('Fake setup, press enter to quit or Ctrl-C to keep the checkouts.') |
931 sys.stdin.readline() | 931 sys.stdin.readline() |
932 except KeyboardInterrupt: | 932 except KeyboardInterrupt: |
933 trial_dir.TrialDir.SHOULD_LEAK.leak = True | 933 trial_dir.TrialDir.SHOULD_LEAK.leak = True |
934 return 0 | 934 return 0 |
935 | 935 |
936 | 936 |
937 if __name__ == '__main__': | 937 if __name__ == '__main__': |
938 sys.exit(main(sys.argv)) | 938 sys.exit(main(sys.argv)) |
OLD | NEW |