Skip to content

Unit Test Framework #30743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@ if selected_platform in platform_list:
env.Append(BUILDERS = { 'GLES3_GLSL' : env.Builder(action=run_in_subprocess(gles_builders.build_gles3_headers), suffix='glsl.gen.h', src_suffix='.glsl')})
env.Append(BUILDERS = { 'GLES2_GLSL' : env.Builder(action=run_in_subprocess(gles_builders.build_gles2_headers), suffix='glsl.gen.h', src_suffix='.glsl')})

# enable test framework globally and inform it of configuration method
env.Append(CPPDEFINES=['DOCTEST_CONFIG_IMPLEMENT'])

scons_cache_path = os.environ.get("SCONS_CACHE")
if scons_cache_path != None:
CacheDir(scons_cache_path)
Expand Down
4 changes: 1 addition & 3 deletions main/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import main_builders
env.main_sources = []

env.add_source_files(env.main_sources, "*.cpp")
env.add_source_files(env.main_sources, "tests/*.cpp")

# order matters here. higher index controller database files write on top of lower index database files
controller_databases = ["#main/gamecontrollerdb.txt", "#main/gamecontrollerdb_205.txt", "#main/gamecontrollerdb_204.txt", "#main/godotcontrollerdb.txt"]
Expand All @@ -28,8 +29,5 @@ env.CommandNoCache("#main/splash_editor.gen.h", "#main/splash_editor.png", run_i
env.Depends("#main/app_icon.gen.h", "#main/app_icon.png")
env.CommandNoCache("#main/app_icon.gen.h", "#main/app_icon.png", run_in_subprocess(main_builders.make_app_icon))

if env["tools"]:
SConscript('tests/SCsub')

lib = env.add_library("main", env.main_sources)
env.Prepend(LIBS=[lib])
9 changes: 0 additions & 9 deletions main/tests/SCsub

This file was deleted.

17 changes: 12 additions & 5 deletions main/tests/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

#ifdef DEBUG_ENABLED

#include <thirdparty/doctest/doctest.h>

#include "test_astar.h"
#include "test_gdscript.h"
#include "test_gui.h"
Expand All @@ -48,7 +50,7 @@
const char **tests_get_names() {

static const char *test_names[] = {
"string",
"doctest",
"math",
"physics",
"physics_2d",
Expand All @@ -69,10 +71,15 @@ const char **tests_get_names() {
}

MainLoop *test_main(String p_test, const List<String> &p_args) {

if (p_test == "string") {

return TestString::test();
doctest::Context test_context;

if (p_test == "doctest") {
// tests should be ordered by name for humans
test_context.setOption("order-by", "name");
test_context.setOption("abort-after", 5);
test_context.setOption("no-breaks", true);
test_context.run(); // run tests
return NULL;
}

if (p_test == "math") {
Expand Down
Loading