diff --git a/angry b/angry new file mode 100644 index 00000000..e69de29b diff --git a/file b/file new file mode 100644 index 00000000..e69de29b diff --git a/src/arkreactor/Error/Diagnostics.cpp b/src/arkreactor/Error/Diagnostics.cpp index e90918ee..2f47b13f 100644 --- a/src/arkreactor/Error/Diagnostics.cpp +++ b/src/arkreactor/Error/Diagnostics.cpp @@ -65,7 +65,9 @@ namespace Ark::Diagnostics else if (maybe_context && !ctx_same_file && !maybe_context->filename.empty()) { // show the location of the parent of our error first - fmt::print(os, "Error originated from file {}:{}\n", maybe_context->filename, maybe_context->at.start.line + 1); + std::string uniformised_filename; + std::ranges::replace_copy(maybe_context->filename, std::back_inserter(uniformised_filename), '\\', '/'); + fmt::print(os, "Error originated from file {}:{}\n", uniformised_filename, maybe_context->at.start.line + 1); std::optional maybe_end_line = std::nullopt; if (maybe_context->at.end) @@ -193,9 +195,11 @@ namespace Ark::Diagnostics const std::string& filename, const internal::FileSpan& at, const std::optional& maybe_context = std::nullopt) { + std::string uniformised_filename; + std::ranges::replace_copy(filename, std::back_inserter(uniformised_filename), '\\', '/'); makeContext( ErrorLocation { - .filename = filename, + .filename = uniformised_filename, .start = at.start, .end = at.end }, os, maybe_context, colorize); diff --git a/tests/unittests/Suites/CompilerSuite.cpp b/tests/unittests/Suites/CompilerSuite.cpp index 464e7949..3e5934f4 100644 --- a/tests/unittests/Suites/CompilerSuite.cpp +++ b/tests/unittests/Suites/CompilerSuite.cpp @@ -81,7 +81,7 @@ ut::suite<"Compiler"> compiler_suite = [] { iterTestFiles( "CompilerSuite/ir", - [](TestData&& data) { + [](const TestData& data) { Ark::Welder welder(0, { lib_path }, features); should("compile without error ir/" + data.stem) = [&] { @@ -103,7 +103,7 @@ ut::suite<"Compiler"> compiler_suite = [] { iterTestFiles( "CompilerSuite/optimized_ir", - [](TestData&& data) { + [](const TestData& data) { Ark::Welder welder(0, { lib_path }, features); should("compile without error optimized_ir/" + data.stem) = [&] { diff --git a/tests/unittests/Suites/DiagnosticsSuite.cpp b/tests/unittests/Suites/DiagnosticsSuite.cpp index 6c6a96cb..64c145e8 100644 --- a/tests/unittests/Suites/DiagnosticsSuite.cpp +++ b/tests/unittests/Suites/DiagnosticsSuite.cpp @@ -14,7 +14,7 @@ ut::suite<"Diagnostics"> diagnostics_suite = [] { iterTestFiles( "DiagnosticsSuite/compileTime", - [](TestData&& data) { + [](const TestData& data) { Ark::State state({ lib_path }); should("generate an error message at compile time for compileTime/" + data.stem) = [&] { @@ -36,7 +36,7 @@ ut::suite<"Diagnostics"> diagnostics_suite = [] { iterTestFiles( "DiagnosticsSuite/runtime", - [](TestData&& data) { + [](const TestData& data) { Ark::State state({ lib_path }); should("compile without error runtime/" + data.stem) = [&] { @@ -62,7 +62,7 @@ ut::suite<"Diagnostics"> diagnostics_suite = [] { iterTestFiles( "DiagnosticsSuite/typeChecking", - [](TestData&& data) { + [](const TestData& data) { Ark::State state({ lib_path }); should("compile without error typeChecking/" + data.stem) = [&] { diff --git a/tests/unittests/Suites/FormatterSuite.cpp b/tests/unittests/Suites/FormatterSuite.cpp index 92d1eb19..c04cf0eb 100644 --- a/tests/unittests/Suites/FormatterSuite.cpp +++ b/tests/unittests/Suites/FormatterSuite.cpp @@ -11,7 +11,7 @@ ut::suite<"Formatter"> formatter_suite = [] { iterTestFiles( "FormatterSuite", - [](TestData&& data) { + [](const TestData& data) { std::string formatted_code; should("output a correctly formatted code for " + data.stem) = [&] { diff --git a/tests/unittests/Suites/OptimizerSuite.cpp b/tests/unittests/Suites/OptimizerSuite.cpp index 630b62fd..11ea619c 100644 --- a/tests/unittests/Suites/OptimizerSuite.cpp +++ b/tests/unittests/Suites/OptimizerSuite.cpp @@ -13,7 +13,7 @@ ut::suite<"Optimizer"> optimizer_suite = [] { "[generate optimized ast]"_test = [] { iterTestFiles( "OptimizerSuite", - [](TestData&& data) { + [](const TestData& data) { JsonCompiler compiler(false, { lib_path }, Ark::FeatureASTOptimizer); std::string json; diff --git a/tests/unittests/Suites/ParserSuite.cpp b/tests/unittests/Suites/ParserSuite.cpp index 0a518aeb..e02090e5 100644 --- a/tests/unittests/Suites/ParserSuite.cpp +++ b/tests/unittests/Suites/ParserSuite.cpp @@ -46,7 +46,7 @@ ut::suite<"Parser"> parser_suite = [] { "[successful parsing]"_test = [] { iterTestFiles( "ParserSuite/success", - [](TestData&& data) { + [](const TestData& data) { Ark::internal::Parser parser(/* debug= */ 0); should("parse " + data.stem) = [&] { @@ -68,7 +68,7 @@ ut::suite<"Parser"> parser_suite = [] { "[error reporting]"_test = [] { iterTestFiles( "ParserSuite/failure", - [](TestData&& data) { + [](const TestData& data) { try { Ark::internal::Parser parser(/* debug= */ 0); diff --git a/tests/unittests/Suites/RosettaSuite.cpp b/tests/unittests/Suites/RosettaSuite.cpp index 7bf9a1f7..76e6f33c 100644 --- a/tests/unittests/Suites/RosettaSuite.cpp +++ b/tests/unittests/Suites/RosettaSuite.cpp @@ -13,7 +13,7 @@ ut::suite<"Rosetta"> rosetta_suite = [] { "[run arkscript rosetta code solutions]"_test = [] { iterTestFiles( "RosettaSuite", - [](TestData&& data) { + [](const TestData&data) { Ark::State state({ lib_path }); should("compile " + data.stem) = [&] { diff --git a/tests/unittests/Suites/TypeCheckerSuite.cpp b/tests/unittests/Suites/TypeCheckerSuite.cpp index 96330e85..bc9bdb9c 100644 --- a/tests/unittests/Suites/TypeCheckerSuite.cpp +++ b/tests/unittests/Suites/TypeCheckerSuite.cpp @@ -177,7 +177,7 @@ ut::suite<"TypeChecker"> type_checker_suite = [] { iterTestFiles( "TypeCheckerSuite", - [&](TestData&& data) { + [&](const TestData& data) { std::vector inputs; std::vector contracts; @@ -185,7 +185,7 @@ ut::suite<"TypeChecker"> type_checker_suite = [] { { iterTestFiles( data.path, - [&inputs](TestData&& inner) { + [&inputs](const TestData& inner) { const Input input = parse_input(inner.path); expect(fatal(input.initialized)) << "invalid test input: " << inner.stem; inputs.push_back(input); diff --git a/tests/unittests/Suites/ValidAstSuite.cpp b/tests/unittests/Suites/ValidAstSuite.cpp index e74b7f69..4678995a 100644 --- a/tests/unittests/Suites/ValidAstSuite.cpp +++ b/tests/unittests/Suites/ValidAstSuite.cpp @@ -13,7 +13,7 @@ ut::suite<"AST"> ast_suite = [] { "[generate valid ast]"_test = [] { iterTestFiles( "ASTSuite", - [](TestData&& data) { + [](const TestData& data) { JsonCompiler compiler(false, { lib_path }); std::string json; diff --git a/tests/unittests/TestsHelper.cpp b/tests/unittests/TestsHelper.cpp index 648229df..74e28a60 100644 --- a/tests/unittests/TestsHelper.cpp +++ b/tests/unittests/TestsHelper.cpp @@ -28,7 +28,7 @@ void updateExpectedFile(const TestData& data, const std::string& actual) } } -void iterTestFiles(const std::string& folder, std::function&& test, IterTestFilesParam&& params) +void iterTestFiles(const std::string& folder, std::function&& test, IterTestFilesParam&& params) { boost::ut::test(folder) = [&] { const auto path = params.folder_is_resource ? getResourcePath(folder) : folder; @@ -58,7 +58,7 @@ void iterTestFiles(const std::string& folder, std::function&& .is_folder = is_directory(entry.path()) }; - test(std::move(data)); + test(data); } }; } @@ -75,6 +75,7 @@ std::string sanitizeCodeError(const Ark::CodeError& e) std::string diag = stream.str(); diag.erase(std::ranges::remove(diag, '\r').begin(), diag.end()); + while (diag.find(ARK_TESTS_ROOT) != std::string::npos) diag.erase(diag.find(ARK_TESTS_ROOT), std::size(ARK_TESTS_ROOT) - 1); diff --git a/tests/unittests/TestsHelper.hpp b/tests/unittests/TestsHelper.hpp index 726dd9fd..f5d58f27 100644 --- a/tests/unittests/TestsHelper.hpp +++ b/tests/unittests/TestsHelper.hpp @@ -52,7 +52,7 @@ void updateExpectedFile(const TestData& data, const std::string& actual); * @param test test function, taking a TestData&& with the paths of the input and its expected result * @param params optionally specify the expected extension. Defaults to "expected" */ -void iterTestFiles(const std::string& folder, std::function&& test, IterTestFilesParam&& params = {}); +void iterTestFiles(const std::string& folder, std::function&& test, IterTestFilesParam&& params = {}); /** * @brief Given an input folder, returns the resource path relatives to the project root