Skip to content

Commit f1c9e6d

Browse files
committed
fix(tests): windows insists on using backslash, so we'll remove them in the tests
1 parent 9fd4d63 commit f1c9e6d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/arkreactor/Error/Diagnostics.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ namespace Ark::Diagnostics
6565
else if (maybe_context && !ctx_same_file && !maybe_context->filename.empty())
6666
{
6767
// show the location of the parent of our error first
68-
fmt::print(os, "Error originated from file {}:{}\n", maybe_context->filename, maybe_context->at.start.line + 1);
68+
std::string uniformised_filename;
69+
std::ranges::replace_copy(maybe_context->filename, std::back_inserter(uniformised_filename), '\\', '/');
70+
fmt::print(os, "Error originated from file {}:{}\n", uniformised_filename, maybe_context->at.start.line + 1);
6971

7072
std::optional<decltype(internal::FilePos::line)> maybe_end_line = std::nullopt;
7173
if (maybe_context->at.end)
@@ -193,9 +195,11 @@ namespace Ark::Diagnostics
193195
const std::string& filename, const internal::FileSpan& at,
194196
const std::optional<CodeErrorContext>& maybe_context = std::nullopt)
195197
{
198+
std::string uniformised_filename;
199+
std::ranges::replace_copy(filename, std::back_inserter(uniformised_filename), '\\', '/');
196200
makeContext(
197201
ErrorLocation {
198-
.filename = filename,
202+
.filename = uniformised_filename,
199203
.start = at.start,
200204
.end = at.end },
201205
os, maybe_context, colorize);

tests/unittests/TestsHelper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ std::string sanitizeCodeError(const Ark::CodeError& e)
7575

7676
std::string diag = stream.str();
7777
diag.erase(std::ranges::remove(diag, '\r').begin(), diag.end());
78+
7879
while (diag.find(ARK_TESTS_ROOT) != std::string::npos)
7980
diag.erase(diag.find(ARK_TESTS_ROOT), std::size(ARK_TESTS_ROOT) - 1);
8081

0 commit comments

Comments
 (0)