diff options
Diffstat (limited to 'unit_tests/legacy_tests.cpp')
| -rw-r--r-- | unit_tests/legacy_tests.cpp | 100 |
1 files changed, 34 insertions, 66 deletions
diff --git a/unit_tests/legacy_tests.cpp b/unit_tests/legacy_tests.cpp index 2d88190..cb91c93 100644 --- a/unit_tests/legacy_tests.cpp +++ b/unit_tests/legacy_tests.cpp | |||
| @@ -5,75 +5,43 @@ | |||
| 5 | #if RUN_LEGACY_TESTS | 5 | #if RUN_LEGACY_TESTS |
| 6 | 6 | ||
| 7 | // ################################################################################################# | 7 | // ################################################################################################# |
| 8 | // ################################################################################################# | ||
| 8 | 9 | ||
| 9 | class LegacyTestRunner : public FileRunner | 10 | TEST_CASE("legacy scripted tests") |
| 10 | { | 11 | { |
| 11 | public: | 12 | auto const& _testParam = GENERATE( |
| 12 | LegacyTestRunner() | 13 | FileRunnerParam{ "appendud", TestType::AssertNoLuaError } // 0 |
| 13 | { | 14 | , FileRunnerParam{ "atexit", TestType::AssertNoLuaError } // 1 |
| 14 | [[maybe_unused]] std::filesystem::path const _current{ std::filesystem::current_path() }; | 15 | , FileRunnerParam{ "atomic", TestType::AssertNoLuaError } // 2 |
| 15 | std::filesystem::path _path{ R"(.\lanes\tests\)" }; | 16 | , FileRunnerParam{ "basic", TestType::AssertNoLuaError } // 3 |
| 16 | root = std::filesystem::canonical(_path).generic_string(); | 17 | , FileRunnerParam{ "cancel", TestType::AssertNoLuaError } // 4 |
| 17 | // I need to append that path to the list of locations where modules can be required | 18 | , FileRunnerParam{ "cyclic", TestType::AssertNoLuaError } // 5 |
| 18 | // so that the legacy scripts can require"assert" and find assert.lua | 19 | , FileRunnerParam{ "deadlock", TestType::AssertNoLuaError } // 6 |
| 19 | std::string _script{"package.path = package.path.."}; | 20 | , FileRunnerParam{ "errhangtest", TestType::AssertNoLuaError } // 7 |
| 20 | _script += "';"; | 21 | , FileRunnerParam{ "error", TestType::AssertNoLuaError } // 8 |
| 21 | _script += root; | 22 | , FileRunnerParam{ "fibonacci", TestType::AssertNoLuaError } // 9 |
| 22 | _script += "/?.lua'"; | 23 | , FileRunnerParam{ "fifo", TestType::AssertNoLuaError } // 10 |
| 23 | std::ignore = L.doString(_script.c_str()); | 24 | , FileRunnerParam{ "finalizer", TestType::AssertNoLuaError } // 11 |
| 24 | } | 25 | , FileRunnerParam{ "func_is_string", TestType::AssertNoLuaError } // 12 |
| 25 | }; | 26 | , FileRunnerParam{ "irayo_closure", TestType::AssertNoLuaError } // 13 |
| 27 | , FileRunnerParam{ "irayo_recursive", TestType::AssertNoLuaError } // 14 | ||
| 28 | , FileRunnerParam{ "keeper", TestType::AssertNoLuaError } // 15 | ||
| 29 | //, FileRunnerParam{ "linda_perf", TestType::AssertNoLuaError } | ||
| 30 | , FileRunnerParam{ LUA54_ONLY("manual_register"), TestType::AssertNoLuaError } // 16: uses lfs module, currently not available for non-5.4 flavors | ||
| 31 | , FileRunnerParam{ "nameof", TestType::AssertNoLuaError } // 17 | ||
| 32 | , FileRunnerParam{ "objects", TestType::AssertNoLuaError } // 18 | ||
| 33 | , FileRunnerParam{ "package", TestType::AssertNoLuaError } // 19 | ||
| 34 | , FileRunnerParam{ "pingpong", TestType::AssertNoLuaError } // 20 | ||
| 35 | , FileRunnerParam{ "recursive", TestType::AssertNoLuaError } // 21 | ||
| 36 | , FileRunnerParam{ "require", TestType::AssertNoLuaError } // 22 | ||
| 37 | , FileRunnerParam{ "rupval", TestType::AssertNoLuaError } // 23 | ||
| 38 | , FileRunnerParam{ "timer", TestType::AssertNoLuaError } // 24 | ||
| 39 | , FileRunnerParam{ LUA54_ONLY("tobeclosed"), TestType::AssertNoLuaError } // 25 | ||
| 40 | , FileRunnerParam{ "track_lanes", TestType::AssertNoLuaError } // 26 | ||
| 41 | ); | ||
| 26 | 42 | ||
| 27 | TEST_P(LegacyTestRunner, LegacyTest) | 43 | FileRunner _runner(R"(.\lanes\tests\)"); |
| 28 | { | 44 | _runner.performTest(_testParam); |
| 29 | FileRunnerParam const& _param = GetParam(); | ||
| 30 | switch (_param.test) { | ||
| 31 | case TestType::AssertNoLuaError: | ||
| 32 | ASSERT_EQ(L.doFile(root, _param.script), LuaError::OK) << L; | ||
| 33 | break; | ||
| 34 | case TestType::AssertNoThrow: | ||
| 35 | ASSERT_NO_THROW((std::ignore = L.doFile(root, _param.script), L.close())) << L; | ||
| 36 | break; | ||
| 37 | case TestType::AssertThrows: | ||
| 38 | ASSERT_THROW((std::ignore = L.doFile(root, _param.script), L.close()), std::logic_error) << L; | ||
| 39 | break; | ||
| 40 | } | ||
| 41 | } | 45 | } |
| 42 | 46 | ||
| 43 | INSTANTIATE_TEST_CASE_P( | ||
| 44 | LegacyTests, | ||
| 45 | LegacyTestRunner, | ||
| 46 | ::testing::Values( | ||
| 47 | "appendud" // 0 | ||
| 48 | , "atexit" // 1 | ||
| 49 | , "atomic" // 2 | ||
| 50 | , "basic" // 3 | ||
| 51 | , "cancel" // 4 | ||
| 52 | , "cyclic" // 5 | ||
| 53 | , "deadlock" // 6 | ||
| 54 | , "errhangtest" // 7 | ||
| 55 | , "error" // 8 | ||
| 56 | , "fibonacci" // 9 | ||
| 57 | , "fifo" // 10 | ||
| 58 | , "finalizer" // 11 | ||
| 59 | , "func_is_string" // 12 | ||
| 60 | , "irayo_closure" // 13 | ||
| 61 | , "irayo_recursive" // 14 | ||
| 62 | , "keeper" // 15 | ||
| 63 | //, "linda_perf" | ||
| 64 | , LUA54_ONLY("manual_register") // 16: uses lfs module, currently not available for non-5.4 flavors | ||
| 65 | , "nameof" // 17 | ||
| 66 | , "objects" // 18 | ||
| 67 | , "package" // 19 | ||
| 68 | , "pingpong" // 20 | ||
| 69 | , "recursive" // 21 | ||
| 70 | , "require" // 22 | ||
| 71 | , "rupval" // 23 | ||
| 72 | , "timer" // 24 | ||
| 73 | , LUA54_ONLY("tobeclosed") // 25 | ||
| 74 | , "track_lanes" // 26 | ||
| 75 | ) | ||
| 76 | //, [](::testing::TestParamInfo<FileRunnerParam> const& info_) { return info_.param.script.empty() ? "N/A": std::string{ info_.param.script }; } | ||
| 77 | ); | ||
| 78 | |||
| 79 | #endif // RUN_LEGACY_TESTS \ No newline at end of file | 47 | #endif // RUN_LEGACY_TESTS \ No newline at end of file |
