OLD | NEW |
1 #include "DMReporter.h" | 1 #include "DMReporter.h" |
2 | 2 |
3 #include "SkCommandLineFlags.h" | 3 #include "SkCommandLineFlags.h" |
4 #include "OverwriteLine.h" | 4 #include "OverwriteLine.h" |
5 | 5 |
6 DEFINE_bool2(quiet, q, false, "If true, don't print status updates."); | 6 DEFINE_bool(quiet, false, "If true, don't print status updates."); |
7 DEFINE_bool2(verbose, v, false, "If true, print status updates one-per-line."); | |
8 | 7 |
9 namespace DM { | 8 namespace DM { |
10 | 9 |
11 void Reporter::finish(SkString name) { | 10 void Reporter::updateStatusLine() const { |
12 sk_atomic_inc(&fFinished); | |
13 | |
14 if (FLAGS_quiet) { | 11 if (FLAGS_quiet) { |
15 return; | 12 return; |
16 } | 13 } |
17 | 14 |
18 SkString status; | 15 SkString status; |
19 status.printf("%s%d tasks left", | 16 status.printf("%s%d tasks left", kSkOverwriteLine, this->started() - this->f
inished()); |
20 FLAGS_verbose ? "\n" : kSkOverwriteLine, | |
21 this->started() - this->finished()); | |
22 const int failed = this->failed(); | 17 const int failed = this->failed(); |
23 if (failed > 0) { | 18 if (failed > 0) { |
24 status.appendf(", %d failed", failed); | 19 status.appendf(", %d failed", failed); |
25 } | 20 } |
26 status.appendf("\t[%s done]", name.c_str()); | |
27 SkDebugf(status.c_str()); | 21 SkDebugf(status.c_str()); |
28 } | 22 } |
29 | 23 |
30 int32_t Reporter::failed() const { | 24 int32_t Reporter::failed() const { |
31 SkAutoMutexAcquire reader(&fMutex); | 25 SkAutoMutexAcquire reader(&fMutex); |
32 return fFailures.count(); | 26 return fFailures.count(); |
33 } | 27 } |
34 | 28 |
35 void Reporter::fail(SkString msg) { | 29 void Reporter::fail(SkString name) { |
36 SkAutoMutexAcquire writer(&fMutex); | 30 SkAutoMutexAcquire writer(&fMutex); |
37 fFailures.push_back(msg); | 31 fFailures.push_back(name); |
38 } | 32 } |
39 | 33 |
40 void Reporter::getFailures(SkTArray<SkString>* failures) const { | 34 void Reporter::getFailures(SkTArray<SkString>* failures) const { |
41 SkAutoMutexAcquire reader(&fMutex); | 35 SkAutoMutexAcquire reader(&fMutex); |
42 *failures = fFailures; | 36 *failures = fFailures; |
43 } | 37 } |
44 | 38 |
45 } // namespace DM | 39 } // namespace DM |
OLD | NEW |