behaviour-tree-test/tests/SCsub
Thaddeus Crews 5482b9e89e
Tests: Convert test headers to compilation files
• Excludes module tests, as they'd be a more involved process
2026-02-19 07:36:26 -06:00

37 lines
1.3 KiB
Python

#!/usr/bin/env python
from misc.utility.scons_hints import *
import glob
import test_builders
Import("env")
env_tests = env.Clone()
# We must disable the THREAD_LOCAL entirely in doctest to prevent crashes on debugging
# Since we link with /MT thread_local is always expired when the header is used
# So the debugger crashes the engine and it causes weird errors
# Explained in https://github.com/onqtam/doctest/issues/401
if env_tests["platform"] == "windows":
env_tests.Append(CPPDEFINES=[("DOCTEST_THREAD_LOCAL", "")])
if env["disable_exceptions"]:
env_tests.Append(CPPDEFINES=["DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS"])
# Sources with tests must be explicitly linked first.
force_link_sources = glob.glob("*/**/*.cpp", recursive=True)
force_link_header = env.CommandNoCache(
"force_link.gen.h", env_tests.Value(force_link_sources), env.Run(test_builders.force_link_builder)
)
env.Depends(force_link_header, "test_builders.py")
tests_obj = []
if env["scu_build"]:
# HACK: SCU setup doesn't support recursive/dynamic setup, so we must manually pass the files.
env_tests.add_source_files(tests_obj, glob.glob(".scu/*.cpp"))
else:
env_tests.add_source_files(tests_obj, glob.glob("*.cpp") + force_link_sources)
lib = env_tests.add_library("tests", tests_obj)
env.Prepend(LIBS=[lib])