OLD | NEW |
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 #include "SkCommandLineFlags.h" | 8 #include "SkCommandLineFlags.h" |
9 #include "SkGraphics.h" | 9 #include "SkGraphics.h" |
10 #include "SkOSFile.h" | 10 #include "SkOSFile.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 sk_atomic_inc(fFailCount); | 161 sk_atomic_inc(fFailCount); |
162 } | 162 } |
163 SkDELETE(this); | 163 SkDELETE(this); |
164 } | 164 } |
165 | 165 |
166 private: | 166 private: |
167 SkAutoTDelete<Test> fTest; | 167 SkAutoTDelete<Test> fTest; |
168 int32_t* fFailCount; | 168 int32_t* fFailCount; |
169 }; | 169 }; |
170 | 170 |
| 171 /* Takes a list of the form [~][^]match[$] |
| 172 ~ causes a matching test to always be skipped |
| 173 ^ requires the start of the test to match |
| 174 $ requires the end of the test to match |
| 175 ^ and $ requires an exact match |
| 176 If a test does not match any list entry, it is skipped unless some list entry
starts with ~ |
| 177 */ |
171 static bool shouldSkip(const char* testName) { | 178 static bool shouldSkip(const char* testName) { |
172 return !FLAGS_match.isEmpty() && !strstr(testName, FLAGS_match[0]); | 179 int count = FLAGS_match.count(); |
| 180 size_t testLen = strlen(testName); |
| 181 bool anyExclude = false; |
| 182 for (int index = 0; index < count; ++index) { |
| 183 const char* matchName = FLAGS_match[index]; |
| 184 size_t matchLen = strlen(matchName); |
| 185 bool matchExclude, matchStart, matchEnd; |
| 186 if ((matchExclude = matchName[0] == '~')) { |
| 187 anyExclude = true; |
| 188 matchName++; |
| 189 matchLen--; |
| 190 } |
| 191 if ((matchStart = matchName[0] == '^')) { |
| 192 matchName++; |
| 193 matchLen--; |
| 194 } |
| 195 if ((matchEnd = matchName[matchLen - 1] == '$')) { |
| 196 matchLen--; |
| 197 } |
| 198 if (matchStart ? (!matchEnd || matchLen == testLen) |
| 199 && strncmp(testName, matchName, matchLen) == 0 |
| 200 : matchEnd ? matchLen <= testLen |
| 201 && strncmp(testName + testLen - matchLen, matchName, matchLen) =
= 0 |
| 202 : strstr(testName, matchName) != 0) { |
| 203 return matchExclude; |
| 204 } |
| 205 } |
| 206 return !anyExclude; |
173 } | 207 } |
174 | 208 |
175 int tool_main(int argc, char** argv); | 209 int tool_main(int argc, char** argv); |
176 int tool_main(int argc, char** argv) { | 210 int tool_main(int argc, char** argv) { |
177 SkCommandLineFlags::SetUsage(""); | 211 SkCommandLineFlags::SetUsage(""); |
178 SkCommandLineFlags::Parse(argc, argv); | 212 SkCommandLineFlags::Parse(argc, argv); |
179 | 213 |
180 if (!FLAGS_tmpDir.isEmpty()) { | 214 if (!FLAGS_tmpDir.isEmpty()) { |
181 make_canonical_dir_path(FLAGS_tmpDir[0], &gTmpDir); | 215 make_canonical_dir_path(FLAGS_tmpDir[0], &gTmpDir); |
182 } | 216 } |
183 if (!FLAGS_resourcePath.isEmpty()) { | 217 if (!FLAGS_resourcePath.isEmpty()) { |
184 make_canonical_dir_path(FLAGS_resourcePath[0], &gResourcePath); | 218 make_canonical_dir_path(FLAGS_resourcePath[0], &gResourcePath); |
185 } | 219 } |
186 | 220 |
187 #if SK_ENABLE_INST_COUNT | 221 #if SK_ENABLE_INST_COUNT |
188 gPrintInstCount = true; | 222 gPrintInstCount = true; |
189 #endif | 223 #endif |
190 | 224 |
191 SkGraphics::Init(); | 225 SkGraphics::Init(); |
192 | 226 |
193 { | 227 { |
194 SkString header("Skia UnitTests:"); | 228 SkString header("Skia UnitTests:"); |
195 if (!FLAGS_match.isEmpty()) { | 229 if (!FLAGS_match.isEmpty()) { |
196 header.appendf(" --match %s", FLAGS_match[0]); | 230 header.appendf(" --match"); |
| 231 for (int index = 0; index < FLAGS_match.count(); ++index) { |
| 232 header.appendf(" %s", FLAGS_match[index]); |
| 233 } |
197 } | 234 } |
198 if (!gTmpDir.isEmpty()) { | 235 if (!gTmpDir.isEmpty()) { |
199 header.appendf(" --tmpDir %s", gTmpDir.c_str()); | 236 header.appendf(" --tmpDir %s", gTmpDir.c_str()); |
200 } | 237 } |
201 if (!gResourcePath.isEmpty()) { | 238 if (!gResourcePath.isEmpty()) { |
202 header.appendf(" --resourcePath %s", gResourcePath.c_str()); | 239 header.appendf(" --resourcePath %s", gResourcePath.c_str()); |
203 } | 240 } |
204 #ifdef SK_DEBUG | 241 #ifdef SK_DEBUG |
205 header.append(" SK_DEBUG"); | 242 header.append(" SK_DEBUG"); |
206 #else | 243 #else |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 GpuTest::DestroyContexts(); | 313 GpuTest::DestroyContexts(); |
277 | 314 |
278 return (failCount == 0) ? 0 : 1; | 315 return (failCount == 0) ? 0 : 1; |
279 } | 316 } |
280 | 317 |
281 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 318 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
282 int main(int argc, char * const argv[]) { | 319 int main(int argc, char * const argv[]) { |
283 return tool_main(argc, (char**) argv); | 320 return tool_main(argc, (char**) argv); |
284 } | 321 } |
285 #endif | 322 #endif |
OLD | NEW |