mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 1 | #include "DMReporter.h" |
| 2 | |
commit-bot@chromium.org | 0caa68a | 2013-10-29 15:02:17 +0000 | [diff] [blame] | 3 | #include "SkCommandLineFlags.h" |
commit-bot@chromium.org | 261c666 | 2014-01-02 16:19:53 +0000 | [diff] [blame] | 4 | #include "OverwriteLine.h" |
commit-bot@chromium.org | 0caa68a | 2013-10-29 15:02:17 +0000 | [diff] [blame] | 5 | |
| 6 | DEFINE_bool(quiet, false, "If true, don't print status updates."); |
| 7 | |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 8 | namespace DM { |
| 9 | |
| 10 | void Reporter::updateStatusLine() const { |
commit-bot@chromium.org | 0caa68a | 2013-10-29 15:02:17 +0000 | [diff] [blame] | 11 | if (FLAGS_quiet) { |
| 12 | return; |
| 13 | } |
| 14 | |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 15 | SkString status; |
commit-bot@chromium.org | 261c666 | 2014-01-02 16:19:53 +0000 | [diff] [blame] | 16 | status.printf("%s%d tasks left", kSkOverwriteLine, this->started() - this->finished()); |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 17 | const int failed = this->failed(); |
| 18 | if (failed > 0) { |
| 19 | status.appendf(", %d failed", failed); |
| 20 | } |
| 21 | SkDebugf(status.c_str()); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | int32_t Reporter::failed() const { |
| 25 | SkAutoMutexAcquire reader(&fMutex); |
| 26 | return fFailures.count(); |
| 27 | } |
| 28 | |
| 29 | void Reporter::fail(SkString name) { |
| 30 | SkAutoMutexAcquire writer(&fMutex); |
| 31 | fFailures.push_back(name); |
| 32 | } |
| 33 | |
| 34 | void Reporter::getFailures(SkTArray<SkString>* failures) const { |
| 35 | SkAutoMutexAcquire reader(&fMutex); |
| 36 | *failures = fFailures; |
| 37 | } |
| 38 | |
| 39 | } // namespace DM |