aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm/DMReporter.cpp
blob: 31310d1cd9a70cbf7610ed03ae7fa91c454182d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "DMReporter.h"

#include "SkCommandLineFlags.h"

DEFINE_bool(quiet, false, "If true, don't print status updates.");

namespace DM {

void Reporter::updateStatusLine() const {
    if (FLAGS_quiet) {
        return;
    }

    SkString status;
    status.printf("\r\033[K%d tasks left", this->started() - this->finished());
    const int failed = this->failed();
    if (failed > 0) {
        status.appendf(", %d failed", failed);
    }
    SkDebugf(status.c_str());
}

int32_t Reporter::failed() const {
    SkAutoMutexAcquire reader(&fMutex);
    return fFailures.count();
}

void Reporter::fail(SkString name) {
    SkAutoMutexAcquire writer(&fMutex);
    fFailures.push_back(name);
}

void Reporter::getFailures(SkTArray<SkString>* failures) const {
    SkAutoMutexAcquire reader(&fMutex);
    *failures = fFailures;
}

}  // namespace DM