From 4c6c07503362fd84adf5eea66065162a38105c36 Mon Sep 17 00:00:00 2001 From: Vilius Sutkus '89 Date: Mon, 2 Sep 2024 17:58:13 +0300 Subject: [PATCH] Update error catcher in pdf2htmlEX Wrapper tests --- test/src/pdf2htmlEX_wrapper_test.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/test/src/pdf2htmlEX_wrapper_test.cpp b/test/src/pdf2htmlEX_wrapper_test.cpp index 8aaf123e..58f34678 100644 --- a/test/src/pdf2htmlEX_wrapper_test.cpp +++ b/test/src/pdf2htmlEX_wrapper_test.cpp @@ -20,6 +20,17 @@ namespace fs = std::filesystem; using pdf2htmlEXWrapperTests = ::testing::TestWithParam; +static void print_backtrace() { + void *array[10]; + int size = backtrace(array, 10); + char **symbols = backtrace_symbols(array, size); + for (int i = 0; i < size; i++) { + std::cerr << symbols[i] << std::endl; + } + free(symbols); + std::cerr << std::flush; +} + TEST_P(pdf2htmlEXWrapperTests, html) { const std::string test_file_path = GetParam(); const TestFile test_file = TestData::test_file(test_file_path); @@ -62,18 +73,12 @@ TEST_P(pdf2htmlEXWrapperTests, html) { std::cerr << "Exception in pdf2htmlEX_wrapper: " << std::endl << e.what() << std::endl << std::flush; - - void *array[10]; - int size = backtrace(array, 10); - char **symbols = backtrace_symbols(array, size); - for (int i = 0; i < size; i++) { - std::cerr << symbols[i] << std::endl; - } - free(symbols); - std::cerr << std::flush; - sleep(2); - + print_backtrace(); throw e; + } catch (...) { + std::cerr << "Exception in pdf2htmlEX_wrapper!" << std::endl << std::flush; + print_backtrace(); + throw std::runtime_error("Unexpected error"); } std::cerr << "End of test" << std::endl << std::flush; }