diff options
author | caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-10 15:57:31 +0000 |
---|---|---|
committer | caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-10 15:57:31 +0000 |
commit | d54e1e9751eea63b528a6e62d919d06929c9bd8f (patch) | |
tree | 2686ad359501c785c970e830feea5af77289a608 | |
parent | 66089e4ec4f1702caf2154780471417872862148 (diff) |
add extended option to Test
The command line option
--extended runs extended tests
--verbose reports number of tests run (if recorded)
Added simple help as well.
Review URL: https://codereview.chromium.org/14063005
git-svn-id: http://skia.googlecode.com/svn/trunk@8595 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | tests/Test.cpp | 3 | ||||
-rw-r--r-- | tests/Test.h | 2 | ||||
-rw-r--r-- | tests/skia_test.cpp | 45 |
3 files changed, 42 insertions, 8 deletions
diff --git a/tests/Test.cpp b/tests/Test.cpp index e0b997a8b7..79d3aad581 100644 --- a/tests/Test.cpp +++ b/tests/Test.cpp @@ -20,7 +20,8 @@ SK_DEFINE_INST_COUNT(skiatest::Reporter) using namespace skiatest; -Reporter::Reporter() { +Reporter::Reporter() + : fTestCount(0) { this->resetReporting(); } diff --git a/tests/Test.h b/tests/Test.h index ca2acc65c2..f90edab1c1 100644 --- a/tests/Test.h +++ b/tests/Test.h @@ -31,6 +31,7 @@ namespace skiatest { }; void resetReporting(); + void bumpTestCount() { ++fTestCount; } int countTests() const { return fTestCount; } int countResults(Result r) { SkASSERT((unsigned)r <= kLastResult); @@ -40,6 +41,7 @@ namespace skiatest { void startTest(Test*); void report(const char testDesc[], Result); void endTest(Test*); + virtual bool allowExtendedTest() const { return false; } // helpers for tests void assertTrue(bool cond, const char desc[]) { diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp index 9a632172d2..f99ae8c0a5 100644 --- a/tests/skia_test.cpp +++ b/tests/skia_test.cpp @@ -61,12 +61,21 @@ static const char* result2string(Reporter::Result result) { class DebugfReporter : public Reporter { public: - DebugfReporter() : fIndex(0), fTotal(0) {} + DebugfReporter(bool allowExtendedTest) + : fIndex(0) + , fTotal(0) + , fAllowExtendedTest(allowExtendedTest) { + } void setIndexOfTotal(int index, int total) { fIndex = index; fTotal = total; } + + virtual bool allowExtendedTest() const { + return fAllowExtendedTest; + } + protected: virtual void onStart(Test* test) { SkDebugf("[%d/%d] %s...\n", fIndex+1, fTotal, test->getName()); @@ -81,6 +90,7 @@ protected: } private: int fIndex, fTotal; + bool fAllowExtendedTest; }; static const char* make_canonical_dir_path(const char* path, SkString* storage) { @@ -116,13 +126,16 @@ int tool_main(int argc, char** argv) { #if SK_ENABLE_INST_COUNT gPrintInstCount = true; #endif + bool allowExtendedTest = false; + bool verboseOutput = false; + SkGraphics::Init(); const char* matchStr = NULL; char* const* stop = argv + argc; for (++argv; argv < stop; ++argv) { - if (strcmp(*argv, "--match") == 0) { + if (0 == strcmp(*argv, "--match") || 0 == strcmp(*argv, "-m")) { ++argv; if (argv < stop && **argv) { matchStr = *argv; @@ -130,7 +143,7 @@ int tool_main(int argc, char** argv) { SkDebugf("no following argument to --match\n"); return -1; } - } else if (0 == strcmp(*argv, "--tmpDir")) { + } else if (0 == strcmp(*argv, "--tmpDir") || 0 == strcmp(*argv, "-t")) { ++argv; if (argv < stop && **argv) { make_canonical_dir_path(*argv, &gTmpDir); @@ -138,12 +151,27 @@ int tool_main(int argc, char** argv) { SkDebugf("no following argument to --tmpDir\n"); return -1; } - } else if ((0 == strcmp(*argv, "--resourcePath")) || - (0 == strcmp(*argv, "-i"))) { + } else if (0 == strcmp(*argv, "--resourcePath") || 0 == strcmp(*argv, "-i")) { argv++; if (argv < stop && **argv) { make_canonical_dir_path(*argv, &gResourcePath); } + } else if (0 == strcmp(*argv, "--extendedTest") || 0 == strcmp(*argv, "-x")) { + allowExtendedTest = true; + } else if (0 == strcmp(*argv, "--verbose") || 0 == strcmp(*argv, "-v")) { + verboseOutput = true; + } else { + if (0 != strcmp(*argv, "--help") && 0 != strcmp(*argv, "-h") + && 0 != strcmp(*argv, "-?")) { + SkDebugf("Unknown option %s. ", *argv); + } + SkDebugf("Skia UnitTests options are:\n"); + SkDebugf(" -m --match [test-name-substring]\n"); + SkDebugf(" -t --tmpDir [dir]\n"); + SkDebugf(" -i --resourcePath [dir]\n"); + SkDebugf(" -x --extendedTest\n"); + SkDebugf(" -v --verbose\n"); + return 1; } } @@ -171,7 +199,7 @@ int tool_main(int argc, char** argv) { SkDebugf("%s\n", header.c_str()); } - DebugfReporter reporter; + DebugfReporter reporter(allowExtendedTest); Iter iter(&reporter); Test* test; @@ -194,7 +222,10 @@ int tool_main(int argc, char** argv) { SkDebugf("Finished %d tests, %d failures, %d skipped.\n", count, failCount, skipCount); - + int testCount = reporter.countTests(); + if (verboseOutput && testCount > 0) { + SkDebugf("Ran %d Internal tests.\n", testCount); + } #if SK_SUPPORT_GPU #if GR_CACHE_STATS |