diff options
Diffstat (limited to 'main/tests/test_main.cpp')
-rw-r--r-- | main/tests/test_main.cpp | 111 |
1 files changed, 39 insertions, 72 deletions
diff --git a/main/tests/test_main.cpp b/main/tests/test_main.cpp index 5ebdaf1741..91eff28f86 100644 --- a/main/tests/test_main.cpp +++ b/main/tests/test_main.cpp @@ -47,10 +47,14 @@ #include "test_render.h" #include "test_shader_lang.h" #include "test_string.h" +#include "test_validate_testing.h" + +#include "thirdparty/doctest/doctest.h" const char **tests_get_names() { static const char *test_names[] = { - "string", + "*", + "all", "math", "basis", "physics_2d", @@ -72,75 +76,38 @@ const char **tests_get_names() { return test_names; } -MainLoop *test_main(String p_test, const List<String> &p_args) { - if (p_test == "string") { - return TestString::test(); - } - - if (p_test == "math") { - return TestMath::test(); - } - - if (p_test == "basis") { - return TestBasis::test(); - } - - if (p_test == "physics_2d") { - return TestPhysics2D::test(); - } - - if (p_test == "physics_3d") { - return TestPhysics3D::test(); - } - - if (p_test == "render") { - return TestRender::test(); - } - - if (p_test == "oa_hash_map") { - return TestOAHashMap::test(); - } - - if (p_test == "class_db") { - return TestClassDB::test(); - } - -#ifndef _3D_DISABLED - if (p_test == "gui") { - return TestGUI::test(); - } -#endif - - if (p_test == "shaderlang") { - return TestShaderLang::test(); - } - - if (p_test == "gd_tokenizer") { - return TestGDScript::test(TestGDScript::TEST_TOKENIZER); - } - - if (p_test == "gd_parser") { - return TestGDScript::test(TestGDScript::TEST_PARSER); - } - - if (p_test == "gd_compiler") { - return TestGDScript::test(TestGDScript::TEST_COMPILER); - } - - if (p_test == "gd_bytecode") { - return TestGDScript::test(TestGDScript::TEST_BYTECODE); - } - - if (p_test == "ordered_hash_map") { - return TestOrderedHashMap::test(); - } - - if (p_test == "astar") { - return TestAStar::test(); - } - - print_line("Unknown test: " + p_test); - return nullptr; +int test_main(int argc, char *argv[]) { + // doctest runner for when legacy unit tests are no found + doctest::Context test_context; + List<String> valid_arguments; + + // clean arguments of --test from the args + int argument_count = 0; + for (int x = 0; x < argc; x++) { + if (strncmp(argv[x], "--test", 6) != 0) { + valid_arguments.push_back(String(argv[x])); + argument_count++; + } + } + + // convert godot command line arguments back to standard arguments. + char **args = new char *[valid_arguments.size()]; + for (int x = 0; x < valid_arguments.size(); x++) { + // operation to convert godot string to non wchar string + const char *str = valid_arguments[x].utf8().ptr(); + // allocate the string copy + args[x] = new char[strlen(str) + 1]; + // copy this into memory + std::memcpy(args[x], str, strlen(str) + 1); + } + + test_context.applyCommandLine(valid_arguments.size(), args); + + test_context.setOption("order-by", "name"); + test_context.setOption("abort-after", 5); + test_context.setOption("no-breaks", true); + delete[] args; + return test_context.run(); } #else @@ -153,8 +120,8 @@ const char **tests_get_names() { return test_names; } -MainLoop *test_main(String p_test, const List<String> &p_args) { - return nullptr; +int test_main(int argc, char *argv[]) { + return 0; } #endif |