OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/test/logging/win/test_log_collector.h" | 5 #include "chrome/test/logging/win/test_log_collector.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <ios> | 10 #include <ios> |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 255 |
256 if (also_emit_success_logs_ || test_info.result()->Failed()) { | 256 if (also_emit_success_logs_ || test_info.result()->Failed()) { |
257 std::cerr << "----- log messages for " | 257 std::cerr << "----- log messages for " |
258 << test_info.test_case_name() << "." << test_info.name() | 258 << test_info.test_case_name() << "." << test_info.name() |
259 << " above this line are repeated below -----" << std::endl; | 259 << " above this line are repeated below -----" << std::endl; |
260 // Dump the log to stderr. | 260 // Dump the log to stderr. |
261 logging_win::PrintLogFile(log_file_, &std::cerr); | 261 logging_win::PrintLogFile(log_file_, &std::cerr); |
262 std::cerr.flush(); | 262 std::cerr.flush(); |
263 } | 263 } |
264 | 264 |
265 if (!file_util::Delete(log_file_, false)) | 265 if (!base::Delete(log_file_, false)) |
266 LOG(ERROR) << "Failed to delete log file " << log_file_.value(); | 266 LOG(ERROR) << "Failed to delete log file " << log_file_.value(); |
267 } | 267 } |
268 | 268 |
269 log_file_.clear(); | 269 log_file_.clear(); |
270 } | 270 } |
271 | 271 |
272 // Invoked by the listener at test program end to shut down the logger and | 272 // Invoked by the listener at test program end to shut down the logger and |
273 // delete the temporary log directory. | 273 // delete the temporary log directory. |
274 void TestLogCollector::TearDown() { | 274 void TestLogCollector::TearDown() { |
275 file_logger_.reset(); | 275 file_logger_.reset(); |
276 | 276 |
277 ignore_result(log_temp_dir_.Delete()); | 277 ignore_result(log_temp_dir_.Delete()); |
278 } | 278 } |
279 | 279 |
280 } // namespace | 280 } // namespace |
281 | 281 |
282 void InstallTestLogCollector(testing::UnitTest* unit_test) { | 282 void InstallTestLogCollector(testing::UnitTest* unit_test) { |
283 // Must be called before running any tests. | 283 // Must be called before running any tests. |
284 DCHECK(unit_test); | 284 DCHECK(unit_test); |
285 DCHECK(!unit_test->current_test_case()); | 285 DCHECK(!unit_test->current_test_case()); |
286 | 286 |
287 g_test_log_collector.Get().Initialize(unit_test); | 287 g_test_log_collector.Get().Initialize(unit_test); |
288 } | 288 } |
289 | 289 |
290 } // namespace logging_win | 290 } // namespace logging_win |
OLD | NEW |