OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #include <stdio.h> | 5 #include <stdio.h> |
6 | 6 |
7 #include "bin/dartutils.h" | 7 #include "bin/dartutils.h" |
8 #include "bin/dfe.h" | 8 #include "bin/dfe.h" |
9 #include "bin/file.h" | 9 #include "bin/file.h" |
10 #include "bin/loader.h" | 10 #include "bin/loader.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 run_filter = kList; | 202 run_filter = kList; |
203 // List all tests and benchmarks and exit without initializing the VM. | 203 // List all tests and benchmarks and exit without initializing the VM. |
204 TestCaseBase::RunAll(); | 204 TestCaseBase::RunAll(); |
205 Benchmark::RunAll(argv[0]); | 205 Benchmark::RunAll(argv[0]); |
206 TestCaseBase::RunAllRaw(); | 206 TestCaseBase::RunAllRaw(); |
207 fflush(stdout); | 207 fflush(stdout); |
208 return 0; | 208 return 0; |
209 } | 209 } |
210 | 210 |
211 int arg_pos = 1; | 211 int arg_pos = 1; |
| 212 bool start_kernel_isolate = false; |
212 if (strstr(argv[arg_pos], "--dfe") == argv[arg_pos]) { | 213 if (strstr(argv[arg_pos], "--dfe") == argv[arg_pos]) { |
213 const char* delim = strstr(argv[1], "="); | 214 const char* delim = strstr(argv[1], "="); |
214 if (delim == NULL || strlen(delim + 1) == 0) { | 215 if (delim == NULL || strlen(delim + 1) == 0) { |
215 OS::PrintErr("Invalid value for the option: %s\n", argv[1]); | 216 OS::PrintErr("Invalid value for the option: %s\n", argv[1]); |
216 PrintUsage(); | 217 PrintUsage(); |
217 return 1; | 218 return 1; |
218 } | 219 } |
219 kernel_snapshot = strdup(delim + 1); | 220 kernel_snapshot = strdup(delim + 1); |
220 // VM needs '--use-dart-frontend' option, which we will insert in place | 221 // VM needs '--use-dart-frontend' option, which we will insert in place |
221 // of '--dfe' option. | 222 // of '--dfe' option. |
222 argv[arg_pos] = strdup("--use-dart-frontend"); | 223 argv[arg_pos] = strdup("--use-dart-frontend"); |
| 224 start_kernel_isolate = true; |
223 ++arg_pos; | 225 ++arg_pos; |
224 } | 226 } |
225 | 227 |
226 if (arg_pos == argc - 1 && strcmp(argv[arg_pos], "--benchmarks") == 0) { | 228 if (arg_pos == argc - 1 && strcmp(argv[arg_pos], "--benchmarks") == 0) { |
227 // "--benchmarks" is the last argument. | 229 // "--benchmarks" is the last argument. |
228 run_filter = kAllBenchmarks; | 230 run_filter = kAllBenchmarks; |
229 } else { | 231 } else { |
230 // Last argument is the test name, the rest are vm flags. | 232 // Last argument is the test name, the rest are vm flags. |
231 run_filter = argv[argc - 1]; | 233 run_filter = argv[argc - 1]; |
232 // Remove the first value (executable) from the arguments and | 234 // Remove the first value (executable) from the arguments and |
233 // exclude the last argument which is the test name. | 235 // exclude the last argument which is the test name. |
234 dart_argc = argc - 2; | 236 dart_argc = argc - 2; |
235 dart_argv = &argv[1]; | 237 dart_argv = &argv[1]; |
236 } | 238 } |
237 | 239 |
238 bool set_vm_flags_success = | 240 bool set_vm_flags_success = |
239 Flags::ProcessCommandLineFlags(dart_argc, dart_argv); | 241 Flags::ProcessCommandLineFlags(dart_argc, dart_argv); |
240 ASSERT(set_vm_flags_success); | 242 ASSERT(set_vm_flags_success); |
241 const char* err_msg = Dart::InitOnce( | 243 const char* err_msg = Dart::InitOnce( |
242 dart::bin::vm_snapshot_data, dart::bin::vm_snapshot_instructions, | 244 dart::bin::vm_snapshot_data, dart::bin::vm_snapshot_instructions, |
243 CreateIsolateAndSetup /* create */, NULL /* shutdown */, | 245 CreateIsolateAndSetup /* create */, NULL /* shutdown */, |
244 NULL /* cleanup */, NULL /* thread_exit */, | 246 NULL /* cleanup */, NULL /* thread_exit */, |
245 dart::bin::DartUtils::OpenFile, dart::bin::DartUtils::ReadFile, | 247 dart::bin::DartUtils::OpenFile, dart::bin::DartUtils::ReadFile, |
246 dart::bin::DartUtils::WriteFile, dart::bin::DartUtils::CloseFile, | 248 dart::bin::DartUtils::WriteFile, dart::bin::DartUtils::CloseFile, |
247 NULL /* entropy_source */, NULL /* get_service_assets */); | 249 NULL /* entropy_source */, NULL /* get_service_assets */, |
| 250 start_kernel_isolate); |
248 | 251 |
249 ASSERT(err_msg == NULL); | 252 ASSERT(err_msg == NULL); |
250 // Apply the filter to all registered tests. | 253 // Apply the filter to all registered tests. |
251 TestCaseBase::RunAll(); | 254 TestCaseBase::RunAll(); |
252 // Apply the filter to all registered benchmarks. | 255 // Apply the filter to all registered benchmarks. |
253 Benchmark::RunAll(argv[0]); | 256 Benchmark::RunAll(argv[0]); |
254 | 257 |
255 err_msg = Dart::Cleanup(); | 258 err_msg = Dart::Cleanup(); |
256 ASSERT(err_msg == NULL); | 259 ASSERT(err_msg == NULL); |
257 | 260 |
258 TestCaseBase::RunAllRaw(); | 261 TestCaseBase::RunAllRaw(); |
259 // Print a warning message if no tests or benchmarks were matched. | 262 // Print a warning message if no tests or benchmarks were matched. |
260 if (run_matches == 0) { | 263 if (run_matches == 0) { |
261 OS::PrintErr("No tests matched: %s\n", run_filter); | 264 OS::PrintErr("No tests matched: %s\n", run_filter); |
262 return 1; | 265 return 1; |
263 } | 266 } |
264 if (DynamicAssertionHelper::failed()) { | 267 if (DynamicAssertionHelper::failed()) { |
265 return 255; | 268 return 255; |
266 } | 269 } |
267 return 0; | 270 return 0; |
268 } | 271 } |
269 | 272 |
270 } // namespace dart | 273 } // namespace dart |
271 | 274 |
272 int main(int argc, const char** argv) { | 275 int main(int argc, const char** argv) { |
273 dart::bin::Platform::Exit(dart::Main(argc, argv)); | 276 dart::bin::Platform::Exit(dart::Main(argc, argv)); |
274 } | 277 } |
OLD | NEW |