OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library runtime_configuration; | 5 library runtime_configuration; |
6 | 6 |
7 import 'dart:io' show | 7 import 'dart:io' show |
8 File, | 8 File, |
9 Platform; | 9 Platform; |
10 | 10 |
11 import 'compiler_configuration.dart' show | 11 import 'compiler_configuration.dart' show |
12 CommandArtifact; | 12 CommandArtifact; |
13 | 13 |
14 // TODO(ahe): Remove this import, we can precompute all the values required | 14 // TODO(ahe): Remove this import, we can precompute all the values required |
15 // from TestSuite once the refactoring is complete. | 15 // from TestSuite once the refactoring is complete. |
16 import 'test_suite.dart' show | 16 import 'test_suite.dart' show |
17 StandardTestSuite, | 17 StandardTestSuite, |
18 TestSuite; | 18 TestSuite; |
19 | 19 |
20 import 'test_runner.dart' show | 20 import 'test_runner.dart' show |
21 Command, | 21 Command, |
22 CommandBuilder; | 22 CommandBuilder; |
23 | 23 |
24 import "utils.dart"; | 24 import "utils.dart"; |
25 | 25 |
26 import 'fletch_warnings_suite.dart' show | 26 import 'dartino_warnings_suite.dart' show |
27 FletchWarningsRuntimeConfiguration; | 27 DartinoWarningsRuntimeConfiguration; |
28 | 28 |
29 import 'fletch_test_suite.dart' show | 29 import 'dartino_test_suite.dart' show |
30 FletchTestRuntimeConfiguration; | 30 DartinoTestRuntimeConfiguration; |
31 | 31 |
32 import 'fletch_session_command.dart' show | 32 import 'dartino_session_command.dart' show |
33 FletchSessionCommand; | 33 DartinoSessionCommand; |
34 | 34 |
35 // TODO(ahe): I expect this class will become abstract very soon. | 35 // TODO(ahe): I expect this class will become abstract very soon. |
36 class RuntimeConfiguration { | 36 class RuntimeConfiguration { |
37 // TODO(ahe): Remove this constructor and move the switch to | 37 // TODO(ahe): Remove this constructor and move the switch to |
38 // test_options.dart. We probably want to store an instance of | 38 // test_options.dart. We probably want to store an instance of |
39 // [RuntimeConfiguration] in [configuration] there. | 39 // [RuntimeConfiguration] in [configuration] there. |
40 factory RuntimeConfiguration(Map configuration) { | 40 factory RuntimeConfiguration(Map configuration) { |
41 String runtime = configuration['runtime']; | 41 String runtime = configuration['runtime']; |
42 switch (runtime) { | 42 switch (runtime) { |
43 case 'none': | 43 case 'none': |
44 return new NoneRuntimeConfiguration(); | 44 return new NoneRuntimeConfiguration(); |
45 | 45 |
46 case 'fletchc': | 46 case 'dartino_compiler': |
47 return new FletchcRuntimeConfiguration( | 47 return new DartinocRuntimeConfiguration( |
48 hostChecked: configuration['host_checked'], | 48 hostChecked: configuration['host_checked'], |
49 useSdk:configuration['use_sdk'], | 49 useSdk:configuration['use_sdk'], |
50 settingsFileName: configuration['settings_file_name']); | 50 settingsFileName: configuration['settings_file_name']); |
51 | 51 |
52 case 'fletchvm': | 52 case 'dartinovm': |
53 return new FletchVMRuntimeConfiguration(configuration); | 53 return new DartinoVMRuntimeConfiguration(configuration); |
54 | 54 |
55 case 'fletch_warnings': | 55 case 'dartino_warnings': |
56 return new FletchWarningsRuntimeConfiguration(configuration); | 56 return new DartinoWarningsRuntimeConfiguration(configuration); |
57 | 57 |
58 case 'fletch_tests': | 58 case 'dartino_tests': |
59 return new FletchTestRuntimeConfiguration(configuration); | 59 return new DartinoTestRuntimeConfiguration(configuration); |
60 | 60 |
61 case 'fletch_cc_tests': | 61 case 'dartino_cc_tests': |
62 return new CCRuntimeConfiguration(); | 62 return new CCRuntimeConfiguration(); |
63 | 63 |
64 default: | 64 default: |
65 throw "Unknown runtime '$runtime'"; | 65 throw "Unknown runtime '$runtime'"; |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 RuntimeConfiguration.subclass(); | 69 RuntimeConfiguration.subclass(); |
70 | 70 |
71 int computeTimeoutMultiplier({ | 71 int computeTimeoutMultiplier({ |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 multiplier *= 4; | 124 multiplier *= 4; |
125 break; | 125 break; |
126 } | 126 } |
127 if (isDebug) { | 127 if (isDebug) { |
128 multiplier *= 2; | 128 multiplier *= 2; |
129 } | 129 } |
130 return multiplier; | 130 return multiplier; |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 class FletchcRuntimeConfiguration extends DartVmRuntimeConfiguration { | 134 class DartinocRuntimeConfiguration extends DartVmRuntimeConfiguration { |
135 final bool useSdk; | 135 final bool useSdk; |
136 final String settingsFileName; | 136 final String settingsFileName; |
137 | 137 |
138 FletchcRuntimeConfiguration( | 138 DartinocRuntimeConfiguration( |
139 {bool hostChecked: true, | 139 {bool hostChecked: true, |
140 this.useSdk: false, | 140 this.useSdk: false, |
141 this.settingsFileName}) { | 141 this.settingsFileName}) { |
142 if (!hostChecked) { | 142 if (!hostChecked) { |
143 throw "fletch only works with --host-checked option."; | 143 throw "dartino only works with --host-checked option."; |
144 } | 144 } |
145 } | 145 } |
146 | 146 |
147 List<Command> computeRuntimeCommands( | 147 List<Command> computeRuntimeCommands( |
148 TestSuite suite, | 148 TestSuite suite, |
149 CommandBuilder commandBuilder, | 149 CommandBuilder commandBuilder, |
150 CommandArtifact artifact, | 150 CommandArtifact artifact, |
151 String script, | 151 String script, |
152 List<String> basicArguments, | 152 List<String> basicArguments, |
153 Map<String, String> environmentOverrides) { | 153 Map<String, String> environmentOverrides) { |
154 if (artifact.filename != null && artifact.mimeType != 'application/dart') { | 154 if (artifact.filename != null && artifact.mimeType != 'application/dart') { |
155 throw "Dart VM cannot run files of type '${artifact.mimeType}'."; | 155 throw "Dart VM cannot run files of type '${artifact.mimeType}'."; |
156 } | 156 } |
157 String executable = useSdk ? '${suite.buildDir}/dartino-sdk/bin/fletch' | 157 String executable = useSdk ? '${suite.buildDir}/dartino-sdk/bin/dartino' |
158 : '${suite.buildDir}/fletch'; | 158 : '${suite.buildDir}/dartino'; |
159 Map<String, String> environment = { | 159 Map<String, String> environment = { |
160 'DART_VM': suite.dartVmBinaryFileName, | 160 'DART_VM': suite.dartVmBinaryFileName, |
161 }; | 161 }; |
162 | 162 |
163 return <Command>[ | 163 return <Command>[ |
164 new FletchSessionCommand( | 164 new DartinoSessionCommand( |
165 executable, script, basicArguments, environment, | 165 executable, script, basicArguments, environment, |
166 settingsFileName: settingsFileName)]; | 166 settingsFileName: settingsFileName)]; |
167 } | 167 } |
168 } | 168 } |
169 | 169 |
170 class FletchVMRuntimeConfiguration extends DartVmRuntimeConfiguration { | 170 class DartinoVMRuntimeConfiguration extends DartVmRuntimeConfiguration { |
171 Map configuration; | 171 Map configuration; |
172 | 172 |
173 FletchVMRuntimeConfiguration(this.configuration); | 173 DartinoVMRuntimeConfiguration(this.configuration); |
174 | 174 |
175 List<Command> computeRuntimeCommands( | 175 List<Command> computeRuntimeCommands( |
176 TestSuite suite, | 176 TestSuite suite, |
177 CommandBuilder commandBuilder, | 177 CommandBuilder commandBuilder, |
178 CommandArtifact artifact, | 178 CommandArtifact artifact, |
179 String script, | 179 String script, |
180 List<String> arguments, | 180 List<String> arguments, |
181 Map<String, String> environmentOverrides) { | 181 Map<String, String> environmentOverrides) { |
182 String script = artifact.filename; | 182 String script = artifact.filename; |
183 String type = artifact.mimeType; | 183 String type = artifact.mimeType; |
184 if (script != null && type != 'application/fletch-snapshot') { | 184 if (script != null && type != 'application/dartino-snapshot') { |
185 throw "Fletch VM cannot run files of type '$type'."; | 185 throw "Dartino VM cannot run files of type '$type'."; |
186 } | 186 } |
187 var argumentsUnfold = ["-Xunfold-program"]..addAll(arguments); | 187 var argumentsUnfold = ["-Xunfold-program"]..addAll(arguments); |
188 | 188 |
189 if (configuration['system'] == 'lk') { | 189 if (configuration['system'] == 'lk') { |
190 return <Command>[ | 190 return <Command>[ |
191 commandBuilder.getVmCommand( | 191 commandBuilder.getVmCommand( |
192 "tools/lk/run_snapshot_lk_qemu.sh", | 192 "tools/lk/run_snapshot_lk_qemu.sh", |
193 arguments, | 193 arguments, |
194 environmentOverrides)]; | 194 environmentOverrides)]; |
195 } | 195 } |
196 | 196 |
197 var useSdk = configuration['use_sdk']; | 197 var useSdk = configuration['use_sdk']; |
198 var fletchVM = useSdk ? "${suite.buildDir}/dartino-sdk/bin/fletch-vm" | 198 var dartinoVM = useSdk ? "${suite.buildDir}/dartino-sdk/bin/dartino-vm" |
199 : "${suite.buildDir}/fletch-vm"; | 199 : "${suite.buildDir}/dartino-vm"; |
200 // NOTE: We assume that `fletch-vm` behaves the same as invoking | 200 // NOTE: We assume that `dartino-vm` behaves the same as invoking |
201 // the DartVM in terms of exit codes. | 201 // the DartVM in terms of exit codes. |
202 return <Command>[ | 202 return <Command>[ |
203 commandBuilder.getVmCommand(fletchVM, arguments, environmentOverrides), | 203 commandBuilder.getVmCommand(dartinoVM, arguments, environmentOverrides), |
204 commandBuilder.getVmCommand( | 204 commandBuilder.getVmCommand( |
205 fletchVM, argumentsUnfold, environmentOverrides)]; | 205 dartinoVM, argumentsUnfold, environmentOverrides)]; |
206 } | 206 } |
207 } | 207 } |
208 | 208 |
209 class CCRuntimeConfiguration extends DartVmRuntimeConfiguration { | 209 class CCRuntimeConfiguration extends DartVmRuntimeConfiguration { |
210 CCRuntimeConfiguration(); | 210 CCRuntimeConfiguration(); |
211 | 211 |
212 List<Command> computeRuntimeCommands( | 212 List<Command> computeRuntimeCommands( |
213 StandardTestSuite suite, | 213 StandardTestSuite suite, |
214 CommandBuilder commandBuilder, | 214 CommandBuilder commandBuilder, |
215 CommandArtifact artifact, | 215 CommandArtifact artifact, |
216 String script, | 216 String script, |
217 List<String> arguments, | 217 List<String> arguments, |
218 Map<String, String> environmentOverrides) { | 218 Map<String, String> environmentOverrides) { |
219 Map options = suite.readOptionsFromFile(new Path(arguments[0])); | 219 Map options = suite.readOptionsFromFile(new Path(arguments[0])); |
220 List<String> ccOptions = options["fletchCCOptions"]; | 220 List<String> ccOptions = options["dartinoCCOptions"]; |
221 var executable = "${suite.buildDir}/${ccOptions[0]}"; | 221 var executable = "${suite.buildDir}/${ccOptions[0]}"; |
222 return <Command>[commandBuilder.getVmCommand( | 222 return <Command>[commandBuilder.getVmCommand( |
223 executable, ccOptions.sublist(1), environmentOverrides)]; | 223 executable, ccOptions.sublist(1), environmentOverrides)]; |
224 } | 224 } |
225 } | 225 } |
226 | 226 |
227 | 227 |
228 /// Temporary runtime configuration for browser runtimes that haven't been | 228 /// Temporary runtime configuration for browser runtimes that haven't been |
229 /// migrated yet. | 229 /// migrated yet. |
230 // TODO(ahe): Remove this class. | 230 // TODO(ahe): Remove this class. |
231 class DummyRuntimeConfiguration extends DartVmRuntimeConfiguration { | 231 class DummyRuntimeConfiguration extends DartVmRuntimeConfiguration { |
232 List<Command> computeRuntimeCommands( | 232 List<Command> computeRuntimeCommands( |
233 TestSuite suite, | 233 TestSuite suite, |
234 CommandBuilder commandBuilder, | 234 CommandBuilder commandBuilder, |
235 CommandArtifact artifact, | 235 CommandArtifact artifact, |
236 String script, | 236 String script, |
237 List<String> arguments, | 237 List<String> arguments, |
238 Map<String, String> environmentOverrides) { | 238 Map<String, String> environmentOverrides) { |
239 throw "Unimplemented runtime '$runtimeType'"; | 239 throw "Unimplemented runtime '$runtimeType'"; |
240 } | 240 } |
241 } | 241 } |
OLD | NEW |