1 parent
e7186f17f0
commit
f0825fbd1a
13 files changed
+105
-36
No files matched your search
@@ -1,5 +1,5 @@
|
||||
#include <Void/Testing/Detail/Stacktrace.hpp>
|
||||
#include <Void/Testing/Detail/Color.hpp>
|
||||
#include <Void/Stacktrace/Stacktrace.hpp>
|
||||
#include <Void/Stacktrace/Color.hpp>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <format>
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <boost/stacktrace.hpp>
|
||||
#include <boost/core/demangle.hpp>
|
||||
|
||||
namespace Void::Testing::Detail {
|
||||
namespace Void::Stacktrace {
|
||||
|
||||
std::vector<StackFrame> capture_stacktrace(unsigned skip_frames, unsigned max_frames) {
|
||||
std::vector<StackFrame> result;
|
||||
@@ -61,4 +61,4 @@ std::string format_stacktrace(const std::vector<StackFrame>& frames) {
|
||||
}
|
||||
|
||||
void print_stacktrace(std::ostream& os, const std::vector<StackFrame>& frames) { os << format_stacktrace(frames); }
|
||||
} // namespace Void::Testing::Detail
|
||||
} // namespace Void::Stacktrace
|
||||
@@ -0,0 +1,6 @@
|
||||
void_add_module(Stacktrace
|
||||
EXTERNAL_DEPS Boost::stacktrace_backtrace
|
||||
DEPS_WIN32 dbghelp
|
||||
DEPS_UNIX dl
|
||||
OPTIONS_UNIX -g -fno-omit-frame-pointer
|
||||
)
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Detail/Stacktrace.hpp>
|
||||
namespace Void::Testing::Detail {
|
||||
void handle_assertion(AssertionResult result) {
|
||||
auto& ctx = TestContext::current();
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#include <Void/Testing/ConsoleReporter.hpp>
|
||||
#include <Void/Testing/Detail/Color.hpp>
|
||||
#include <Void/Stacktrace/Color.hpp>
|
||||
#include <Void/Testing/Detail/SignalHandler.hpp>
|
||||
#include <format>
|
||||
#include <chrono>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Void::Testing {
|
||||
using namespace Detail::Color;
|
||||
using namespace Void::Stacktrace::Color;
|
||||
|
||||
void ConsoleReporter::on_run_start(const RunConfig&, int total_tests) {
|
||||
os_ << "\n" << apply(bold_blue, "╭──────────────────────────────────────────────╮") << "\n"
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
#include "Void/Testing/Config.hpp"
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/ConsoleReporter.hpp>
|
||||
#include <Void/Testing/Detail/Color.hpp>
|
||||
#include <Void/Stacktrace/Color.hpp>
|
||||
#include <Void/Stacktrace/Stacktrace.hpp>
|
||||
#include <Void/Testing/Detail/Registry.hpp>
|
||||
#include <Void/Testing/Detail/SignalHandler.hpp>
|
||||
#include <Void/Testing/Detail/Stacktrace.hpp>
|
||||
#include <Void/Testing/JUnitReporter.hpp>
|
||||
#include <algorithm>
|
||||
#include <csignal>
|
||||
@@ -161,13 +161,13 @@ namespace Void::Testing
|
||||
result.state = TestState::Failed;
|
||||
result.crash_info =
|
||||
std::format("Unhandled exception: {}", e.what());
|
||||
result.stacktrace =
|
||||
Detail::format_stacktrace(Detail::capture_stacktrace(1, 8));
|
||||
result.stacktrace = Void::Stacktrace::format_stacktrace(
|
||||
Void::Stacktrace::capture_stacktrace(1, 8));
|
||||
} catch (...) {
|
||||
result.state = TestState::Failed;
|
||||
result.crash_info = "Unhandled unknown exception";
|
||||
result.stacktrace =
|
||||
Detail::format_stacktrace(Detail::capture_stacktrace(1, 8));
|
||||
result.stacktrace = Void::Stacktrace::format_stacktrace(
|
||||
Void::Stacktrace::capture_stacktrace(1, 8));
|
||||
}
|
||||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
@@ -209,9 +209,9 @@ namespace Void::Testing
|
||||
|
||||
RunResult Runner::run(const RunConfig& config)
|
||||
{
|
||||
Detail::Color::g_color_enabled = !config.no_color;
|
||||
Void::Stacktrace::Color::g_color_enabled = !config.no_color;
|
||||
if (config.show_help) {
|
||||
using namespace Detail::Color;
|
||||
using namespace Void::Stacktrace::Color;
|
||||
|
||||
std::cout
|
||||
<< "\n"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <Void/Testing/Detail/SignalHandler.hpp>
|
||||
#include <Void/Testing/Detail/Stacktrace.hpp>
|
||||
#include <Void/Stacktrace/Stacktrace.hpp>
|
||||
#include <csignal>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
@@ -30,8 +30,8 @@ const char* signal_name(int sig) {
|
||||
|
||||
static void crash_handler(int sig) {
|
||||
g_last_signal = sig;
|
||||
auto frames = capture_stacktrace(1, 16);
|
||||
auto trace = format_stacktrace(frames);
|
||||
auto frames = Void::Stacktrace::capture_stacktrace(1, 16);
|
||||
auto trace = Void::Stacktrace::format_stacktrace(frames);
|
||||
if (g_crash_callback) g_crash_callback(sig, trace);
|
||||
#ifndef _WIN32
|
||||
if (g_jump_ready) { g_jump_ready = false; siglongjmp(g_jump_buffer, sig); }
|
||||
|
||||
@@ -1,8 +1 @@
|
||||
void_add_module(Testing EXTERNAL_DEPS Boost::stacktrace_backtrace)
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(Void_Testing PUBLIC dbghelp)
|
||||
else()
|
||||
target_link_libraries(Void_Testing PUBLIC dl)
|
||||
target_compile_options(Void_Testing PRIVATE -g -fno-omit-frame-pointer)
|
||||
endif()
|
||||
void_add_module(Testing INTERNAL_DEPS Stacktrace)
|
||||
Reference in new issue
Block a user