blob: 0fd83e5bb656a1406cd6842a55185a4df8b96f45 [file] [log] [blame]
mtklein@google.comd36522d2013-10-16 13:02:15 +00001#include "DMReporter.h"
2
commit-bot@chromium.org0caa68a2013-10-29 15:02:17 +00003#include "SkCommandLineFlags.h"
commit-bot@chromium.org261c6662014-01-02 16:19:53 +00004#include "OverwriteLine.h"
commit-bot@chromium.org0caa68a2013-10-29 15:02:17 +00005
commit-bot@chromium.org79e13262014-02-25 20:02:09 +00006DEFINE_bool(quiet, false, "If true, don't print status updates.");
commit-bot@chromium.org0caa68a2013-10-29 15:02:17 +00007
mtklein@google.comd36522d2013-10-16 13:02:15 +00008namespace DM {
9
commit-bot@chromium.org79e13262014-02-25 20:02:09 +000010void Reporter::updateStatusLine() const {
commit-bot@chromium.org0caa68a2013-10-29 15:02:17 +000011 if (FLAGS_quiet) {
12 return;
13 }
14
mtklein@google.coma7a9f372013-10-18 20:52:44 +000015 SkString status;
commit-bot@chromium.org79e13262014-02-25 20:02:09 +000016 status.printf("%s%d tasks left", kSkOverwriteLine, this->started() - this->finished());
mtklein@google.coma7a9f372013-10-18 20:52:44 +000017 const int failed = this->failed();
18 if (failed > 0) {
19 status.appendf(", %d failed", failed);
20 }
21 SkDebugf(status.c_str());
mtklein@google.comd36522d2013-10-16 13:02:15 +000022}
23
24int32_t Reporter::failed() const {
25 SkAutoMutexAcquire reader(&fMutex);
26 return fFailures.count();
27}
28
commit-bot@chromium.org79e13262014-02-25 20:02:09 +000029void Reporter::fail(SkString name) {
mtklein@google.comd36522d2013-10-16 13:02:15 +000030 SkAutoMutexAcquire writer(&fMutex);
commit-bot@chromium.org79e13262014-02-25 20:02:09 +000031 fFailures.push_back(name);
mtklein@google.comd36522d2013-10-16 13:02:15 +000032}
33
34void Reporter::getFailures(SkTArray<SkString>* failures) const {
35 SkAutoMutexAcquire reader(&fMutex);
36 *failures = fFailures;
37}
38
39} // namespace DM