Also proxy bumpTestCount.
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 23 Apr 2013 11:16:32 +0000 (11:16 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 23 Apr 2013 11:16:32 +0000 (11:16 +0000)
Example output with -v -x:

...
Finished 127 tests, 0 failures, 0 skipped.
Ran 73094673 Internal tests.

BUG=
R=caryclark@google.com

Author: mtklein@google.com

Review URL: https://chromiumcodereview.appspot.com/13983011

git-svn-id: http://skia.googlecode.com/svn/trunk@8821 2bbb7eff-a529-9590-31e7-b0007b416f81

tests/Test.cpp
tests/Test.h

index 07db969..5558a0b 100644 (file)
@@ -60,7 +60,7 @@ const char* Test::getName() {
 namespace {
     class LocalReporter : public Reporter {
     public:
-        explicit LocalReporter(const Reporter& reporterToMimic) : fReporter(reporterToMimic) {}
+        explicit LocalReporter(Reporter* reporterToMimic) : fReporter(reporterToMimic) {}
 
         int failure_size() const { return fFailures.count(); }
         const char* failure(int i) const { return fFailures[i].c_str(); }
@@ -72,16 +72,21 @@ namespace {
             }
         }
 
+        // Proxy down to fReporter.  We assume these calls are threadsafe.
         virtual bool allowExtendedTest() const SK_OVERRIDE {
-            return fReporter.allowExtendedTest();
+            return fReporter->allowExtendedTest();
         }
 
         virtual bool allowThreaded() const SK_OVERRIDE {
-            return fReporter.allowThreaded();
+            return fReporter->allowThreaded();
+        }
+
+        virtual void bumpTestCount() SK_OVERRIDE {
+            fReporter->bumpTestCount();
         }
 
     private:
-        const Reporter& fReporter;
+        Reporter* fReporter;  // Unowned.
         SkTArray<SkString> fFailures;
     };
 }  // namespace
@@ -93,7 +98,7 @@ void Test::run() {
     const SkMSec start = SkTime::GetMSecs();
     // Run the test into a LocalReporter so we know if it's passed or failed without interference
     // from other tests that might share fReporter.
-    LocalReporter local(*fReporter);
+    LocalReporter local(fReporter);
     this->onRun(&local);
     fPassed = local.failure_size() == 0;
     fElapsed = SkTime::GetMSecs() - start;
index a4baf5b..dfa12a6 100644 (file)
@@ -32,14 +32,16 @@ namespace skiatest {
             kLastResult = kFailed
         };
 
-        void bumpTestCount() { sk_atomic_inc(&fTestCount); }
         int countTests() const { return fTestCount; }
 
         void startTest(Test*);
         void report(const char testDesc[], Result);
         void endTest(Test*);
+
         virtual bool allowExtendedTest() const { return false; }
         virtual bool allowThreaded() const { return false; }
+        virtual void bumpTestCount() { sk_atomic_inc(&fTestCount); }
+
         // helpers for tests
         void reportFailed(const char desc[]) {
             this->report(desc, kFailed);