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

Side by Side Diff: tools/flags/SkCommonFlags.cpp

Issue 1611323004: Treat bad values passed to --images as a fatal error (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 4 years, 10 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
« dm/DM.cpp ('K') | « tools/flags/SkCommonFlags.h ('k') | 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 2014 Google Inc. 2 * Copyright 2014 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 #include "SkCommonFlags.h" 8 #include "SkCommonFlags.h"
9 #include "SkOSFile.h"
9 10
10 DEFINE_bool(cpu, true, "master switch for running CPU-bound work."); 11 DEFINE_bool(cpu, true, "master switch for running CPU-bound work.");
11 12
12 DEFINE_bool(dryRun, false, 13 DEFINE_bool(dryRun, false,
13 "just print the tests that would be run, without actually running th em."); 14 "just print the tests that would be run, without actually running th em.");
14 15
15 DEFINE_bool(gpu, true, "master switch for running GPU-bound work."); 16 DEFINE_bool(gpu, true, "master switch for running GPU-bound work.");
16 17
17 DEFINE_string(images, "", "Directory of images to decode."); 18 DEFINE_string(images, "", "List of images and/or directories to decode. A direct ory with no images"
19 " is treated as a fatal error.");
18 20
19 DEFINE_string2(match, m, nullptr, 21 DEFINE_string2(match, m, nullptr,
20 "[~][^]substring[$] [...] of GM name to run.\n" 22 "[~][^]substring[$] [...] of GM name to run.\n"
21 "Multiple matches may be separated by spaces.\n" 23 "Multiple matches may be separated by spaces.\n"
22 "~ causes a matching GM to always be skipped\n" 24 "~ causes a matching GM to always be skipped\n"
23 "^ requires the start of the GM to match\n" 25 "^ requires the start of the GM to match\n"
24 "$ requires the end of the GM to match\n" 26 "$ requires the end of the GM to match\n"
25 "^ and $ requires an exact match\n" 27 "^ and $ requires an exact match\n"
26 "If a GM does not match any list entry,\n" 28 "If a GM does not match any list entry,\n"
27 "it is skipped unless some list entry starts with ~"); 29 "it is skipped unless some list entry starts with ~");
(...skipping 12 matching lines...) Expand all
40 DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver."); 42 DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver.");
41 43
42 DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose."); 44 DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose.");
43 45
44 DEFINE_string2(writePath, w, "", "If set, write bitmaps here as .pngs."); 46 DEFINE_string2(writePath, w, "", "If set, write bitmaps here as .pngs.");
45 47
46 DEFINE_string(key, "", 48 DEFINE_string(key, "",
47 "Space-separated key/value pairs to add to JSON identifying this b uilder."); 49 "Space-separated key/value pairs to add to JSON identifying this b uilder.");
48 DEFINE_string(properties, "", 50 DEFINE_string(properties, "",
49 "Space-separated key/value pairs to add to JSON identifying this r un."); 51 "Space-separated key/value pairs to add to JSON identifying this r un.");
52 DEFINE_bool2(pre_log, p, false, "Log before running each test. May be incomprehe nsible when threading");
50 53
51 DEFINE_bool2(pre_log, p, false, "Log before running each test. May be incomprehe nsible when threading"); 54 bool CollectImages(SkTArray<SkString>* output) {
55 SkASSERT(output);
56
57 static const char* const exts[] = {
58 "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico" ,
59 "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO" ,
60 #ifdef SK_CODEC_DECODES_RAW
scroggo 2016/01/27 15:43:37 This could go in its own CL, but I'm moving it any
61 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
62 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
63 #endif
64 };
65
66 for (int i = 0; i < FLAGS_images.count(); ++i) {
67 const char* flag = FLAGS_images[i];
68 if (!sk_exists(flag)) {
69 SkDebugf("%s does not exist!\n", flag);
70 return false;
71 }
72
73 if (sk_isdir(flag)) {
74 // If the value passed in is a directory, add all the images
75 bool foundAnImage = false;
76 for (const char* ext : exts) {
77 SkOSFile::Iter it(flag, ext);
78 SkString file;
79 while (it.next(&file)) {
80 foundAnImage = true;
81 output->push_back() = SkOSPath::Join(flag, file.c_str());
82 }
83 }
84 if (!foundAnImage) {
85 SkDebugf("No supported images found in %s!\n", flag);
86 return false;
87 }
88 } else {
89 // Also add the value if it is a single image
90 output->push_back() = flag;
91 }
92 }
93 return true;
94 }
OLDNEW
« dm/DM.cpp ('K') | « tools/flags/SkCommonFlags.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698