From 1849baa955687bf290de4553fd6236be0b5b26ff Mon Sep 17 00:00:00 2001 From: Vilius Sutkus '89 Date: Mon, 2 Sep 2024 21:40:30 +0300 Subject: [PATCH] Use cpptrace library --- .github/workflows/build_test.yml | 2 +- conanfile.py | 1 + test/CMakeLists.txt | 2 ++ test/src/pdf2htmlEX_wrapper_test.cpp | 12 ++++++------ 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index f6fba27b..75418e25 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -50,7 +50,7 @@ jobs: - name: conan config run: conan config install .github/config/${{ matrix.os }}-${{ matrix.compiler }}/conan - name: conan install - run: conan install . --output-folder=build --build=never + run: conan install . --output-folder=build --build=missing - name: cache uses: actions/cache@v4 diff --git a/conanfile.py b/conanfile.py index afa4d402..1f9be342 100644 --- a/conanfile.py +++ b/conanfile.py @@ -40,6 +40,7 @@ def requirements(self): if self.options.get_safe("with_pdf2htmlEX"): self.requires("pdf2htmlex/0.18.8.rc1-20240814-git") self.requires("fontconfig/2.15.0-odr") + self.requires("cpptrace/0.7.0") if self.options.get_safe("with_wvWare"): self.requires("wvware/1.2.9") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4b4fddfe..27c7f52d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -78,6 +78,8 @@ target_link_libraries(odr_test if(WITH_PDF2HTMLEX) target_link_libraries(odr_test PRIVATE pdf2htmlex::pdf2htmlex) + find_package(cpptrace REQUIRED) + target_link_libraries(odr_test PRIVATE cpptrace::cpptrace) endif(WITH_PDF2HTMLEX) if(WITH_WVWARE) target_link_libraries(odr_test PRIVATE wvware::wvware) diff --git a/test/src/pdf2htmlEX_wrapper_test.cpp b/test/src/pdf2htmlEX_wrapper_test.cpp index 63963e61..35ea2c4f 100644 --- a/test/src/pdf2htmlEX_wrapper_test.cpp +++ b/test/src/pdf2htmlEX_wrapper_test.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include @@ -50,8 +50,7 @@ TEST_P(pdf2htmlEXWrapperTests, html) { } std::cout << "Calling pdf2htmlEX_wrapper" << std::endl << std::flush; - try { - std::this_thread::set_capture_stacktraces_at_throw(); + CPPTRACE_TRY { Html html = odr::internal::html::pdf2htmlEX_wrapper( test_file.path, output_path, config, password); std::cout << "Returned from pdf2htmlEX_wrapper" << std::endl << std::flush; @@ -59,10 +58,11 @@ TEST_P(pdf2htmlEXWrapperTests, html) { EXPECT_TRUE(fs::is_regular_file(html_page.path)); EXPECT_LT(0, fs::file_size(html_page.path)); } - } catch (...) { + } CPPTRACE_CATCH (...) { std::cerr << "Exception in pdf2htmlEX_wrapper!" << std::endl; - std::cerr << std::stacktrace::from_current_exception() << std::endl << std::flush; - + cpptrace::from_current_exception().print(); + std::cerr << std::flush; + std::cout << std::flush; throw std::runtime_error("Unexpected error"); } std::cerr << "End of test" << std::endl << std::flush;