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 | |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 6 | DEFINE_bool2(quiet, q, false, "If true, don't print status updates."); |
| 7 | DEFINE_bool2(verbose, v, false, "If true, print status updates one-per-line."); |
commit-bot@chromium.org | 0caa68a | 2013-10-29 15:02:17 +0000 | [diff] [blame] | 8 | |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 9 | namespace DM { |
| 10 | |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 11 | void Reporter::finish(SkString name) { |
| 12 | sk_atomic_inc(&fFinished); |
| 13 | |
commit-bot@chromium.org | 0caa68a | 2013-10-29 15:02:17 +0000 | [diff] [blame] | 14 | if (FLAGS_quiet) { |
| 15 | return; |
| 16 | } |
| 17 | |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 18 | SkString status; |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 19 | status.printf("%s%d tasks left", |
| 20 | FLAGS_verbose ? "\n" : kSkOverwriteLine, |
| 21 | this->started() - this->finished()); |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 22 | const int failed = this->failed(); |
| 23 | if (failed > 0) { |
| 24 | status.appendf(", %d failed", failed); |
| 25 | } |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 26 | status.appendf("\t[%s done]", name.c_str()); |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 27 | SkDebugf(status.c_str()); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | int32_t Reporter::failed() const { |
| 31 | SkAutoMutexAcquire reader(&fMutex); |
| 32 | return fFailures.count(); |
| 33 | } |
| 34 | |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 35 | void Reporter::fail(SkString msg) { |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 36 | SkAutoMutexAcquire writer(&fMutex); |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 37 | fFailures.push_back(msg); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | void Reporter::getFailures(SkTArray<SkString>* failures) const { |
| 41 | SkAutoMutexAcquire reader(&fMutex); |
| 42 | *failures = fFailures; |
| 43 | } |
| 44 | |
| 45 | } // namespace DM |