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

Unified Diff: tools/image_expectations.h

Issue 289063010: make render_pictures properly handle empty expectations file (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: extract some shared test code Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/image_expectations.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/image_expectations.h
diff --git a/tools/image_expectations.h b/tools/image_expectations.h
index b7b135d91230b60f65936b99468441af467e6f9d..a24334e60d3b459d361b1ef701cdb75375e3b2aa 100644
--- a/tools/image_expectations.h
+++ b/tools/image_expectations.h
@@ -10,6 +10,7 @@
#include "SkBitmap.h"
#include "SkJSONCPP.h"
+#include "SkOSFile.h"
#include "SkRefCnt.h"
namespace sk_tools {
@@ -81,6 +82,20 @@ namespace sk_tools {
public:
/**
* Adds expectations from a JSON file, returning true if successful.
+ *
+ * If the file exists but is empty, it succeeds, and there will be no expectations.
+ * If the file does not exist, this will fail.
+ *
+ * Reasoning:
+ * Generating expectations the first time can be a tricky chicken-and-egg
+ * proposition. "I need actual results to turn into expectations... but the only
+ * way to get actual results is to run the tool, and the tool won't run without
+ * expectations!"
+ * We could make the tool run even if there is no expectations file at all, but it's
+ * better for the tool to fail if the expectations file is not found--that will tell us
+ * quickly if files are not being copied around as they should be.
+ * Creating an empty file is an easy way to break the chicken-and-egg cycle and generate
+ * the first real expectations.
*/
bool readExpectationsFile(const char *jsonPath);
@@ -116,11 +131,13 @@ namespace sk_tools {
private:
/**
- * Read the file contents from jsonPath and parse them into jsonRoot.
+ * Read the file contents from filePtr and parse them into jsonRoot.
+ *
+ * It is up to the caller to close filePtr after this is done.
*
* Returns true if successful.
*/
- static bool Parse(const char *jsonPath, Json::Value *jsonRoot);
+ static bool Parse(SkFILE* filePtr, Json::Value *jsonRoot);
Json::Value fActualResults;
Json::Value fExpectedJsonRoot;
« no previous file with comments | « no previous file | tools/image_expectations.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698