diff options
author | 2012-10-29 18:59:17 +0000 | |
---|---|---|
committer | 2012-10-29 18:59:17 +0000 | |
commit | 82cb65ba18150e1ff5b6a0e78a8630d59d4d4af9 (patch) | |
tree | 737f9d801063e06b5509e1a60468790ff7387a13 /gm | |
parent | 782f3b423095858d59162789f893fa977f8fd363 (diff) |
Alphabetize gm options (in usage message and option parser).
Also add long-form option names for all options.
Review URL: https://codereview.appspot.com/6817050
git-svn-id: http://skia.googlecode.com/svn/trunk@6173 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm')
-rw-r--r-- | gm/gmmain.cpp | 214 |
1 files changed, 109 insertions, 105 deletions
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp index 742fb46a56..54bbd8b9eb 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -748,11 +748,7 @@ static const ConfigData gRec[] = { }; static void usage(const char * argv0) { - // TODO: rearrange into alphabetical order - // TODO: add documentation for missing options SkDebugf("%s\n", argv0); - SkDebugf(" [-w writePath] [-r readPath] [-d diffPath] [-i resourcePath]\n"); - SkDebugf(" [-wp writePicturePath]\n"); SkDebugf(" [--config "); for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { if (i > 0) { @@ -760,31 +756,37 @@ static void usage(const char * argv0) { } SkDebugf(gRec[i].fName); } - SkDebugf(" ]\n"); - SkDebugf(" [--noreplay] [--nopipe] [--noserialize] [--forceBWtext] [--nopdf] \n" - " [--tiledPipe] [--hierarchy | --nohierarchy]\n" - " [--nodeferred] [--match substring] [--notexturecache]\n" - " [-h|--help]\n" - ); - SkDebugf(" writePath: directory to write rendered images in.\n"); - SkDebugf(" writePicturePath: directory to write images to in .skp format.\n"); - SkDebugf( - " readPath: directory to read reference images from;\n" - " reports if any pixels mismatch between reference and new images\n"); - SkDebugf(" diffPath: directory to write difference images in.\n"); - SkDebugf(" resourcePath: directory that stores image resources.\n"); - SkDebugf(" --noreplay: do not exercise SkPicture replay.\n"); - SkDebugf(" --nopipe: Skip SkGPipe replay.\n"); - SkDebugf(" --tiledPipe: Exercise tiled SkGPipe replay.\n"); + SkDebugf("]:\n run these configurations\n"); SkDebugf( - " --noserialize: do not exercise SkPicture serialization & deserialization.\n"); - SkDebugf(" --forceBWtext: disable text anti-aliasing.\n"); - SkDebugf(" --hierarchy: use multilevel directory structure when reading/writing files.\n"); - SkDebugf(" --nopdf: skip the pdf rendering test pass.\n"); - SkDebugf(" --nodeferred: skip the deferred rendering test pass.\n"); - SkDebugf(" --match foo: will only run tests that substring match foo.\n"); - SkDebugf(" --notexturecache: disable the gpu texture cache.\n"); - SkDebugf(" -h|--help : Show this help message. \n"); +// Alphabetized ignoring "no" prefix ("readPath", "noreplay", "resourcePath"). +// It would probably be better if we allowed both yes-and-no settings for each +// one, e.g.: +// [--replay|--noreplay]: whether to exercise SkPicture replay; default is yes +" [--nodeferred]: skip the deferred rendering test pass\n" +" [--diffPath|-d <path>]: write difference images into this directory\n" +" [--disable-missing-warning]: don't print a message to stderr if\n" +" unable to read a reference image for any tests (NOT default behavior)\n" +" [--enable-missing-warning]: print message to stderr (but don't fail) if\n" +" unable to read a reference image for any tests (default behavior)\n" +" [--forceBWtext]: disable text anti-aliasing\n" +" [--help|-h]: show this help message\n" +" [--hierarchy|--nohierarchy]: whether to use multilevel directory structure\n" +" when reading/writing files; default is no\n" +" [--match <substring>]: only run tests whose name includes this substring\n" +" [--modulo <remainder> <divisor>]: only run tests for which \n" +" testIndex %% divisor == remainder\n" +" [--nopdf]: skip the pdf rendering test pass\n" +" [--nopipe]: Skip SkGPipe replay\n" +" [--readPath|-r <path>]: read reference images from this dir, and report\n" +" any differences between those and the newly generated ones\n" +" [--noreplay]: do not exercise SkPicture replay\n" +" [--resourcePath|-i <path>]: directory that stores image resources\n" +" [--noserialize]: do not exercise SkPicture serialization & deserialization\n" +" [--notexturecache]: disable the gpu texture cache\n" +" [--tiledPipe]: Exercise tiled SkGPipe replay\n" +" [--writePath|-w <path>]: write rendered images into this directory\n" +" [--writePicturePath|-wp <path>]: write .skp files into this directory\n" + ); } static int findConfig(const char config[]) { @@ -887,106 +889,108 @@ int tool_main(int argc, char** argv) { SkTDArray<size_t> configs; bool userConfig = false; - int moduloIndex = -1; - int moduloCount = -1; + int moduloRemainder = -1; + int moduloDivisor = -1; const char* const commandName = argv[0]; char* const* stop = argv + argc; for (++argv; argv < stop; ++argv) { - // TODO: rearrange options into alphabetical order - if (strcmp(*argv, "-w") == 0) { - argv++; - if (argv < stop && **argv) { - writePath = *argv; - } - } else if (strcmp(*argv, "-wp") == 0) { + if (strcmp(*argv, "--config") == 0) { argv++; - if (argv < stop && **argv) { - writePicturePath = *argv; - } - } else if (strcmp(*argv, "-r") == 0) { - argv++; - if (argv < stop && **argv) { - readPath = *argv; + if (argv < stop) { + int index = findConfig(*argv); + if (index >= 0) { + *configs.append() = index; + userConfig = true; + } else { + SkString str; + str.printf("unrecognized config %s\n", *argv); + SkDebugf(str.c_str()); + usage(commandName); + return -1; + } + } else { + SkDebugf("missing arg for --config\n"); + usage(commandName); + return -1; } - } else if (strcmp(*argv, "-d") == 0) { + } else if (strcmp(*argv, "--nodeferred") == 0) { + doDeferred = false; + } else if ((0 == strcmp(*argv, "--diffPath")) || + (0 == strcmp(*argv, "-d"))) { argv++; if (argv < stop && **argv) { diffPath = *argv; } - } else if (strcmp(*argv, "-i") == 0) { - argv++; - if (argv < stop && **argv) { - resourcePath = *argv; - } + } else if (strcmp(*argv, "--disable-missing-warning") == 0) { + gmmain.fNotifyMissingReadReference = false; + } else if (strcmp(*argv, "--enable-missing-warning") == 0) { + gmmain.fNotifyMissingReadReference = true; } else if (strcmp(*argv, "--forceBWtext") == 0) { gForceBWtext = true; - } else if (strcmp(*argv, "--nopipe") == 0) { - doPipe = false; - } else if (strcmp(*argv, "--tiledPipe") == 0) { - doTiledPipe = true; - } else if (strcmp(*argv, "--noreplay") == 0) { - doReplay = false; - } else if (strcmp(*argv, "--nopdf") == 0) { - doPDF = false; - } else if (strcmp(*argv, "--nodeferred") == 0) { - doDeferred = false; + } else if (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0) { + usage(commandName); + return -1; + } else if (strcmp(*argv, "--hierarchy") == 0) { + gmmain.fUseFileHierarchy = true; + } else if (strcmp(*argv, "--nohierarchy") == 0) { + gmmain.fUseFileHierarchy = false; + } else if (strcmp(*argv, "--match") == 0) { + ++argv; + if (argv < stop && **argv) { + // just record the ptr, no need for a deep copy + *fMatches.append() = *argv; + } } else if (strcmp(*argv, "--modulo") == 0) { ++argv; if (argv >= stop) { continue; } - moduloIndex = atoi(*argv); + moduloRemainder = atoi(*argv); ++argv; if (argv >= stop) { continue; } - moduloCount = atoi(*argv); - } else if (strcmp(*argv, "--disable-missing-warning") == 0) { - gmmain.fNotifyMissingReadReference = false; - } else if (strcmp(*argv, "--enable-missing-warning") == 0) { - gmmain.fNotifyMissingReadReference = true; - } else if (strcmp(*argv, "--hierarchy") == 0) { - gmmain.fUseFileHierarchy = true; - } else if (strcmp(*argv, "--nohierarchy") == 0) { - gmmain.fUseFileHierarchy = false; + moduloDivisor = atoi(*argv); + } else if (strcmp(*argv, "--nopdf") == 0) { + doPDF = false; + } else if (strcmp(*argv, "--nopipe") == 0) { + doPipe = false; + } else if ((0 == strcmp(*argv, "--readPath")) || + (0 == strcmp(*argv, "-r"))) { + argv++; + if (argv < stop && **argv) { + readPath = *argv; + } + } else if (strcmp(*argv, "--noreplay") == 0) { + doReplay = false; + } else if ((0 == strcmp(*argv, "--resourcePath")) || + (0 == strcmp(*argv, "-i"))) { + argv++; + if (argv < stop && **argv) { + resourcePath = *argv; + } } else if (strcmp(*argv, "--serialize") == 0) { - // Leaving in this option so that a user need not modify - // their command line arguments to still run. doSerialize = true; } else if (strcmp(*argv, "--noserialize") == 0) { doSerialize = false; - } else if (strcmp(*argv, "--match") == 0) { - ++argv; - if (argv < stop && **argv) { - // just record the ptr, no need for a deep copy - *fMatches.append() = *argv; - } } else if (strcmp(*argv, "--notexturecache") == 0) { disableTextureCache = true; - } else if (strcmp(*argv, "--config") == 0) { + } else if (strcmp(*argv, "--tiledPipe") == 0) { + doTiledPipe = true; + } else if ((0 == strcmp(*argv, "--writePath")) || + (0 == strcmp(*argv, "-w"))) { argv++; - if (argv < stop) { - int index = findConfig(*argv); - if (index >= 0) { - *configs.append() = index; - userConfig = true; - } else { - SkString str; - str.printf("unrecognized config %s\n", *argv); - SkDebugf(str.c_str()); - usage(commandName); - return -1; - } - } else { - SkDebugf("missing arg for --config\n"); - usage(commandName); - return -1; + if (argv < stop && **argv) { + writePath = *argv; + } + } else if ((0 == strcmp(*argv, "--writePicturePath")) || + (0 == strcmp(*argv, "-wp"))) { + argv++; + if (argv < stop && **argv) { + writePicturePath = *argv; } - } else if (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0) { - usage(commandName); - return -1; } else { usage(commandName); return -1; @@ -1019,11 +1023,11 @@ int tool_main(int argc, char** argv) { fprintf(stderr, "reading resources from %s\n", resourcePath); } - if (moduloCount <= 0) { - moduloIndex = -1; + if (moduloDivisor <= 0) { + moduloRemainder = -1; } - if (moduloIndex < 0 || moduloIndex >= moduloCount) { - moduloIndex = -1; + if (moduloRemainder < 0 || moduloRemainder >= moduloDivisor) { + moduloRemainder = -1; } // Accumulate success of all tests. @@ -1067,11 +1071,11 @@ int tool_main(int argc, char** argv) { while ((gm = iter.next()) != NULL) { ++gmIndex; - if (moduloIndex >= 0) { - if ((gmIndex % moduloCount) != moduloIndex) { + if (moduloRemainder >= 0) { + if ((gmIndex % moduloDivisor) != moduloRemainder) { continue; } - moduloStr.printf("[%d.%d] ", gmIndex, moduloCount); + moduloStr.printf("[%d.%d] ", gmIndex, moduloDivisor); } const char* shortName = gm->shortName(); |