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 "vm/benchmark_test.h" | 7 #include "vm/benchmark_test.h" |
8 #include "vm/dart.h" | 8 #include "vm/dart.h" |
9 #include "vm/unit_test.h" | 9 #include "vm/unit_test.h" |
10 | 10 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 if (argc < 2) { | 73 if (argc < 2) { |
74 // Bad parameter count. | 74 // Bad parameter count. |
75 PrintUsage(); | 75 PrintUsage(); |
76 return 1; | 76 return 1; |
77 } else if (argc == 2) { | 77 } else if (argc == 2) { |
78 if (strcmp(argv[1], "--list") == 0) { | 78 if (strcmp(argv[1], "--list") == 0) { |
79 run_filter = kList; | 79 run_filter = kList; |
80 // List all tests and benchmarks and exit without initializing the VM. | 80 // List all tests and benchmarks and exit without initializing the VM. |
81 TestCaseBase::RunAll(); | 81 TestCaseBase::RunAll(); |
82 Benchmark::RunAll(); | 82 Benchmark::RunAll(argv[0]); |
83 return 0; | 83 return 0; |
84 } else if (strcmp(argv[1], "--all") == 0) { | 84 } else if (strcmp(argv[1], "--all") == 0) { |
85 run_filter = kAll; | 85 run_filter = kAll; |
86 } else if (strcmp(argv[1], "--tests") == 0) { | 86 } else if (strcmp(argv[1], "--tests") == 0) { |
87 run_filter = kAllTests; | 87 run_filter = kAllTests; |
88 } else if (strcmp(argv[1], "--benchmarks") == 0) { | 88 } else if (strcmp(argv[1], "--benchmarks") == 0) { |
89 run_filter = kAllBenchmarks; | 89 run_filter = kAllBenchmarks; |
90 } else { | 90 } else { |
91 run_filter = argv[1]; | 91 run_filter = argv[1]; |
92 } | 92 } |
93 } else { | 93 } else { |
94 // First argument is the test name, the rest are vm flags. | 94 // First argument is the test name, the rest are vm flags. |
95 run_filter = argv[1]; | 95 run_filter = argv[1]; |
96 // Remove the first two values from the arguments. | 96 // Remove the first two values from the arguments. |
97 dart_argc = argc - 2; | 97 dart_argc = argc - 2; |
98 dart_argv = &argv[2]; | 98 dart_argv = &argv[2]; |
99 } | 99 } |
100 bool set_vm_flags_success = Flags::ProcessCommandLineFlags(dart_argc, | 100 bool set_vm_flags_success = Flags::ProcessCommandLineFlags(dart_argc, |
101 dart_argv); | 101 dart_argv); |
102 ASSERT(set_vm_flags_success); | 102 ASSERT(set_vm_flags_success); |
103 bool init_success = Dart::InitOnce(NULL, NULL); | 103 bool init_success = Dart::InitOnce(NULL, NULL); |
104 ASSERT(init_success); | 104 ASSERT(init_success); |
105 // Apply the filter to all registered tests. | 105 // Apply the filter to all registered tests. |
106 TestCaseBase::RunAll(); | 106 TestCaseBase::RunAll(); |
107 // Apply the filter to all registered benchmarks. | 107 // Apply the filter to all registered benchmarks. |
108 Benchmark::RunAll(); | 108 Benchmark::RunAll(argv[0]); |
109 // Print a warning message if no tests or benchmarks were matched. | 109 // Print a warning message if no tests or benchmarks were matched. |
110 if (run_matches == 0) { | 110 if (run_matches == 0) { |
111 fprintf(stderr, "No tests matched: %s\n", run_filter); | 111 fprintf(stderr, "No tests matched: %s\n", run_filter); |
112 return 1; | 112 return 1; |
113 } | 113 } |
114 return 0; | 114 return 0; |
115 } | 115 } |
116 | 116 |
117 } // namespace dart | 117 } // namespace dart |
118 | 118 |
119 | 119 |
120 int main(int argc, const char** argv) { | 120 int main(int argc, const char** argv) { |
121 return dart::Main(argc, argv); | 121 return dart::Main(argc, argv); |
122 } | 122 } |
OLD | NEW |