Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: runtime/bin/run_vm_tests.cc

Issue 187853004: Remove broken flags --all and --tests. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/file.h" 7 #include "bin/file.h"
8 8
9 #include "vm/benchmark_test.h" 9 #include "vm/benchmark_test.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
11 #include "bin/dartutils.h" 11 #include "bin/dartutils.h"
12 #include "vm/unit_test.h" 12 #include "vm/unit_test.h"
13 13
14 14
15 // TODO(iposva, asiva): This is a placeholder for the real unittest framework. 15 // TODO(iposva, asiva): This is a placeholder for the real unittest framework.
16 namespace dart { 16 namespace dart {
17 17
18 // Only run tests that match the filter string. The default does not match any 18 // Only run tests that match the filter string. The default does not match any
19 // tests. 19 // tests.
20 static const char* const kNone = "No Test or Benchmarks"; 20 static const char* const kNone = "No Test or Benchmarks";
21 static const char* const kAll = "All";
22 static const char* const kList = "List all Tests and Benchmarks"; 21 static const char* const kList = "List all Tests and Benchmarks";
23 static const char* const kAllTests = "All Tests";
24 static const char* const kAllBenchmarks = "All Benchmarks"; 22 static const char* const kAllBenchmarks = "All Benchmarks";
25 static const char* run_filter = kNone; 23 static const char* run_filter = kNone;
26 24
27 static int run_matches = 0; 25 static int run_matches = 0;
28 26
29 27
30 void TestCase::Run() { 28 void TestCase::Run() {
31 fprintf(stdout, "Running test: %s\n", name()); 29 fprintf(stdout, "Running test: %s\n", name());
32 (*run_)(); 30 (*run_)();
33 fprintf(stdout, "Done: %s\n", name()); 31 fprintf(stdout, "Done: %s\n", name());
34 } 32 }
35 33
36 34
37 void TestCaseBase::RunTest() { 35 void TestCaseBase::RunTest() {
38 if ((run_filter == kAll) || 36 if (strcmp(run_filter, this->name()) == 0) {
39 (run_filter == kAllTests) ||
40 (strcmp(run_filter, this->name()) == 0)) {
41 this->Run(); 37 this->Run();
42 run_matches++; 38 run_matches++;
43 } else if (run_filter == kList) { 39 } else if (run_filter == kList) {
44 fprintf(stdout, "%s\n", this->name()); 40 fprintf(stdout, "%s\n", this->name());
45 run_matches++; 41 run_matches++;
46 } 42 }
47 } 43 }
48 44
49 45
50 void Benchmark::RunBenchmark() { 46 void Benchmark::RunBenchmark() {
51 if ((run_filter == kAll) || 47 if ((run_filter == kAllBenchmarks) ||
52 (run_filter == kAllBenchmarks) ||
53 (strcmp(run_filter, this->name()) == 0)) { 48 (strcmp(run_filter, this->name()) == 0)) {
54 this->Run(); 49 this->Run();
55 OS::Print("%s(RunTime): %" Pd "\n", this->name(), this->score()); 50 OS::Print("%s(RunTime): %" Pd "\n", this->name(), this->score());
56 run_matches++; 51 run_matches++;
57 } else if (run_filter == kList) { 52 } else if (run_filter == kList) {
58 fprintf(stdout, "%s\n", this->name()); 53 fprintf(stdout, "%s\n", this->name());
59 run_matches++; 54 run_matches++;
60 } 55 }
61 } 56 }
62 57
63 58
64 static void PrintUsage() { 59 static void PrintUsage() {
65 fprintf(stderr, "run_vm_tests [--list | --benchmarks | " 60 fprintf(stderr, "run_vm_tests [--list | --benchmarks | "
66 "--tests | --all | <test name> | <benchmark name>]\n"); 61 "<test name> | <benchmark name>]\n");
67 fprintf(stderr, "run_vm_tests [vm-flags ...] <test name>\n"); 62 fprintf(stderr, "run_vm_tests [vm-flags ...] <test name>\n");
68 fprintf(stderr, "run_vm_tests [vm-flags ...] <benchmark name>\n"); 63 fprintf(stderr, "run_vm_tests [vm-flags ...] <benchmark name>\n");
69 } 64 }
70 65
71 66
72 static int Main(int argc, const char** argv) { 67 static int Main(int argc, const char** argv) {
73 // Flags being passed to the Dart VM. 68 // Flags being passed to the Dart VM.
74 int dart_argc = 0; 69 int dart_argc = 0;
75 const char** dart_argv = NULL; 70 const char** dart_argv = NULL;
76 71
77 if (argc < 2) { 72 if (argc < 2) {
78 // Bad parameter count. 73 // Bad parameter count.
79 PrintUsage(); 74 PrintUsage();
80 return 1; 75 return 1;
81 } else if (argc == 2) { 76 } else if (argc == 2) {
82 if (strcmp(argv[1], "--list") == 0) { 77 if (strcmp(argv[1], "--list") == 0) {
83 run_filter = kList; 78 run_filter = kList;
84 // List all tests and benchmarks and exit without initializing the VM. 79 // List all tests and benchmarks and exit without initializing the VM.
85 TestCaseBase::RunAll(); 80 TestCaseBase::RunAll();
86 Benchmark::RunAll(argv[0]); 81 Benchmark::RunAll(argv[0]);
87 return 0; 82 return 0;
88 } else if (strcmp(argv[1], "--all") == 0) {
89 run_filter = kAll;
90 } else if (strcmp(argv[1], "--tests") == 0) {
91 run_filter = kAllTests;
92 } else if (strcmp(argv[1], "--benchmarks") == 0) { 83 } else if (strcmp(argv[1], "--benchmarks") == 0) {
93 run_filter = kAllBenchmarks; 84 run_filter = kAllBenchmarks;
94 } else { 85 } else {
95 run_filter = argv[1]; 86 run_filter = argv[1];
96 } 87 }
97 } else { 88 } else {
98 // Last argument is the test name, the rest are vm flags. 89 // Last argument is the test name, the rest are vm flags.
99 run_filter = argv[argc - 1]; 90 run_filter = argv[argc - 1];
100 // Remove the first value (executable) from the arguments and 91 // Remove the first value (executable) from the arguments and
101 // exclude the last argument which is the test name. 92 // exclude the last argument which is the test name.
(...skipping 22 matching lines...) Expand all
124 } 115 }
125 return 0; 116 return 0;
126 } 117 }
127 118
128 } // namespace dart 119 } // namespace dart
129 120
130 121
131 int main(int argc, const char** argv) { 122 int main(int argc, const char** argv) {
132 return dart::Main(argc, argv); 123 return dart::Main(argc, argv);
133 } 124 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698