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

Unified Diff: tests/Test.h

Issue 694703005: When running DM, write test failures to json. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use "" instead of NULL Created 6 years, 1 month 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 | « tests/GrTRecorderTest.cpp ('k') | tests/Test.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/Test.h
diff --git a/tests/Test.h b/tests/Test.h
index 6c85b32bce6d95204b1ac8e66d57676f4941281c..90cd25998f04397258ac3da5602d7c1e9f4ec53e 100644
--- a/tests/Test.h
+++ b/tests/Test.h
@@ -20,6 +20,40 @@ namespace skiatest {
class Test;
+ /**
+ * Information about a single failure from a Test.
+ *
+ * Not intended to be created/modified directly. To create one, use one of
+ *
+ * REPORTER_ASSERT
+ * REPORTER_ASSERT_MESSAGE
+ * ERRORF
+ *
+ * described in more detail further down in this file.
+ */
+ struct Failure {
+ const char* fileName;
+ int lineNo;
+ const char* condition;
+ SkString message;
+
+ // Helper to combine the failure info into one string.
+ void getFailureString(SkString* result) const {
+ if (!result) {
+ return;
+ }
+ result->printf("%s:%d\t", fileName, lineNo);
+ if (!message.isEmpty()) {
+ result->append(message);
+ if (strlen(condition) > 0) {
+ result->append(": ");
+ }
+ }
+ result->append(condition);
+ }
+ };
+
+
class Reporter : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(Reporter)
@@ -28,7 +62,7 @@ namespace skiatest {
int countTests() const { return fTestCount; }
void startTest(Test*);
- void reportFailed(const SkString& desc);
+ void reportFailed(const Failure&);
void endTest(Test*);
virtual bool allowExtendedTest() const { return false; }
@@ -37,7 +71,7 @@ namespace skiatest {
protected:
virtual void onStart(Test*) {}
- virtual void onReportFailed(const SkString& desc) {}
+ virtual void onReportFailed(const Failure&) {}
virtual void onEnd(Test*) {}
private:
@@ -110,31 +144,31 @@ namespace skiatest {
}
*/
-#define REPORTER_ASSERT(r, cond) \
- do { \
- if (!(cond)) { \
- SkString desc; \
- desc.printf("%s:%d\t%s", __FILE__, __LINE__, #cond); \
- r->reportFailed(desc); \
- } \
+#define REPORTER_ASSERT(r, cond) \
+ do { \
+ if (!(cond)) { \
+ skiatest::Failure failure = { __FILE__, __LINE__, \
+ #cond, SkString() }; \
+ r->reportFailed(failure); \
+ } \
} while(0)
-#define REPORTER_ASSERT_MESSAGE(r, cond, message) \
- do { \
- if (!(cond)) { \
- SkString desc; \
- desc.printf("%s:%d\t%s: %s", __FILE__, __LINE__, \
- message, #cond); \
- r->reportFailed(desc); \
- } \
+#define REPORTER_ASSERT_MESSAGE(r, cond, message) \
+ do { \
+ if (!(cond)) { \
+ skiatest::Failure failure = { __FILE__, __LINE__, \
+ #cond, SkString(message) }; \
+ r->reportFailed(failure); \
+ } \
} while(0)
-#define ERRORF(reporter, ...) \
- do { \
- SkString desc; \
- desc.printf("%s:%d\t", __FILE__, __LINE__); \
- desc.appendf(__VA_ARGS__) ; \
- (reporter)->reportFailed(desc); \
+#define ERRORF(r, ...) \
+ do { \
+ SkString desc; \
+ desc.appendf(__VA_ARGS__) ; \
+ skiatest::Failure failure = { __FILE__, __LINE__, \
+ "", SkString(desc) }; \
+ r->reportFailed(failure); \
} while(0)
#define DEF_TEST(name, reporter) \
« no previous file with comments | « tests/GrTRecorderTest.cpp ('k') | tests/Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698