From 63d746f2048eea9a49d3b04ebf4957f8a35c883b Mon Sep 17 00:00:00 2001 From: Alexandre Plateau Date: Thu, 11 Dec 2025 13:21:05 +0100 Subject: [PATCH 1/9] fix(tests): windows insists on using backslash, so we'll remove them in the tests --- src/arkreactor/Error/Diagnostics.cpp | 4 +++- tests/unittests/TestsHelper.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/arkreactor/Error/Diagnostics.cpp b/src/arkreactor/Error/Diagnostics.cpp index e90918ee..c6cc92b9 100644 --- a/src/arkreactor/Error/Diagnostics.cpp +++ b/src/arkreactor/Error/Diagnostics.cpp @@ -193,9 +193,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/TestsHelper.cpp b/tests/unittests/TestsHelper.cpp index 648229df..c5db4d7f 100644 --- a/tests/unittests/TestsHelper.cpp +++ b/tests/unittests/TestsHelper.cpp @@ -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); From da8f6deab7fa8206fad8d8da89fc87eaf6647b38 Mon Sep 17 00:00:00 2001 From: Alexandre Plateau Date: Thu, 11 Dec 2025 14:36:09 +0100 Subject: [PATCH 2/9] angry --- angry | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 angry diff --git a/angry b/angry new file mode 100644 index 00000000..e69de29b From 240104efc2918cad16471527c94ac4a8d81be764 Mon Sep 17 00:00:00 2001 From: Alexandre Plateau Date: Thu, 11 Dec 2025 15:02:06 +0100 Subject: [PATCH 3/9] print files --- tests/unittests/Main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/unittests/Main.cpp b/tests/unittests/Main.cpp index e666fb87..5f74d7ad 100644 --- a/tests/unittests/Main.cpp +++ b/tests/unittests/Main.cpp @@ -1,3 +1,6 @@ +#include "TestsHelper.hpp" + + #include #include #include @@ -18,6 +21,10 @@ int main(const int argc, char** argv) if (argc >= 2 && std::string(argv[1]) != "update") filter = argv[1]; + const auto path = getResourcePath("DiagnosticsSuite/runtime"); + for (const auto& entry : std::filesystem::directory_iterator(path)) + std::cout << "# " << entry.path().generic_string() << std::endl; + bool failed = false; const auto start = std::chrono::high_resolution_clock::now(); From 7d764cab90286975c1f28fce67757b3e8c277fd1 Mon Sep 17 00:00:00 2001 From: Alexandre Plateau Date: Thu, 11 Dec 2025 17:24:26 +0100 Subject: [PATCH 4/9] show all --- tests/unittests/Main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/unittests/Main.cpp b/tests/unittests/Main.cpp index 5f74d7ad..900310fc 100644 --- a/tests/unittests/Main.cpp +++ b/tests/unittests/Main.cpp @@ -21,9 +21,14 @@ int main(const int argc, char** argv) if (argc >= 2 && std::string(argv[1]) != "update") filter = argv[1]; - const auto path = getResourcePath("DiagnosticsSuite/runtime"); - for (const auto& entry : std::filesystem::directory_iterator(path)) - std::cout << "# " << entry.path().generic_string() << std::endl; + auto show = [](const std::string& res) { + const auto path = getResourcePath(res); + for (const auto& entry : std::filesystem::directory_iterator(path)) + std::cout << "# " << entry.path().generic_string() << std::endl; + }; + show("DiagnosticsSuite/compileTime"); + show("DiagnosticsSuite/runtime"); + show("DiagnosticsSuite/typeChecking"); bool failed = false; const auto start = std::chrono::high_resolution_clock::now(); From 5fdc8f5b76b9edd4fe83fb899ec26316e6578880 Mon Sep 17 00:00:00 2001 From: Alexandre Plateau Date: Thu, 11 Dec 2025 17:34:11 +0100 Subject: [PATCH 5/9] wip --- tests/unittests/TestsHelper.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unittests/TestsHelper.cpp b/tests/unittests/TestsHelper.cpp index c5db4d7f..5f2beae0 100644 --- a/tests/unittests/TestsHelper.cpp +++ b/tests/unittests/TestsHelper.cpp @@ -58,6 +58,7 @@ void iterTestFiles(const std::string& folder, std::function&& .is_folder = is_directory(entry.path()) }; + std::cout << "test on '" << entry.path().generic_string() << std::endl; test(std::move(data)); } }; From 03be093ebb7c2b0eaa4ee7dd4e90287a533862db Mon Sep 17 00:00:00 2001 From: Alexandre Plateau Date: Thu, 11 Dec 2025 17:41:59 +0100 Subject: [PATCH 6/9] maybe const ref --- lib/std | 2 +- tests/unittests/Suites/CompilerSuite.cpp | 4 ++-- tests/unittests/Suites/DiagnosticsSuite.cpp | 6 +++--- tests/unittests/Suites/FormatterSuite.cpp | 2 +- tests/unittests/Suites/OptimizerSuite.cpp | 2 +- tests/unittests/Suites/ParserSuite.cpp | 4 ++-- tests/unittests/Suites/RosettaSuite.cpp | 2 +- tests/unittests/Suites/TypeCheckerSuite.cpp | 4 ++-- tests/unittests/Suites/ValidAstSuite.cpp | 2 +- tests/unittests/TestsHelper.cpp | 6 +++--- tests/unittests/TestsHelper.hpp | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/std b/lib/std index e39177ea..15ea7246 160000 --- a/lib/std +++ b/lib/std @@ -1 +1 @@ -Subproject commit e39177ea12df831288544faa0ebb2c2c6e77647a +Subproject commit 15ea724606100353f41210a65203f47062e6b2d3 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 5f2beae0..62e483c6 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,8 +58,8 @@ void iterTestFiles(const std::string& folder, std::function&& .is_folder = is_directory(entry.path()) }; - std::cout << "test on '" << entry.path().generic_string() << std::endl; - test(std::move(data)); + std::cout << "test on '" << entry.path().generic_string() << "'" << std::endl; + test(data); } }; } 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 From dff4aab61c97dd797642d8dec727453774ecd332 Mon Sep 17 00:00:00 2001 From: Alexandre Plateau Date: Thu, 11 Dec 2025 17:46:11 +0100 Subject: [PATCH 7/9] test --- file | 0 lib/std | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 file diff --git a/file b/file new file mode 100644 index 00000000..e69de29b diff --git a/lib/std b/lib/std index 15ea7246..e39177ea 160000 --- a/lib/std +++ b/lib/std @@ -1 +1 @@ -Subproject commit 15ea724606100353f41210a65203f47062e6b2d3 +Subproject commit e39177ea12df831288544faa0ebb2c2c6e77647a From d01d28d6baaae34357471c7d495b05a3aadc5eb2 Mon Sep 17 00:00:00 2001 From: Alexandre Plateau Date: Thu, 11 Dec 2025 20:05:59 +0100 Subject: [PATCH 8/9] what am i even doing --- tests/unittests/Main.cpp | 37 ++++++++++++++++++++++----------- tests/unittests/TestsHelper.cpp | 1 - 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/tests/unittests/Main.cpp b/tests/unittests/Main.cpp index 900310fc..72e07ea7 100644 --- a/tests/unittests/Main.cpp +++ b/tests/unittests/Main.cpp @@ -1,6 +1,3 @@ -#include "TestsHelper.hpp" - - #include #include #include @@ -10,6 +7,31 @@ #include #include +void tt(const std::string& folder, std::function&& run) +{ + boost::ut::test(folder) = [=] { + for (const std::string& name : { + "11111111111111111111111111111111111111111111111111111111", + "2222222222222222222222222222222222222222222222222222222222", + "2222222222222222222222222222222222222222222222222222222222", + "333333333333333333333333333333333333333333333333333333333333"}) + { + run(name); + } + }; +} + +boost::ut::suite<"Main"> main_suite = [] { + using namespace boost::ut; + + tt("main", [](const std::string& name) { + should("parametrized " + name) = [] { + expect(true); + expect(false); + }; + }); +}; + int main(const int argc, char** argv) { using namespace boost; @@ -21,15 +43,6 @@ int main(const int argc, char** argv) if (argc >= 2 && std::string(argv[1]) != "update") filter = argv[1]; - auto show = [](const std::string& res) { - const auto path = getResourcePath(res); - for (const auto& entry : std::filesystem::directory_iterator(path)) - std::cout << "# " << entry.path().generic_string() << std::endl; - }; - show("DiagnosticsSuite/compileTime"); - show("DiagnosticsSuite/runtime"); - show("DiagnosticsSuite/typeChecking"); - bool failed = false; const auto start = std::chrono::high_resolution_clock::now(); diff --git a/tests/unittests/TestsHelper.cpp b/tests/unittests/TestsHelper.cpp index 62e483c6..74e28a60 100644 --- a/tests/unittests/TestsHelper.cpp +++ b/tests/unittests/TestsHelper.cpp @@ -58,7 +58,6 @@ void iterTestFiles(const std::string& folder, std::function Date: Thu, 11 Dec 2025 21:12:11 +0100 Subject: [PATCH 9/9] please fix it --- src/arkreactor/Error/Diagnostics.cpp | 4 +++- tests/unittests/Main.cpp | 25 ------------------------- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/arkreactor/Error/Diagnostics.cpp b/src/arkreactor/Error/Diagnostics.cpp index c6cc92b9..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) diff --git a/tests/unittests/Main.cpp b/tests/unittests/Main.cpp index 72e07ea7..e666fb87 100644 --- a/tests/unittests/Main.cpp +++ b/tests/unittests/Main.cpp @@ -7,31 +7,6 @@ #include #include -void tt(const std::string& folder, std::function&& run) -{ - boost::ut::test(folder) = [=] { - for (const std::string& name : { - "11111111111111111111111111111111111111111111111111111111", - "2222222222222222222222222222222222222222222222222222222222", - "2222222222222222222222222222222222222222222222222222222222", - "333333333333333333333333333333333333333333333333333333333333"}) - { - run(name); - } - }; -} - -boost::ut::suite<"Main"> main_suite = [] { - using namespace boost::ut; - - tt("main", [](const std::string& name) { - should("parametrized " + name) = [] { - expect(true); - expect(false); - }; - }); -}; - int main(const int argc, char** argv) { using namespace boost;