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")
# And create an executable from it. Also include 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.
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.
target_compile_definitions(ArbutilsTests PRIVATE TESTS_BUILD)
endif ()

View File

@ -1,6 +1,8 @@
#ifndef ARBUTILS_EXCEPTION_HPP
#define ARBUTILS_EXCEPTION_HPP
#if !WINDOWS
#define BACKWARD_HAS_BFD 1
#endif
#include <exception>
#include <sstream>
@ -34,7 +36,7 @@ namespace ArbUt {
function += "...";
}
ss << objectName;
if (include_addr){
if (include_addr) {
ss << "[" << trace.addr << "]";
}
ss << " " << function << std::endl;

View File

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