| 80 | } |
| 81 | |
| 82 | void OnTestStart(const ::testing::TestInfo& testInfo) override { |
| 83 | // We fully format this marker before printing it to stderr/stdout because we want to print it atomically. |
| 84 | // If we were to write `std::cout << "\n###subtest-finished:" << name`, there would be a chance that |
| 85 | // someone else could sneak in and print something between `"\n###subtest-finished"` and `name` |
| 86 | // (this happens when test binary uses both `Cout` and `std::cout`). |
| 87 | auto marker = Join("", "\n###subtest-started:", testInfo.test_suite_name(), "::", testInfo.name(), "\n"); |
| 88 | |
| 89 | // Theoretically, we don't need to flush both `Cerr` and `std::cerr` here because both ultimately |
| 90 | // result in calling `fflush(stderr)`. However, there may be additional buffering logic |
| 91 | // going on (custom `std::cerr.tie()`, for example), so just to be sure, we flush both of them. |
| 92 | std::cout << std::flush; |
| 93 | Cout << marker << Flush; |
| 94 | |
| 95 | std::cerr << std::flush; |
| 96 | Cerr << marker << Flush; |
| 97 | |
| 98 | auto ts = std::chrono::duration_cast<std::chrono::duration<double>>( |
| 99 | std::chrono::system_clock::now().time_since_epoch()); |
| 100 | |
| 101 | (*Trace_) |
| 102 | << "{" |
| 103 | << "\"name\": \"subtest-started\", " |
| 104 | << "\"timestamp\": " << std::setprecision(14) << ts.count() << ", " |
| 105 | << "\"value\": {" |
| 106 | << "\"class\": " << EscapeJson(testInfo.test_suite_name()) << ", " |
| 107 | << "\"subtest\": " << EscapeJson(testInfo.name()) |
| 108 | << "}" |
| 109 | << "}" |
| 110 | << "\n" |
| 111 | << std::flush; |
| 112 | } |
| 113 | |
| 114 | void OnTestPartResult(const testing::TestPartResult& result) override { |
| 115 | if (!result.passed()) { |
nothing calls this directly
no test coverage detected