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

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

Issue 2675553002: Removed instances of fprintf in run_vm_tests and replaced them with OS::Print/PrintErr. (Closed)
Patch Set: Created 3 years, 10 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
« 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/dartutils.h" 7 #include "bin/dartutils.h"
8 #include "bin/file.h" 8 #include "bin/file.h"
9 #include "bin/platform.h" 9 #include "bin/platform.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 17 matching lines...) Expand all
28 // tests. 28 // tests.
29 static const char* const kNone = "No Test or Benchmarks"; 29 static const char* const kNone = "No Test or Benchmarks";
30 static const char* const kList = "List all Tests and Benchmarks"; 30 static const char* const kList = "List all Tests and Benchmarks";
31 static const char* const kAllBenchmarks = "All Benchmarks"; 31 static const char* const kAllBenchmarks = "All Benchmarks";
32 static const char* run_filter = kNone; 32 static const char* run_filter = kNone;
33 33
34 static int run_matches = 0; 34 static int run_matches = 0;
35 35
36 36
37 void TestCase::Run() { 37 void TestCase::Run() {
38 fprintf(stdout, "Running test: %s\n", name()); 38 OS::Print("Running test: %s\n", name());
39 (*run_)(); 39 (*run_)();
40 fprintf(stdout, "Done: %s\n", name()); 40 OS::Print("Done: %s\n", name());
41 } 41 }
42 42
43 43
44 void RawTestCase::Run() { 44 void RawTestCase::Run() {
45 fprintf(stdout, "Running test: %s\n", name()); 45 OS::Print("Running test: %s\n", name());
46 (*run_)(); 46 (*run_)();
47 fprintf(stdout, "Done: %s\n", name()); 47 OS::Print("Done: %s\n", name());
48 } 48 }
49 49
50 50
51 void TestCaseBase::RunTest() { 51 void TestCaseBase::RunTest() {
52 if (strcmp(run_filter, this->name()) == 0) { 52 if (strcmp(run_filter, this->name()) == 0) {
53 this->Run(); 53 this->Run();
54 run_matches++; 54 run_matches++;
55 } else if (run_filter == kList) { 55 } else if (run_filter == kList) {
56 fprintf(stdout, "%s\n", this->name()); 56 OS::Print("%s\n", this->name());
57 run_matches++; 57 run_matches++;
58 } 58 }
59 } 59 }
60 60
61 61
62 void Benchmark::RunBenchmark() { 62 void Benchmark::RunBenchmark() {
63 if ((run_filter == kAllBenchmarks) || 63 if ((run_filter == kAllBenchmarks) ||
64 (strcmp(run_filter, this->name()) == 0)) { 64 (strcmp(run_filter, this->name()) == 0)) {
65 this->Run(); 65 this->Run();
66 OS::Print("%s(%s): %" Pd64 "\n", this->name(), this->score_kind(), 66 OS::Print("%s(%s): %" Pd64 "\n", this->name(), this->score_kind(),
67 this->score()); 67 this->score());
68 run_matches++; 68 run_matches++;
69 } else if (run_filter == kList) { 69 } else if (run_filter == kList) {
70 fprintf(stdout, "%s\n", this->name()); 70 OS::Print("%s\n", this->name());
71 run_matches++; 71 run_matches++;
72 } 72 }
73 } 73 }
74 74
75 75
76 static void PrintUsage() { 76 static void PrintUsage() {
77 fprintf(stderr, 77 OS::PrintErr(
78 "run_vm_tests [--list | --benchmarks | " 78 "run_vm_tests [--list | --benchmarks | "
79 "<test name> | <benchmark name>]\n"); 79 "<test name> | <benchmark name>]\n");
80 fprintf(stderr, "run_vm_tests [vm-flags ...] <test name>\n"); 80 OS::PrintErr("run_vm_tests [vm-flags ...] <test name>\n");
81 fprintf(stderr, "run_vm_tests [vm-flags ...] <benchmark name>\n"); 81 OS::PrintErr("run_vm_tests [vm-flags ...] <benchmark name>\n");
82 } 82 }
83 83
84 84
85 static int Main(int argc, const char** argv) { 85 static int Main(int argc, const char** argv) {
86 // Flags being passed to the Dart VM. 86 // Flags being passed to the Dart VM.
87 int dart_argc = 0; 87 int dart_argc = 0;
88 const char** dart_argv = NULL; 88 const char** dart_argv = NULL;
89 89
90 if (argc < 2) { 90 if (argc < 2) {
91 // Bad parameter count. 91 // Bad parameter count.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 TestCaseBase::RunAll(); 126 TestCaseBase::RunAll();
127 // Apply the filter to all registered benchmarks. 127 // Apply the filter to all registered benchmarks.
128 Benchmark::RunAll(argv[0]); 128 Benchmark::RunAll(argv[0]);
129 129
130 err_msg = Dart::Cleanup(); 130 err_msg = Dart::Cleanup();
131 ASSERT(err_msg == NULL); 131 ASSERT(err_msg == NULL);
132 132
133 TestCaseBase::RunAllRaw(); 133 TestCaseBase::RunAllRaw();
134 // Print a warning message if no tests or benchmarks were matched. 134 // Print a warning message if no tests or benchmarks were matched.
135 if (run_matches == 0) { 135 if (run_matches == 0) {
136 fprintf(stderr, "No tests matched: %s\n", run_filter); 136 OS::PrintErr("No tests matched: %s\n", run_filter);
137 return 1; 137 return 1;
138 } 138 }
139 if (DynamicAssertionHelper::failed()) { 139 if (DynamicAssertionHelper::failed()) {
140 return 255; 140 return 255;
141 } 141 }
142 return 0; 142 return 0;
143 } 143 }
144 144
145 } // namespace dart 145 } // namespace dart
146 146
147 147
148 int main(int argc, const char** argv) { 148 int main(int argc, const char** argv) {
149 dart::bin::Platform::Exit(dart::Main(argc, argv)); 149 dart::bin::Platform::Exit(dart::Main(argc, argv));
150 } 150 }
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