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

Side by Side Diff: gm/gm_expectations.h

Issue 12691009: gm: write all messages to stdout/stderr with "GM:" preamble to distinguish from various debug messa… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: split_out_stderr Created 7 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
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #ifndef gm_expectations_DEFINED 7 #ifndef gm_expectations_DEFINED
8 #define gm_expectations_DEFINED 8 #define gm_expectations_DEFINED
9 9
10 #include "gm.h" 10 #include "gm.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 * don't have any expectations. 96 * don't have any expectations.
97 */ 97 */
98 Expectations(Json::Value jsonElement) { 98 Expectations(Json::Value jsonElement) {
99 if (jsonElement.empty()) { 99 if (jsonElement.empty()) {
100 fIgnoreFailure = kDefaultIgnoreFailure; 100 fIgnoreFailure = kDefaultIgnoreFailure;
101 } else { 101 } else {
102 Json::Value ignoreFailure = jsonElement[kJsonKey_ExpectedResults _IgnoreFailure]; 102 Json::Value ignoreFailure = jsonElement[kJsonKey_ExpectedResults _IgnoreFailure];
103 if (ignoreFailure.isNull()) { 103 if (ignoreFailure.isNull()) {
104 fIgnoreFailure = kDefaultIgnoreFailure; 104 fIgnoreFailure = kDefaultIgnoreFailure;
105 } else if (!ignoreFailure.isBool()) { 105 } else if (!ignoreFailure.isBool()) {
106 fprintf(stderr, "found non-boolean json value for key '%s' i n element '%s'\n", 106 fprintf(stderr, GM_PREAMBLE "found non-boolean json value"
107 " for key '%s' in element '%s'\n",
107 kJsonKey_ExpectedResults_IgnoreFailure, 108 kJsonKey_ExpectedResults_IgnoreFailure,
108 jsonElement.toStyledString().c_str()); 109 jsonElement.toStyledString().c_str());
109 DEBUGFAIL_SEE_STDERR; 110 DEBUGFAIL_SEE_STDERR;
110 fIgnoreFailure = kDefaultIgnoreFailure; 111 fIgnoreFailure = kDefaultIgnoreFailure;
111 } else { 112 } else {
112 fIgnoreFailure = ignoreFailure.asBool(); 113 fIgnoreFailure = ignoreFailure.asBool();
113 } 114 }
114 115
115 Json::Value allowedChecksums = jsonElement[kJsonKey_ExpectedResu lts_Checksums]; 116 Json::Value allowedChecksums = jsonElement[kJsonKey_ExpectedResu lts_Checksums];
116 if (allowedChecksums.isNull()) { 117 if (allowedChecksums.isNull()) {
117 // ok, we'll just assume there aren't any expected checksums to compare against 118 // ok, we'll just assume there aren't any expected checksums to compare against
118 } else if (!allowedChecksums.isArray()) { 119 } else if (!allowedChecksums.isArray()) {
119 fprintf(stderr, "found non-array json value for key '%s' in element '%s'\n", 120 fprintf(stderr, GM_PREAMBLE "found non-array json value"
121 " for key '%s' in element '%s'\n",
120 kJsonKey_ExpectedResults_Checksums, 122 kJsonKey_ExpectedResults_Checksums,
121 jsonElement.toStyledString().c_str()); 123 jsonElement.toStyledString().c_str());
122 DEBUGFAIL_SEE_STDERR; 124 DEBUGFAIL_SEE_STDERR;
123 } else { 125 } else {
124 for (Json::ArrayIndex i=0; i<allowedChecksums.size(); i++) { 126 for (Json::ArrayIndex i=0; i<allowedChecksums.size(); i++) {
125 Json::Value checksumElement = allowedChecksums[i]; 127 Json::Value checksumElement = allowedChecksums[i];
126 if (!checksumElement.isIntegral()) { 128 if (!checksumElement.isIntegral()) {
127 fprintf(stderr, "found non-integer checksum in json element '%s'\n", 129 fprintf(stderr, GM_PREAMBLE "found non-integer check sum"
130 " in json element '%s'\n",
128 jsonElement.toStyledString().c_str()); 131 jsonElement.toStyledString().c_str());
129 DEBUGFAIL_SEE_STDERR; 132 DEBUGFAIL_SEE_STDERR;
130 } else { 133 } else {
131 fAllowedChecksums.push_back() = asChecksum(checksumE lement); 134 fAllowedChecksums.push_back() = asChecksum(checksumE lement);
132 } 135 }
133 } 136 }
134 } 137 }
135 } 138 }
136 } 139 }
137 140
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 SkBitmap referenceBitmap; 229 SkBitmap referenceBitmap;
227 bool decodedReferenceBitmap = 230 bool decodedReferenceBitmap =
228 SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap, 231 SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap,
229 SkBitmap::kARGB_8888_Config, 232 SkBitmap::kARGB_8888_Config,
230 SkImageDecoder::kDecodePixels_Mode, 233 SkImageDecoder::kDecodePixels_Mode,
231 NULL); 234 NULL);
232 if (decodedReferenceBitmap) { 235 if (decodedReferenceBitmap) {
233 return Expectations(referenceBitmap); 236 return Expectations(referenceBitmap);
234 } else { 237 } else {
235 if (fNotifyOfMissingFiles) { 238 if (fNotifyOfMissingFiles) {
236 fprintf(stderr, "FAILED to read %s\n", path.c_str()); 239 fprintf(stderr, GM_PREAMBLE "FAILED to read %s\n", path.c_st r());
237 } 240 }
238 return Expectations(); 241 return Expectations();
239 } 242 }
240 } 243 }
241 244
242 private: 245 private:
243 const SkString fRootDir; 246 const SkString fRootDir;
244 const bool fNotifyOfMissingFiles; 247 const bool fNotifyOfMissingFiles;
245 }; 248 };
246 249
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 327 }
325 328
326 /** 329 /**
327 * Read the file contents from jsonPath and parse them into jsonRoot. 330 * Read the file contents from jsonPath and parse them into jsonRoot.
328 * 331 *
329 * Returns true if successful. 332 * Returns true if successful.
330 */ 333 */
331 static bool parse(const char *jsonPath, Json::Value *jsonRoot) { 334 static bool parse(const char *jsonPath, Json::Value *jsonRoot) {
332 SkFILEStream inFile(jsonPath); 335 SkFILEStream inFile(jsonPath);
333 if (!inFile.isValid()) { 336 if (!inFile.isValid()) {
334 fprintf(stderr, "unable to read JSON file %s\n", jsonPath); 337 fprintf(stderr, GM_PREAMBLE "unable to read JSON file %s\n", jso nPath);
335 DEBUGFAIL_SEE_STDERR; 338 DEBUGFAIL_SEE_STDERR;
336 return false; 339 return false;
337 } 340 }
338 341
339 SkAutoDataUnref dataRef(readFileIntoSkData(inFile)); 342 SkAutoDataUnref dataRef(readFileIntoSkData(inFile));
340 if (NULL == dataRef.get()) { 343 if (NULL == dataRef.get()) {
341 fprintf(stderr, "error reading JSON file %s\n", jsonPath); 344 fprintf(stderr, GM_PREAMBLE "error reading JSON file %s\n", json Path);
342 DEBUGFAIL_SEE_STDERR; 345 DEBUGFAIL_SEE_STDERR;
343 return false; 346 return false;
344 } 347 }
345 348
346 const char *bytes = reinterpret_cast<const char *>(dataRef.get()->da ta()); 349 const char *bytes = reinterpret_cast<const char *>(dataRef.get()->da ta());
347 size_t size = dataRef.get()->size(); 350 size_t size = dataRef.get()->size();
348 Json::Reader reader; 351 Json::Reader reader;
349 if (!reader.parse(bytes, bytes+size, *jsonRoot)) { 352 if (!reader.parse(bytes, bytes+size, *jsonRoot)) {
350 fprintf(stderr, "error parsing JSON file %s\n", jsonPath); 353 fprintf(stderr, GM_PREAMBLE "error parsing JSON file %s\n", json Path);
351 DEBUGFAIL_SEE_STDERR; 354 DEBUGFAIL_SEE_STDERR;
352 return false; 355 return false;
353 } 356 }
354 return true; 357 return true;
355 } 358 }
356 359
357 Json::Value fJsonRoot; 360 Json::Value fJsonRoot;
358 Json::Value fJsonExpectedResults; 361 Json::Value fJsonExpectedResults;
359 }; 362 };
360 363
361 } 364 }
362 #endif 365 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698