aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-12-20 17:21:32 +0100
committerBenoit Germain <benoit.germain@ubisoft.com>2024-12-20 17:21:32 +0100
commit59ae58fd31d63c261372bd5a36765328583bc1b6 (patch)
tree44eef790bd9948d864db350746c4017a47d93e53
parent30579fc3e7c73bbad5d376c43f226b2c16c7cebb (diff)
downloadlanes-59ae58fd31d63c261372bd5a36765328583bc1b6.tar.gz
lanes-59ae58fd31d63c261372bd5a36765328583bc1b6.tar.bz2
lanes-59ae58fd31d63c261372bd5a36765328583bc1b6.zip
Make VS Test Explorer happy by absorbing the text output of legacy tests
-rw-r--r--tests/error.lua18
-rw-r--r--unit_tests/Catch2.runsettings3
-rw-r--r--unit_tests/shared.cpp12
3 files changed, 26 insertions, 7 deletions
diff --git a/tests/error.lua b/tests/error.lua
index a1ba1ce..243dd57 100644
--- a/tests/error.lua
+++ b/tests/error.lua
@@ -1,9 +1,19 @@
1-- 1--
2-- Error reporting 2-- Error reporting
3-- 3--
4local function PRINT(...)
5 local str=""
6 for i=1,select('#',...) do
7 str= str..tostring(select(i,...)).."\t"
8 end
9 if io then
10 io.stderr:write(str.."\n")
11 end
12end
13
4local which_tests, remaining_tests = {}, {} 14local which_tests, remaining_tests = {}, {}
5for k,v in ipairs{...} do 15for k,v in ipairs{...} do
6 print("got arg:", type(v), tostring(v)) 16 PRINT("got arg:", type(v), tostring(v))
7 which_tests[v] = true 17 which_tests[v] = true
8 remaining_tests[v] = true 18 remaining_tests[v] = true
9end 19end
@@ -27,7 +37,7 @@ local WR = function(...)
27 if type(v) == "function" then 37 if type(v) == "function" then
28 local infos = debug.getinfo(v) 38 local infos = debug.getinfo(v)
29 --[[for k,v in pairs(infos) do 39 --[[for k,v in pairs(infos) do
30 print(k,v) 40 PRINT(k,v)
31 end]] 41 end]]
32 v = infos.source..":"..infos.linedefined 42 v = infos.source..":"..infos.linedefined
33 end 43 end
@@ -115,7 +125,7 @@ local configure_tests = function()
115 (lane_error and tostring(lane_error) or "no error") .. " in lane", 125 (lane_error and tostring(lane_error) or "no error") .. " in lane",
116 (finalizer and "with" or "without").. " finalizer" .. ((finalizer and finalizer_error) and " raising " .. tostring(finalizer_error) or "") 126 (finalizer and "with" or "without").. " finalizer" .. ((finalizer and finalizer_error) and " raising " .. tostring(finalizer_error) or "")
117 }, ", ") 127 }, ", ")
118 print(test_header) 128 PRINT(test_header)
119 test_settings[test_header] = { level, lane_error, finalizer, finalizer_error } 129 test_settings[test_header] = { level, lane_error, finalizer, finalizer_error }
120 end 130 end
121 -- can't store nil in tables, use null instead 131 -- can't store nil in tables, use null instead
@@ -240,4 +250,4 @@ end
240local unknown_test, val = next(remaining_tests) 250local unknown_test, val = next(remaining_tests)
241assert(not unknown_test, tostring(unknown_test) .. " test is unknown") 251assert(not unknown_test, tostring(unknown_test) .. " test is unknown")
242 252
243print "\nTHE END" 253PRINT "\nTHE END"
diff --git a/unit_tests/Catch2.runsettings b/unit_tests/Catch2.runsettings
index 9360bfb..c8e32ee 100644
--- a/unit_tests/Catch2.runsettings
+++ b/unit_tests/Catch2.runsettings
@@ -22,9 +22,6 @@
22 <!-- Combine: A single test executable is started to run multiple test cases. (Single: instance per test case) --> 22 <!-- Combine: A single test executable is started to run multiple test cases. (Single: instance per test case) -->
23 <ExecutionMode>Combine</ExecutionMode> 23 <ExecutionMode>Combine</ExecutionMode>
24 24
25 <!-- In Milliseconds -->
26 <TestCaseTimeout>10000</TestCaseTimeout>
27
28 <!-- Working directory --> 25 <!-- Working directory -->
29 <WorkingDirectoryRoot>Solution</WorkingDirectoryRoot> 26 <WorkingDirectoryRoot>Solution</WorkingDirectoryRoot>
30 <WorkingDirectory>Lanes</WorkingDirectory> 27 <WorkingDirectory>Lanes</WorkingDirectory>
diff --git a/unit_tests/shared.cpp b/unit_tests/shared.cpp
index d2b4ef7..c2b8bf0 100644
--- a/unit_tests/shared.cpp
+++ b/unit_tests/shared.cpp
@@ -389,6 +389,18 @@ TEST_CASE("LuaState.doString")
389FileRunner::FileRunner(std::string_view const& where_) 389FileRunner::FileRunner(std::string_view const& where_)
390: LuaState{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ true } } 390: LuaState{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ true } }
391{ 391{
392 // _G.print = _nullprint
393 // because the VS Test Explorer doesn't appreciate the text output of some scripts, so absorb them
394 if constexpr (1) {
395 auto const _nullprint = +[](lua_State* const L_) { return 0; };
396 luaG_pushglobaltable(L);
397 lua_pushcfunction(L, _nullprint);
398 luaG_setfield(L, StackIndex{ -2 }, std::string_view{ "print" });
399 lua_pop(L, 1);
400 stackCheck(0);
401 }
402 // TODO: do the same with io.stderr:write?
403
392 [[maybe_unused]] std::filesystem::path const _current{ std::filesystem::current_path() }; 404 [[maybe_unused]] std::filesystem::path const _current{ std::filesystem::current_path() };
393 std::filesystem::path _path{ where_ }; 405 std::filesystem::path _path{ where_ };
394 root = std::filesystem::canonical(_path).generic_string(); 406 root = std::filesystem::canonical(_path).generic_string();