Index: dm/DM.cpp |
diff --git a/dm/DM.cpp b/dm/DM.cpp |
index 274ec2a815eb89f8aa6ab40d478da116f9df9050..65fccc761177893b1f1f49609533c076f0e7fb36 100644 |
--- a/dm/DM.cpp |
+++ b/dm/DM.cpp |
@@ -14,18 +14,18 @@ |
#include "DMTaskRunner.h" |
#include "DMCpuTask.h" |
#include "DMGpuTask.h" |
+#include "DMWriteTask.h" |
#include <string.h> |
using skiagm::GM; |
using skiagm::GMRegistry; |
-using skiagm::Expectations; |
-using skiagm::ExpectationsSource; |
-using skiagm::JsonExpectationsSource; |
DEFINE_int32(cpuThreads, -1, "Threads for CPU work. Default NUM_CPUS."); |
DEFINE_int32(gpuThreads, 1, "Threads for GPU work."); |
-DEFINE_string(expectations, "", "Compare generated images against JSON expectations at this path."); |
+DEFINE_string2(expectations, r, "", |
+ "If a directory, compare generated images against images under this path. " |
+ "If a file, compare generated images against JSON expectations at this path."); |
DEFINE_string(resources, "resources", "Path to resources directory."); |
DEFINE_string(match, "", "[~][^]substring[$] [...] of GM name to run.\n" |
"Multiple matches may be separated by spaces.\n" |
@@ -50,7 +50,7 @@ static SkString lowercase(SkString s) { |
static void kick_off_tasks(const SkTDArray<GMRegistry::Factory>& gms, |
const SkTArray<SkString>& configs, |
- const ExpectationsSource& expectations, |
+ const DM::Expectations& expectations, |
DM::Reporter* reporter, |
DM::TaskRunner* tasks) { |
const SkBitmap::Config _565 = SkBitmap::kRGB_565_Config; |
@@ -107,13 +107,6 @@ static void report_failures(const DM::Reporter& reporter) { |
} |
} |
-class NoExpectations : public ExpectationsSource { |
-public: |
- Expectations get(const char* /*testName*/) const SK_OVERRIDE { |
- return Expectations(); |
- } |
-}; |
- |
int tool_main(int argc, char** argv); |
int tool_main(int argc, char** argv) { |
SkGraphics::Init(); |
@@ -134,9 +127,14 @@ int tool_main(int argc, char** argv) { |
} |
SkDebugf("%d GMs x %d configs\n", gms.count(), configs.count()); |
- SkAutoTUnref<ExpectationsSource> expectations(SkNEW(NoExpectations)); |
+ SkAutoTDelete<DM::Expectations> expectations(SkNEW(DM::NoExpectations)); |
if (FLAGS_expectations.count() > 0) { |
- expectations.reset(SkNEW_ARGS(JsonExpectationsSource, (FLAGS_expectations[0]))); |
+ const char* path = FLAGS_expectations[0]; |
+ if (sk_isdir(path)) { |
+ expectations.reset(SkNEW_ARGS(DM::WriteTask::Expectations, (path))); |
+ } else { |
+ expectations.reset(SkNEW_ARGS(DM::JsonExpectations, (path))); |
+ } |
} |
DM::Reporter reporter; |