OLD | NEW |
1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 import os | 6 import os |
7 from os.path import join, exists | 7 from os.path import join, exists |
8 import re | 8 import re |
9 | 9 |
10 import test | 10 import test |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 strip = len(src_dir.split(os.path.sep)) | 77 strip = len(src_dir.split(os.path.sep)) |
78 for root, dirs, files in os.walk(src_dir): | 78 for root, dirs, files in os.walk(src_dir): |
79 ignore_dirs = [d for d in dirs if d.startswith('.')] | 79 ignore_dirs = [d for d in dirs if d.startswith('.')] |
80 for d in ignore_dirs: | 80 for d in ignore_dirs: |
81 dirs.remove(d) | 81 dirs.remove(d) |
82 for f in [x for x in files if self.IsTest(x)]: | 82 for f in [x for x in files if self.IsTest(x)]: |
83 test_path = [] + current_path | 83 test_path = [] + current_path |
84 test_path.extend(root.split(os.path.sep)[strip:]) | 84 test_path.extend(root.split(os.path.sep)[strip:]) |
85 test_name = short_name = f | 85 test_name = short_name = f |
86 | 86 |
87 # shotlen test_name | |
88 # remove repeats | |
89 if short_name.startswith(test_path[-1]): | |
90 short_name = short_name[len(test_path[-1]) : ] | |
91 | |
92 # remove suffixes | 87 # remove suffixes |
93 if short_name.endswith(".dart"): | 88 if short_name.endswith(".dart"): |
94 short_name = short_name[:-5] # Remove .dart suffix. | 89 short_name = short_name[:-5] # Remove .dart suffix. |
95 # now .app suffix discarded at self.IsTest() | |
96 #elif short_name.endswith(".app"): | |
97 # short_name = short_name[:-4] # Remove .app suffix. | |
98 else: | 90 else: |
99 raise Error('Unknown suffix in "%s", fix IsTest() predicate' % f) | 91 raise Error('Unknown suffix in "%s", fix IsTest() predicate' % f) |
100 | 92 |
101 | 93 test_path.append(short_name) |
102 while short_name.startswith('_'): | |
103 short_name = short_name[1:] | |
104 | |
105 test_path.extend(short_name.split('_')) | |
106 | 94 |
107 # test full name and shorted name matches given path pattern | 95 # test full name and shorted name matches given path pattern |
108 if self.Contains(path, test_path): pass | 96 if self.Contains(path, test_path): pass |
109 elif self.Contains(path, test_path + [test_name]): pass | 97 elif self.Contains(path, test_path + [test_name]): pass |
110 else: | 98 else: |
111 continue | 99 continue |
112 | 100 |
113 tests.append(Co19TestCase(test_path, | 101 tests.append(Co19TestCase(test_path, |
114 self.context, | 102 self.context, |
115 join(root, f), | 103 join(root, f), |
(...skipping 29 matching lines...) Expand all Loading... |
145 patterns[idx : idx] = ['*'] * (len(file) - len(path)) | 133 patterns[idx : idx] = ['*'] * (len(file) - len(path)) |
146 path = [test.Pattern(p) for p in patterns] | 134 path = [test.Pattern(p) for p in patterns] |
147 | 135 |
148 for i in xrange(len(path)): | 136 for i in xrange(len(path)): |
149 if not path[i].match(file[i]): | 137 if not path[i].match(file[i]): |
150 return False | 138 return False |
151 return True | 139 return True |
152 | 140 |
153 def GetConfiguration(context, root): | 141 def GetConfiguration(context, root): |
154 return Co19TestConfiguration(context, root) | 142 return Co19TestConfiguration(context, root) |
OLD | NEW |