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