diff --git a/include/mimic++/Stacktrace.hpp b/include/mimic++/Stacktrace.hpp index f79da4a9c..9b689a787 100644 --- a/include/mimic++/Stacktrace.hpp +++ b/include/mimic++/Stacktrace.hpp @@ -381,10 +381,12 @@ namespace mimicpp::stacktrace::detail { assert(index < stacktrace.size() && "Index out of bounds."); + out = format::format_to(std::move(out), "`"); out = print_path(std::move(out), stacktrace.source_file(index)); + out = format::format_to(std::move(out), "`"); out = format::format_to( std::move(out), - "[{}], {}", + "#L{}, `{}`", stacktrace.source_line(index), stacktrace.description(index)); diff --git a/test/custom-stacktrace-tests/Printing.cpp b/test/custom-stacktrace-tests/Printing.cpp index ac275263b..cede1e999 100644 --- a/test/custom-stacktrace-tests/Printing.cpp +++ b/test/custom-stacktrace-tests/Printing.cpp @@ -52,7 +52,7 @@ TEST_CASE( const auto text = mimicpp::print(stacktrace); REQUIRE_THAT( text, - Catch::Matchers::Equals("#0 test.cpp[1337], Hello, World!\n")); + Catch::Matchers::Equals("#0 `test.cpp`#L1337, `Hello, World!`\n")); } SECTION("When stacktrace contains multiple entries.") @@ -79,7 +79,7 @@ TEST_CASE( REQUIRE_THAT( text, Catch::Matchers::Equals( - "#0 other-test.cpp[42], Hello, mimic++!\n" - "#1 test.cpp[1337], Hello, World!\n")); + "#0 `other-test.cpp`#L42, `Hello, mimic++!`\n" + "#1 `test.cpp`#L1337, `Hello, World!`\n")); } } diff --git a/test/unit-tests/Stacktrace.cpp b/test/unit-tests/Stacktrace.cpp index 8958c82ad..bb388e02b 100644 --- a/test/unit-tests/Stacktrace.cpp +++ b/test/unit-tests/Stacktrace.cpp @@ -281,10 +281,12 @@ TEST_CASE( const std::string pattern = format::format( R"((?:#\d+ )" // always starts with the entry index + "`" R"((?:\/?)" // may begin with a / R"((?:(?:\d|\w|_|-|\+|\*|\.)+(?:\\|\/))*)" // arbitrary times `dir/` R"((?:\d|\w|_|-|\+|\*|\.)+)?)" // file name; sometimes there is no file, so the whole path may be empty - R"((?:\[\d+\],.+?\n)){{{}}})", // other stuff + "`" + R"((?:#L\d+, `.*`\n)){{{}}})", // other stuff size); REQUIRE_THAT( mimicpp::print(stacktrace),