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

Unified Diff: tests/skia_test.cpp

Issue 19537005: Revert r10280, which caused https://code.google.com/p/skia/issues/detail?id=1441 (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 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 | « gyp/bench.gyp ('k') | tools/flags/SkCommandLineFlags.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/skia_test.cpp
===================================================================
--- tests/skia_test.cpp (revision 10283)
+++ tests/skia_test.cpp (working copy)
@@ -159,6 +159,44 @@
int32_t* fFailCount;
};
+/* Takes a list of the form [~][^]match[$]
+ ~ causes a matching test to always be skipped
+ ^ requires the start of the test to match
+ $ requires the end of the test to match
+ ^ and $ requires an exact match
+ If a test does not match any list entry, it is skipped unless some list entry starts with ~
+ */
+static bool shouldSkip(const char* testName) {
+ int count = FLAGS_match.count();
+ size_t testLen = strlen(testName);
+ bool anyExclude = count == 0;
+ for (int index = 0; index < count; ++index) {
+ const char* matchName = FLAGS_match[index];
+ size_t matchLen = strlen(matchName);
+ bool matchExclude, matchStart, matchEnd;
+ if ((matchExclude = matchName[0] == '~')) {
+ anyExclude = true;
+ matchName++;
+ matchLen--;
+ }
+ if ((matchStart = matchName[0] == '^')) {
+ matchName++;
+ matchLen--;
+ }
+ if ((matchEnd = matchName[matchLen - 1] == '$')) {
+ matchLen--;
+ }
+ if (matchStart ? (!matchEnd || matchLen == testLen)
+ && strncmp(testName, matchName, matchLen) == 0
+ : matchEnd ? matchLen <= testLen
+ && strncmp(testName + testLen - matchLen, matchName, matchLen) == 0
+ : strstr(testName, matchName) != 0) {
+ return matchExclude;
+ }
+ }
+ return !anyExclude;
+}
+
int tool_main(int argc, char** argv);
int tool_main(int argc, char** argv) {
SkCommandLineFlags::SetUsage("");
@@ -206,16 +244,9 @@
int total = 0;
int toRun = 0;
Test* test;
-
- SkTDArray<const char*> matchStrs;
- for(int i = 0; i < FLAGS_match.count(); ++i) {
- matchStrs.push(FLAGS_match[i]);
- }
-
while ((test = iter.next()) != NULL) {
SkAutoTDelete<Test> owned(test);
-
- if(!SkCommandLineFlags::ShouldSkip(matchStrs, test->getName())) {
+ if(!shouldSkip(test->getName())) {
toRun++;
}
total++;
@@ -231,7 +262,7 @@
SkTArray<Test*> unsafeTests; // Always passes ownership to an SkTestRunnable
for (int i = 0; i < total; i++) {
SkAutoTDelete<Test> test(iter.next());
- if (SkCommandLineFlags::ShouldSkip(matchStrs, test->getName())) {
+ if (shouldSkip(test->getName())) {
++skipCount;
} else if (!test->isThreadsafe()) {
unsafeTests.push_back() = test.detach();
« no previous file with comments | « gyp/bench.gyp ('k') | tools/flags/SkCommandLineFlags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698