aboutsummaryrefslogtreecommitdiff
path: root/tests/skia_test.cpp
diff options
context:
space:
mode:
authorsglez@google.com <sglez@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-23 17:26:34 +0000
committersglez@google.com <sglez@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-23 17:26:34 +0000
commit434251f87292808c1c461e48dba5d22735e74f97 (patch)
treec30beda131d9ebf56d3e7d1bd382f57d7349340f /tests/skia_test.cpp
parent88876dbac8338f5d9ff81a1f0ac03880788e2bea (diff)
downloadskia-434251f87292808c1c461e48dba5d22735e74f97.tar.gz
refactor duplication (shouldSkip and skip_name) into a utility function
R=caryclark@google.com, reed@google.com Review URL: https://codereview.chromium.org/19807005 git-svn-id: http://skia.googlecode.com/svn/trunk@10280 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/skia_test.cpp')
-rw-r--r--tests/skia_test.cpp49
1 files changed, 9 insertions, 40 deletions
diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp
index da63d42ea..7a8308f64 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -159,44 +159,6 @@ private:
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("");
@@ -244,9 +206,16 @@ int tool_main(int argc, char** argv) {
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(!shouldSkip(test->getName())) {
+
+ if(!SkCommandLineFlags::ShouldSkip(matchStrs, test->getName())) {
toRun++;
}
total++;
@@ -262,7 +231,7 @@ int tool_main(int argc, char** argv) {
SkTArray<Test*> unsafeTests; // Always passes ownership to an SkTestRunnable
for (int i = 0; i < total; i++) {
SkAutoTDelete<Test> test(iter.next());
- if (shouldSkip(test->getName())) {
+ if (SkCommandLineFlags::ShouldSkip(matchStrs, test->getName())) {
++skipCount;
} else if (!test->isThreadsafe()) {
unsafeTests.push_back() = test.detach();