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

Side by Side Diff: gm/gmmain.cpp

Issue 13842014: Add option to specify defaults configs to --config flag in gm. This makes it easier to run gm defau… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Add option to specify defaults configs to --config flag in gm. This makes it easier to run gm defau… Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 /* 8 /*
9 * Code for the "gm" (Golden Master) rendering comparison tool. 9 * Code for the "gm" (Golden Master) rendering comparison tool.
10 * 10 *
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 #endif // SK_SUPPORT_GPU 1161 #endif // SK_SUPPORT_GPU
1162 #ifdef SK_SUPPORT_XPS 1162 #ifdef SK_SUPPORT_XPS
1163 /* At present we have no way of comparing XPS files (either natively or by c onverting to PNG). */ 1163 /* At present we have no way of comparing XPS files (either natively or by c onverting to PNG). */
1164 { SkBitmap::kARGB_8888_Config, kXPS_Backend, kDontCare_GLContextType, 0, kWrite_ConfigFlag, "xps", true }, 1164 { SkBitmap::kARGB_8888_Config, kXPS_Backend, kDontCare_GLContextType, 0, kWrite_ConfigFlag, "xps", true },
1165 #endif // SK_SUPPORT_XPS 1165 #endif // SK_SUPPORT_XPS
1166 #ifdef SK_SUPPORT_PDF 1166 #ifdef SK_SUPPORT_PDF
1167 { SkBitmap::kARGB_8888_Config, kPDF_Backend, kDontCare_GLContextType, 0, kPDFConfigFlags, "pdf", true }, 1167 { SkBitmap::kARGB_8888_Config, kPDF_Backend, kDontCare_GLContextType, 0, kPDFConfigFlags, "pdf", true },
1168 #endif // SK_SUPPORT_PDF 1168 #endif // SK_SUPPORT_PDF
1169 }; 1169 };
1170 1170
1171 static const char kDefaultsConfigStr[] = "defaults";
1172 static const char kExcludeConfigChar = '~';
1173
1171 static SkString configUsage() { 1174 static SkString configUsage() {
1172 SkString result; 1175 SkString result;
1173 result.appendf("Space delimited list of which configs to run. Possible optio ns: ["); 1176 result.appendf("Space delimited list of which configs to run. Possible optio ns: [");
1174 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { 1177 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
1178 SkASSERT(gRec[i].fName != kDefaultsConfigStr);
1175 if (i > 0) { 1179 if (i > 0) {
1176 result.append("|"); 1180 result.append("|");
1177 } 1181 }
1178 result.appendf("%s", gRec[i].fName); 1182 result.appendf("%s", gRec[i].fName);
1179 } 1183 }
1180 result.append("]\n"); 1184 result.append("]\n");
1181 result.appendf("The default value is: \""); 1185 result.appendf("The default value is: \"");
1186 SkString firstDefault;
1187 SkString allButFirstDefaults;
1188 SkString firstNonDefault;
1182 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { 1189 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
1183 if (gRec[i].fRunByDefault) { 1190 if (gRec[i].fRunByDefault) {
1184 if (i > 0) { 1191 if (i > 0) {
1185 result.append(" "); 1192 result.append(" ");
1186 } 1193 }
1187 result.appendf("%s", gRec[i].fName); 1194 result.append(gRec[i].fName);
1195 if (firstDefault.isEmpty()) {
1196 firstDefault = gRec[i].fName;
1197 } else {
1198 if (!allButFirstDefaults.isEmpty()) {
1199 allButFirstDefaults.append(" ");
1200 }
1201 allButFirstDefaults.append(gRec[i].fName);
1202 }
1203 } else if (firstNonDefault.isEmpty()) {
epoger 2013/04/23 16:29:40 you could just remember *a* nonDefault config, whi
bsalomon 2013/04/24 15:13:54 Done.
1204 firstNonDefault = gRec[i].fName;
1188 } 1205 }
1189 } 1206 }
1190 result.appendf("\""); 1207 result.append("\"\n");
1191 1208 result.appendf("\"%s\" evaluates to the default set of configs.\n", kDefault sConfigStr);
1209 result.appendf("Prepending \"%c\" on a config name excludes it from the set of configs to run.\n",
1210 kExcludeConfigChar);
1211 result.appendf("E.g. \"--config %s %c%s %s\" will run these configs:\n\t%s % s",
1212 kDefaultsConfigStr,
1213 kExcludeConfigChar,
1214 firstDefault.c_str(),
1215 firstNonDefault.c_str(),
1216 allButFirstDefaults.c_str(),
1217 firstNonDefault.c_str());
1192 return result; 1218 return result;
1193 } 1219 }
1194 1220
1195 // Macro magic to convert a numeric preprocessor token into a string. 1221 // Macro magic to convert a numeric preprocessor token into a string.
1196 // Adapted from http://stackoverflow.com/questions/240353/convert-a-preprocessor -token-to-a-string 1222 // Adapted from http://stackoverflow.com/questions/240353/convert-a-preprocessor -token-to-a-string
1197 // This should probably be moved into one of our common headers... 1223 // This should probably be moved into one of our common headers...
1198 #define TOSTRING_INTERNAL(x) #x 1224 #define TOSTRING_INTERNAL(x) #x
1199 #define TOSTRING(x) TOSTRING_INTERNAL(x) 1225 #define TOSTRING(x) TOSTRING_INTERNAL(x)
1200 1226
1201 // Alphabetized ignoring "no" prefix ("readPath", "noreplay", "resourcePath"). 1227 // Alphabetized ignoring "no" prefix ("readPath", "noreplay", "resourcePath").
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 usage.printf("Run the golden master tests.\n"); 1639 usage.printf("Run the golden master tests.\n");
1614 SkCommandLineFlags::SetUsage(usage.c_str()); 1640 SkCommandLineFlags::SetUsage(usage.c_str());
1615 SkCommandLineFlags::Parse(argc, argv); 1641 SkCommandLineFlags::Parse(argc, argv);
1616 1642
1617 gmmain.fUseFileHierarchy = FLAGS_hierarchy; 1643 gmmain.fUseFileHierarchy = FLAGS_hierarchy;
1618 if (FLAGS_mismatchPath.count() == 1) { 1644 if (FLAGS_mismatchPath.count() == 1) {
1619 gmmain.fMismatchPath = FLAGS_mismatchPath[0]; 1645 gmmain.fMismatchPath = FLAGS_mismatchPath[0];
1620 } 1646 }
1621 1647
1622 for (int i = 0; i < FLAGS_config.count(); i++) { 1648 for (int i = 0; i < FLAGS_config.count(); i++) {
1623 int index = findConfig(FLAGS_config[i]); 1649 const char* config = FLAGS_config[i];
1650 userConfig = true;
1651 bool exclude = false;
1652 if (*config == kExcludeConfigChar) {
1653 exclude = true;
1654 config += 1;
1655 }
1656 int index = findConfig(config);
1624 if (index >= 0) { 1657 if (index >= 0) {
1625 appendUnique<size_t>(&configs, index); 1658 if (exclude) {
1626 userConfig = true; 1659 *excludeConfigs.append() = index;
1660 } else {
1661 appendUnique<size_t>(&configs, index);
1662 }
1663 } else if (0 == strcmp(kDefaultsConfigStr, config)) {
1664 for (size_t c = 0; c < SK_ARRAY_COUNT(gRec); ++c) {
1665 if (gRec[c].fRunByDefault) {
1666 if (exclude) {
epoger 2013/04/23 16:29:40 OMG. The caller can pass "~defaults" to exclude a
bsalomon 2013/04/24 15:13:54 The existing --excludeConfig works this way (exclu
1667 *excludeConfigs.append() = c;
1668 } else {
1669 appendUnique<size_t>(&configs, c);
1670 }
1671 }
1672 }
1627 } else { 1673 } else {
1628 gm_fprintf(stderr, "unrecognized config %s\n", FLAGS_config[i]); 1674 gm_fprintf(stderr, "unrecognized config %s\n", config);
1629 return -1; 1675 return -1;
1630 } 1676 }
1631 } 1677 }
1632 1678
1633 for (int i = 0; i < FLAGS_excludeConfig.count(); i++) { 1679 for (int i = 0; i < FLAGS_excludeConfig.count(); i++) {
1634 int index = findConfig(FLAGS_excludeConfig[i]); 1680 int index = findConfig(FLAGS_excludeConfig[i]);
1635 if (index >= 0) { 1681 if (index >= 0) {
1636 *excludeConfigs.append() = index; 1682 *excludeConfigs.append() = index;
1637 } else { 1683 } else {
1638 gm_fprintf(stderr, "unrecognized excludeConfig %s\n", FLAGS_excludeC onfig[i]); 1684 gm_fprintf(stderr, "unrecognized excludeConfig %s\n", FLAGS_excludeC onfig[i]);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 " Config will be skipped.\n", gRec[index].fSampleCnt, gRec[index].fName); 1778 " Config will be skipped.\n", gRec[index].fSampleCnt, gRec[index].fName);
1733 configs.remove(i); 1779 configs.remove(i);
1734 --i; 1780 --i;
1735 } 1781 }
1736 } 1782 }
1737 } 1783 }
1738 #else 1784 #else
1739 GrContextFactory* grFactory = NULL; 1785 GrContextFactory* grFactory = NULL;
1740 #endif 1786 #endif
1741 1787
1788 if (configs.isEmpty()) {
1789 gm_fprintf(stderr, "No configs to run.");
1790 return -1;
1791 }
1792
1793 // now show the user the set of configs that will be run.
1794 SkString configStr("These configs will be run: ");
epoger 2013/04/23 16:29:40 Maybe this should be guarded by if (FLAGS_verbose)
bsalomon 2013/04/24 15:13:54 If we're already printing each test as it runs in
1795 // show the user the config that will run.
1796 for (int i = 0; i < configs.count(); ++i) {
1797 configStr.appendf("%s%s", gRec[configs[i]].fName, (i == configs.count() - 1) ? "\n" : " ");
1798 }
1799 gm_fprintf(stdout, "%s", configStr.c_str());
1800
1742 if (FLAGS_resourcePath.count() == 1) { 1801 if (FLAGS_resourcePath.count() == 1) {
1743 GM::SetResourcePath(FLAGS_resourcePath[0]); 1802 GM::SetResourcePath(FLAGS_resourcePath[0]);
1744 } 1803 }
1745 1804
1746 if (FLAGS_readPath.count() == 1) { 1805 if (FLAGS_readPath.count() == 1) {
1747 const char* readPath = FLAGS_readPath[0]; 1806 const char* readPath = FLAGS_readPath[0];
1748 if (!sk_exists(readPath)) { 1807 if (!sk_exists(readPath)) {
1749 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath); 1808 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath);
1750 return -1; 1809 return -1;
1751 } 1810 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 if (FLAGS_forceBWtext) { 1970 if (FLAGS_forceBWtext) {
1912 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 1971 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
1913 } 1972 }
1914 } 1973 }
1915 1974
1916 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 1975 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
1917 int main(int argc, char * const argv[]) { 1976 int main(int argc, char * const argv[]) {
1918 return tool_main(argc, (char**) argv); 1977 return tool_main(argc, (char**) argv);
1919 } 1978 }
1920 #endif 1979 #endif
OLDNEW
« 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