Don't use stacktrace on Windows.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2020-08-15 14:19:36 +02:00
parent 002902eed9
commit e778b61839
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
3 changed files with 11 additions and 8 deletions

View File

@ -26,8 +26,12 @@ if (TESTS)
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp") file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
# And create an executable from it. Also include catch.hpp. # And create an executable from it. Also include catch.hpp.
add_executable(ArbutilsTests ${TEST_FILES} extern/catch.hpp) add_executable(ArbutilsTests ${TEST_FILES} extern/catch.hpp)
set(LINKS Arbutils)
if (NOT WINDOWS)
set(LINKS ${LINKS} -lbfd -ldl)
endif()
# And finally link the library to the executable. # And finally link the library to the executable.
target_link_libraries(ArbutilsTests Arbutils -lbfd -ldl) target_link_libraries(ArbutilsTests ${LINKS})
# Add a compilation definition to the code that we are building a test build. # Add a compilation definition to the code that we are building a test build.
target_compile_definitions(ArbutilsTests PRIVATE TESTS_BUILD) target_compile_definitions(ArbutilsTests PRIVATE TESTS_BUILD)
endif () endif ()

View File

@ -1,6 +1,8 @@
#ifndef ARBUTILS_EXCEPTION_HPP #ifndef ARBUTILS_EXCEPTION_HPP
#define ARBUTILS_EXCEPTION_HPP #define ARBUTILS_EXCEPTION_HPP
#if !WINDOWS
#define BACKWARD_HAS_BFD 1 #define BACKWARD_HAS_BFD 1
#endif
#include <exception> #include <exception>
#include <sstream> #include <sstream>

View File

@ -6,14 +6,11 @@ using namespace ArbUt;
TEST_CASE("Throw exception get stack trace") { TEST_CASE("Throw exception get stack trace") {
try { try {
throw ArbUt::Exception("foobar"); throw ArbUt::Exception("foobar");
} } catch (const ArbUt::Exception& e) {
catch (const ArbUt::Exception& e) {
#ifndef NDEBUG #ifndef NDEBUG
REQUIRE(e.GetStacktrace(1) == REQUIRE(e.GetStacktrace(1) == "ExceptionTests.cpp[8] ____C_A_T_C_H____T_E_S_T____0()\n");
"ExceptionTests.cpp[8] ____C_A_T_C_H____T_E_S_T____0()\n");
#else #else
REQUIRE(e.GetStacktrace(1, false) == REQUIRE(e.GetStacktrace(1, false) == "ArbutilsTests Catch::RunContext::runTest(Catch::TestCase const&)\n");
"ArbutilsTests Catch::RunContext::runTest(Catch::TestCase const&)\n");
#endif #endif
} }
} }