OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 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 |
| 4 # found in the LICENSE file. |
| 5 |
| 6 import os |
| 7 import sys |
| 8 |
| 9 |
| 10 def main(): |
| 11 print 'with_flag: Verify the test data files were mapped properly' |
| 12 assert len(sys.argv) == 2 |
| 13 mode = sys.argv[1] |
| 14 assert mode in ('run', 'trace') |
| 15 expected = { |
| 16 os.path.join('subdir', '42.txt'): |
| 17 'the answer to life the universe and everything\n', |
| 18 'test_file1.txt': 'Foo\n', |
| 19 'test_file2.txt': 'Bar\n', |
| 20 } |
| 21 |
| 22 root = 'files1' |
| 23 actual = {} |
| 24 for relroot, dirnames, filenames in os.walk(root): |
| 25 for filename in filenames: |
| 26 fullpath = os.path.join(relroot, filename) |
| 27 actual[fullpath[len(root)+1:]] = open(fullpath, 'rb').read() |
| 28 if mode == 'trace' and '.svn' in dirnames: |
| 29 dirnames.remove('.svn') |
| 30 |
| 31 if actual != expected: |
| 32 print 'Failure' |
| 33 print actual |
| 34 print expected |
| 35 return 1 |
| 36 |
| 37 root_dir = os.path.dirname(os.path.abspath(__file__)) |
| 38 parent_dir, base = os.path.split(root_dir) |
| 39 if mode == 'trace': |
| 40 # Verify the parent directory. |
| 41 parent_dir, base2 = os.path.split(parent_dir) |
| 42 if base != 'isolate' or base2 != 'tests': |
| 43 print 'mode trace: Invalid root dir %s' % root_dir |
| 44 return 4 |
| 45 else: |
| 46 # Verify that we are not inside a checkout. |
| 47 if base == 'tests': |
| 48 print 'mode run: Invalid root dir %s' % root_dir |
| 49 return 5 |
| 50 return 0 |
| 51 |
| 52 |
| 53 if __name__ == '__main__': |
| 54 sys.exit(main()) |
OLD | NEW |