ChaiScript/unittests/threading_config_test.cpp
leftibot 708dd4ba70 Fix #666: TSAN builds don't actually use threads
TSAN builds did not explicitly enable MULTITHREAD_SUPPORT_ENABLED, so they
relied on the CMake default. This adds -DMULTITHREAD_SUPPORT_ENABLED=ON to
both TSAN jobs and expands the CI matrix to cover threading on/off with
Debug/Release for Linux, macOS, and Windows MSVC. Also excludes async-dependent
.chai tests from non-threaded builds and adds a Threading_Config_Test to verify
the threading configuration is correct in both modes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 18:41:32 -06:00

27 lines
646 B
C++

#include <chaiscript/chaiscript.hpp>
int main() {
#ifndef CHAISCRIPT_NO_THREADS
// When threading is enabled, verify that async() is registered and functional
chaiscript::ChaiScript chai;
const auto result = chai.eval<int>(R"(
var f = async(fun() { return 42; });
f.get();
)");
if (result != 42) {
return EXIT_FAILURE;
}
#else
// When threading is disabled, verify that async() is NOT registered
chaiscript::ChaiScript chai;
try {
chai.eval("async(fun() { return 0; })");
return EXIT_FAILURE;
} catch (const std::exception &) {
// Expected: async should not exist
}
#endif
return EXIT_SUCCESS;
}