diff options
-rw-r--r-- | bench/benchmain.cpp | 35 | ||||
-rw-r--r-- | gm/gmmain.cpp | 41 | ||||
-rw-r--r-- | gyp/bench.gyp | 1 | ||||
-rw-r--r-- | tests/skia_test.cpp | 49 | ||||
-rw-r--r-- | tools/flags/SkCommandLineFlags.cpp | 31 | ||||
-rw-r--r-- | tools/flags/SkCommandLineFlags.h | 11 |
6 files changed, 59 insertions, 109 deletions
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp index c0f6da90ec..1ace7d108a 100644 --- a/bench/benchmain.cpp +++ b/bench/benchmain.cpp @@ -22,6 +22,7 @@ class GrContext; #include "SkBenchLogger.h" #include "SkBenchmark.h" #include "SkCanvas.h" +#include "SkCommandLineFlags.h" #include "SkDeferredCanvas.h" #include "SkDevice.h" #include "SkColorPriv.h" @@ -270,38 +271,6 @@ static int findConfig(const char config[]) { return -1; } -static bool skip_name(const SkTDArray<const char*> array, const char name[]) { - // FIXME: this duplicates the logic in skia_test.cpp, gmmain.cpp -- consolidate - int count = array.count(); - size_t testLen = strlen(name); - bool anyExclude = count == 0; - for (int i = 0; i < array.count(); ++i) { - const char* matchName = array[i]; - 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(name, matchName, matchLen) == 0 - : matchEnd ? matchLen <= testLen - && strncmp(name + testLen - matchLen, matchName, matchLen) == 0 - : strstr(name, matchName) != 0) { - return matchExclude; - } - } - return !anyExclude; -} - static void help() { SkString configsStr; static const size_t kConfigCount = SK_ARRAY_COUNT(gConfigs); @@ -771,7 +740,7 @@ int tool_main(int argc, char** argv) { } // only run benchmarks if their name contains matchStr - if (skip_name(fMatches, bench->getName())) { + if (SkCommandLineFlags::ShouldSkip(fMatches, bench->getName())) { continue; } diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp index 01eaaebffd..c0471d5868 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -38,8 +38,6 @@ #include "SkTileGridPicture.h" #include "SamplePipeControllers.h" -__SK_FORCE_IMAGE_DECODER_LINKING; - #ifdef SK_BUILD_FOR_WIN // json includes xlocale which generates warning 4530 because we're compiling without // exceptions; see https://code.google.com/p/skia/issues/detail?id=1067 @@ -1410,38 +1408,6 @@ static int findConfig(const char config[]) { return -1; } -static bool skip_name(SkCommandLineFlags::StringArray array, const char name[]) { - // FIXME: this duplicates the logic in test/skia_test.cpp -- consolidate - int count = array.count(); - size_t testLen = strlen(name); - bool anyExclude = count == 0; - for (int i = 0; i < array.count(); ++i) { - const char* matchName = array[i]; - 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(name, matchName, matchLen) == 0 - : matchEnd ? matchLen <= testLen - && strncmp(name + testLen - matchLen, matchName, matchLen) == 0 - : strstr(name, matchName) != 0) { - return matchExclude; - } - } - return !anyExclude; -} - namespace skiagm { #if SK_SUPPORT_GPU SkAutoTUnref<GrContext> gGrContext; @@ -2076,7 +2042,12 @@ int tool_main(int argc, char** argv) { } const char* shortName = gm->shortName(); - if (skip_name(FLAGS_match, shortName)) { + + SkTDArray<const char*> matchStrs; + for (int i = 0; i < FLAGS_match.count(); ++i) { + matchStrs.push(FLAGS_match[i]); + } + if (SkCommandLineFlags::ShouldSkip(matchStrs, shortName)) { continue; } diff --git a/gyp/bench.gyp b/gyp/bench.gyp index 27f80cead9..040f7a4fcf 100644 --- a/gyp/bench.gyp +++ b/gyp/bench.gyp @@ -19,6 +19,7 @@ 'dependencies': [ 'skia_lib.gyp:skia_lib', 'bench_timer', + 'flags.gyp:flags', ], 'conditions': [ ['skia_gpu == 1', diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp index da63d42ea5..7a8308f641 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(); diff --git a/tools/flags/SkCommandLineFlags.cpp b/tools/flags/SkCommandLineFlags.cpp index ed8db8e705..b088b4e4d3 100644 --- a/tools/flags/SkCommandLineFlags.cpp +++ b/tools/flags/SkCommandLineFlags.cpp @@ -303,3 +303,34 @@ void SkCommandLineFlags::Parse(int argc, char** argv) { exit(0); } } + +bool SkCommandLineFlags::ShouldSkip(const SkTDArray<const char*>& strings, const char* name) { + int count = strings.count(); + size_t testLen = strlen(name); + bool anyExclude = count == 0; + for (int i = 0; i < strings.count(); ++i) { + const char* matchName = strings[i]; + 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(name, matchName, matchLen) == 0 + : matchEnd ? matchLen <= testLen + && strncmp(name + testLen - matchLen, matchName, matchLen) == 0 + : strstr(name, matchName) != 0) { + return matchExclude; + } + } + return !anyExclude; +} diff --git a/tools/flags/SkCommandLineFlags.h b/tools/flags/SkCommandLineFlags.h index d0e74502d8..51af933467 100644 --- a/tools/flags/SkCommandLineFlags.h +++ b/tools/flags/SkCommandLineFlags.h @@ -10,6 +10,7 @@ #include "SkString.h" #include "SkTArray.h" +#include "SkTDArray.h" /** * Including this file (and compiling SkCommandLineFlags.cpp) provides command line @@ -90,7 +91,6 @@ * strings) so that a flag can be followed by multiple parameters. */ - class SkFlagInfo; class SkCommandLineFlags { @@ -108,6 +108,15 @@ public: */ static void Parse(int argc, char** argv); + /* 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 SkTDArray<const char*>& strings, const char* name); + /** * Custom class for holding the arguments for a string flag. * Publicly only has accessors so the strings cannot be modified. |