From 8e61c9be6d339ea7076ce79ad87b923fe6143f95 Mon Sep 17 00:00:00 2001 From: "Matthew \"strager\" Glazar" Date: Sat, 8 Oct 2022 22:07:03 -0700 Subject: [PATCH] feat(io): add debug logging on error to help track down bug Tests are flaky on Windows [1]. Here's what I see on CI when a failure happens: [snip] 1: [----------] 5 tests from typescript/test_parse_conditional_expression (0 ms total) 1: 1: [----------] Global test environment tear-down 1: [==========] 1879 tests from 145 test suites ran. (9726 ms total) 1: [ PASSED ] 1879 tests. 1: 1: YOU HAVE 1 DISABLED TEST 1: 1: D:/a/quick-lint-js/quick-lint-js/src/quick-lint-js/io/output-stream.cpp:101: internal check failed in flush_impl: false 1: quick-lint-js crashed. Please report this bug here: 1: https://quick-lint-js.com/crash-report/ 1/2 Test #1: quick-lint-js-test ...............***Failed 9.77 sec Add some debug logs to help isolate the bug. [1] https://github.com/quick-lint/quick-lint-js/issues/859 --- src/quick-lint-js/io/output-stream.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/quick-lint-js/io/output-stream.cpp b/src/quick-lint-js/io/output-stream.cpp index 0280c8fd6b..28d9e802f8 100644 --- a/src/quick-lint-js/io/output-stream.cpp +++ b/src/quick-lint-js/io/output-stream.cpp @@ -98,6 +98,11 @@ void file_output_stream::flush_impl(string8_view data) { // (stdout/stderr). auto write_result = this->file_.write_full(data.data(), data.size()); if (!write_result.ok()) { + std::fprintf( + stderr, + "fatal: file_output_stream::flush_impl failed to write data: %s\n", + write_result.error_to_string().c_str()); + std::fflush(stderr); QLJS_UNIMPLEMENTED(); } }