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

Unified Diff: tools/skdiff_main.cpp

Issue 302443012: add a verbose flag to skdiff that shows the progress and status of (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address ben comments 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/skdiff_main.cpp
diff --git a/tools/skdiff_main.cpp b/tools/skdiff_main.cpp
index 9d0bcf55e9d92c64fee2628993b50671dae9fdab..ba3221678e51c8e6f2ea9e593c6271a3cea42804 100644
--- a/tools/skdiff_main.cpp
+++ b/tools/skdiff_main.cpp
@@ -311,6 +311,20 @@ static void get_bounds(DiffRecord& drp) {
get_bounds(drp.fComparison, "comparison");
}
+#ifdef SK_OS_WIN
+#define ANSI_COLOR_RED ""
+#define ANSI_COLOR_GREEN ""
+#define ANSI_COLOR_YELLOW ""
+#define ANSI_COLOR_RESET ""
+#else
+#define ANSI_COLOR_RED "\x1b[31m"
+#define ANSI_COLOR_GREEN "\x1b[32m"
+#define ANSI_COLOR_YELLOW "\x1b[33m"
+#define ANSI_COLOR_RESET "\x1b[0m"
+#endif
+
+#define VERBOSE_STATUS(status,color,filename) if (verbose) printf( "[ " color " %10s " ANSI_COLOR_RESET " ] %s\n", status, filename->c_str())
+
/// Creates difference images, returns the number that have a 0 metric.
/// If outputDir.isEmpty(), don't write out diff files.
static void create_diff_images (DiffMetricProc dmp,
@@ -323,6 +337,7 @@ static void create_diff_images (DiffMetricProc dmp,
const StringArray& nomatchSubstrings,
bool recurseIntoSubdirs,
bool getBounds,
+ bool verbose,
DiffSummary* summary) {
SkASSERT(!baseDir.isEmpty());
SkASSERT(!comparisonDir.isEmpty());
@@ -370,6 +385,8 @@ static void create_diff_images (DiffMetricProc dmp,
drp->fComparison.fFullPath = comparisonPath;
drp->fComparison.fStatus = DiffResource::kDoesNotExist_Status;
+ VERBOSE_STATUS("MISSING", ANSI_COLOR_YELLOW, baseFiles[i]);
+
++i;
} else if (v > 0) {
// in comparisonDir, but not in baseDir
@@ -386,6 +403,8 @@ static void create_diff_images (DiffMetricProc dmp,
drp->fComparison.fFullPath = comparisonPath;
drp->fComparison.fStatus = DiffResource::kExists_Status;
+ VERBOSE_STATUS("MISSING", ANSI_COLOR_YELLOW, comparisonFiles[j]);
+
++j;
} else {
// Found the same filename in both baseDir and comparisonDir.
@@ -413,20 +432,23 @@ static void create_diff_images (DiffMetricProc dmp,
if (NULL == baseFileBits || NULL == comparisonFileBits) {
if (NULL == baseFileBits) {
drp->fBase.fStatus = DiffResource::kCouldNotRead_Status;
+ VERBOSE_STATUS("READ FAIL", ANSI_COLOR_RED, baseFiles[i]);
}
if (NULL == comparisonFileBits) {
drp->fComparison.fStatus = DiffResource::kCouldNotRead_Status;
+ VERBOSE_STATUS("READ FAIL", ANSI_COLOR_RED, comparisonFiles[j]);
}
drp->fResult = DiffRecord::kCouldNotCompare_Result;
} else if (are_buffers_equal(baseFileBits, comparisonFileBits)) {
drp->fResult = DiffRecord::kEqualBits_Result;
-
+ VERBOSE_STATUS("MATCH", ANSI_COLOR_GREEN, baseFiles[i]);
} else {
AutoReleasePixels arp(drp);
get_bitmap(baseFileBits, drp->fBase, SkImageDecoder::kDecodePixels_Mode);
get_bitmap(comparisonFileBits, drp->fComparison,
SkImageDecoder::kDecodePixels_Mode);
+ VERBOSE_STATUS("DIFFERENT", ANSI_COLOR_RED, baseFiles[i]);
if (DiffResource::kDecoded_Status == drp->fBase.fStatus &&
DiffResource::kDecoded_Status == drp->fComparison.fStatus) {
create_and_write_diff_image(drp, dmp, colorThreshold,
@@ -558,6 +580,7 @@ int tool_main(int argc, char** argv) {
bool listFilenames = false;
bool printDirNames = true;
bool recurseIntoSubdirs = true;
+ bool verbose = false;
RecordArray differences;
DiffSummary summary;
@@ -625,6 +648,10 @@ int tool_main(int argc, char** argv) {
listFilenames = true;
continue;
}
+ if (!strcmp(argv[i], "--verbose")) {
+ verbose = true;
+ continue;
+ }
if (!strcmp(argv[i], "--match")) {
matchSubstrings.push(new SkString(argv[++i]));
continue;
@@ -728,7 +755,7 @@ int tool_main(int argc, char** argv) {
create_diff_images(diffProc, colorThreshold, &differences,
baseDir, comparisonDir, outputDir,
matchSubstrings, nomatchSubstrings, recurseIntoSubdirs, generateDiffs,
- &summary);
+ verbose, &summary);
summary.print(listFilenames, failOnResultType, failOnStatusType);
if (differences.count()) {
« 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