From b7c2792cea2db976c540ed4bf20ef1e382b851ae Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Tue, 18 Jul 2023 13:32:47 +0200 Subject: [PATCH] Nicer test failure output.. --- test/runner.cxx | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/test/runner.cxx b/test/runner.cxx index 6e7bc459a..dddc24896 100644 --- a/test/runner.cxx +++ b/test/runner.cxx @@ -201,23 +201,30 @@ int main(int argc, char const *argv[]) } catch (pqxx::feature_not_supported const &e) { - std::cerr << "Not testing unsupported feature: " << e.what() + std::cerr << "Not testing unsupported feature: " << e.what() << '\n'; #if pqxx_have_source_location - << "(" << e.location.file_name() << ':' << e.location.line() - << " in " << e.location.function_name() << " )" + std::string func{e.location.function_name()}; + std::cerr << "("; + std::cerr << e.location.file_name() << ':' << e.location.line(); + if (not func.empty()) + std::cerr << " in " << e.location.function_name(); + std::cerr << ")\n"; #endif - << std::endl; success = true; --test_count; } catch (pqxx::sql_error const &e) { - std::cerr << "SQL error: " << e.what() << std::endl + std::cerr << "SQL error: " << e.what() << '\n'; #if pqxx_have_source_location - << "(" << e.location.file_name() << ':' << e.location.line() - << " in " << e.location.function_name() << " )" + std::string func{e.location.function_name()}; + std::cerr << "("; + std::cerr << e.location.file_name() << ':' << e.location.line(); + if (not func.empty()) + std::cerr << " in " << e.location.function_name(); + std::cerr << ")\n"; #endif - << "Query was: " << e.query() << std::endl; + std::cerr << "Query was: " << e.query() << std::endl; } catch (std::exception const &e) {