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 import os | 5 import os |
6 import re | 6 import re |
7 import shutil | 7 import shutil |
8 import sys | 8 import sys |
9 import tempfile | 9 import tempfile |
10 | 10 |
11 import test | 11 import test |
12 from testing import test_case,test_configuration | 12 from testing import test_case,test_configuration |
13 import utils | 13 import utils |
14 | 14 |
15 from os.path import join, exists, isdir | 15 from os.path import join, exists, isdir |
16 | 16 |
17 def GeneratedName(src): | 17 def GeneratedName(src): |
18 return re.sub('\.dart$', '-generatedTest.dart', src) | 18 return re.sub('\.dart$', '-generatedTest.dart', src) |
19 | 19 |
20 class DartStubTestCase(test_case.StandardTestCase): | 20 class DartStubTestCase(test_case.StandardTestCase): |
21 def __init__(self, context, path, filename, mode, arch): | 21 def __init__(self, context, path, filename, mode, arch, component): |
22 super(DartStubTestCase, self).__init__(context, path, filename, mode, arch) | 22 super(DartStubTestCase, self).__init__(context, path, filename, mode, arch, |
| 23 component) |
23 self.filename = filename | 24 self.filename = filename |
24 self.mode = mode | 25 self.mode = mode |
25 self.arch = arch | 26 self.arch = arch |
| 27 self.component = component |
26 | 28 |
27 def IsBatchable(self): | 29 def IsBatchable(self): |
28 return False | 30 return False |
29 | 31 |
30 def GetStubs(self): | 32 def GetStubs(self): |
31 source = self.GetSource() | 33 source = self.GetSource() |
32 stub_classes = utils.ParseTestOptions(test.ISOLATE_STUB_PATTERN, source, | 34 stub_classes = utils.ParseTestOptions(test.ISOLATE_STUB_PATTERN, source, |
33 self.context.workspace) | 35 self.context.workspace) |
34 if stub_classes is None: | 36 if stub_classes is None: |
35 return (None, None, None) | 37 return (None, None, None) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 def GetCommand(self): | 81 def GetCommand(self): |
80 # Parse the options by reading the .dart source file. | 82 # Parse the options by reading the .dart source file. |
81 source = self.GetSource() | 83 source = self.GetSource() |
82 vm_options = utils.ParseTestOptions(test.VM_OPTIONS_PATTERN, source, | 84 vm_options = utils.ParseTestOptions(test.VM_OPTIONS_PATTERN, source, |
83 self.context.workspace) | 85 self.context.workspace) |
84 dart_options = utils.ParseTestOptions(test.DART_OPTIONS_PATTERN, source, | 86 dart_options = utils.ParseTestOptions(test.DART_OPTIONS_PATTERN, source, |
85 self.context.workspace) | 87 self.context.workspace) |
86 (interface, _, implementation) = self.GetStubs() | 88 (interface, _, implementation) = self.GetStubs() |
87 | 89 |
88 # Combine everything into a command array and return it. | 90 # Combine everything into a command array and return it. |
89 command = self.context.GetDart(self.mode, self.arch) | 91 command = self.context.GetDart(self.mode, self.arch, self.component) |
90 if interface is None: | 92 if interface is None: |
91 f = self.filename | 93 f = self.filename |
92 else: | 94 else: |
93 f = GeneratedName(interface) | 95 f = GeneratedName(interface) |
94 files = [ join(self.GetPath(), f) ] | 96 files = [ join(self.GetPath(), f) ] |
95 if vm_options: command += vm_options | 97 if vm_options: command += vm_options |
96 if dart_options: command += dart_options | 98 if dart_options: command += dart_options |
97 else: command += files | 99 else: command += files |
98 return command | 100 return command |
99 | 101 |
100 | 102 |
101 class DartStubTestConfiguration(test_configuration.StandardTestConfiguration): | 103 class DartStubTestConfiguration(test_configuration.StandardTestConfiguration): |
102 def __init__(self, context, root): | 104 def __init__(self, context, root): |
103 super(DartStubTestConfiguration, self).__init__(context, root) | 105 super(DartStubTestConfiguration, self).__init__(context, root) |
104 | 106 |
105 def ListTests(self, current_path, path, mode, arch): | 107 def ListTests(self, current_path, path, mode, arch, component): |
106 dartc = self.context.GetDartC(mode, 'dartc') | 108 dartc = self.context.GetDartC(mode, 'dartc') |
107 self.context.generate = os.access(dartc[0], os.X_OK) | 109 self.context.generate = os.access(dartc[0], os.X_OK) |
108 tests = [] | 110 tests = [] |
109 for root, dirs, files in os.walk(join(self.root, 'src')): | 111 for root, dirs, files in os.walk(join(self.root, 'src')): |
110 # Skip remnants from the subdirectory that used to be used for | 112 # Skip remnants from the subdirectory that used to be used for |
111 # generated code. | 113 # generated code. |
112 if root.endswith('generated'): | 114 if root.endswith('generated'): |
113 continue | 115 continue |
114 for f in [x for x in files if self.IsTest(x)]: | 116 for f in [x for x in files if self.IsTest(x)]: |
115 # If we can generate code, do not use the checked-in generated | 117 # If we can generate code, do not use the checked-in generated |
116 # code. Conversely, if we cannot, then only use the | 118 # code. Conversely, if we cannot, then only use the |
117 # checked-in generated code. | 119 # checked-in generated code. |
118 if self.context.generate == f.endswith('-generatedTest.dart'): | 120 if self.context.generate == f.endswith('-generatedTest.dart'): |
119 continue | 121 continue |
120 test_path = current_path + [ f[:-5] ] # Remove .dart suffix. | 122 test_path = current_path + [ f[:-5] ] # Remove .dart suffix. |
121 if not self.Contains(path, test_path): | 123 if not self.Contains(path, test_path): |
122 continue | 124 continue |
123 tests.append(DartStubTestCase(self.context, | 125 tests.append(DartStubTestCase(self.context, |
124 test_path, | 126 test_path, |
125 join(root, f), | 127 join(root, f), |
126 mode, | 128 mode, |
127 arch)) | 129 arch, |
| 130 component)) |
128 return tests | 131 return tests |
129 | 132 |
130 | 133 |
131 def GetConfiguration(context, root): | 134 def GetConfiguration(context, root): |
132 return DartStubTestConfiguration(context, root) | 135 return DartStubTestConfiguration(context, root) |
OLD | NEW |