Comprehensive test framework for systematically testing individual C++ types with the SpacetimeDB C++ library. Features parallel builds, real-time progress monitoring, and automated constraint validation testing.
# Run all tests with default parallelism (16 builds)
./run_type_isolation_test.sh
# Run with custom parallelism
./run_type_isolation_test.sh 8
# Monitor progress in real-time (separate terminal)
watch -n 1 cat test_summary_live.txt- Parallel Execution: Configurable parallelism (default: 16 concurrent builds)
- Live Progress Monitoring: Real-time status table with build/publish progress
- Optimized Builds: Pre-builds library once, 2-3x faster than individual builds
- Smart Error Capture: Clean error messages (up to 250 characters) in status table
- Auto-discovery: Automatically tests all
.cppfiles intest_modules/ - State Recovery: Resumes from previous state if interrupted
- Primitives: U8-U256, I8-I256, F32/F64, Bool, String
- Special Types: Identity, Timestamp, ConnectionId
- Complex Types: Enums, structs, vectors, optionals
- Constraints: Unique constraints and indexes
Tests that intentionally fail to validate error detection:
error_autoinc_non_integer: Compile-time error for AutoIncrement on non-integerserror_invalid_index: Compile-time error for Index on non-filterable typeserror_multiple_pk: Runtime error for multiple primary keyserror_non_spacetimedb_type: Compile-time error for unsupported typeserror_circular_ref: Runtime error for circular type referenceserror_scheduled_id_pk: Runtime error for invalid scheduled tables
- Type combinations and interactions
- Reducer and table scenarios
- Specific debugging modules
test_summary_live.txt: Live status tabletest_log.txt: Detailed build/publish log with timestampstest_modules/build_*/: Individual build directorieslibrary_build/: Pre-built shared library
Module | Build | Publish | WASM Size | Error
--------------------------|-------|---------|-----------|------------------
debug_large_struct | ✅ | ✅ | 299KB |
error_multiple_pk | ✅ | ❌ | 306KB | Multiple primary keys
module01_basic_unsigned | 🔨 | ⏳ | - |
Status Indicators: ⏳ Pending, 🔨 Building, 📤 Publishing, ✅ Passed, ❌ Failed, ⏭️ Skipped
- Total time: ~1 minute for 57 modules
- Library pre-build: ~10 seconds
- Module builds: 5-13 seconds each (vs 20-30 without optimization)
- Current success rate: 89% (51/57 passing, 6 intentional failures)
- SpacetimeDB CLI and server
- Emscripten (emcc, emcmake)
- CMake 3.16+, C++20 compiler
- Bash 4.0+ with associative arrays
Standard workflow:
cd crates/bindings-cpp/tests/type-isolation-test
./run_type_isolation_test.shMonitor progress:
watch -n 1 cat test_summary_live.txtCheck detailed errors:
grep "error" test_log.txtServer issues:
curl -s http://127.0.0.1:3000/health # Check server
spacetime start # Start if neededBuild failures:
- Check error messages in live table (250 char limit)
- Review
test_log.txtfor full details - Build artifacts in
test_modules/build_<module>/
Stuck updates:
pkill -f update_table_from_log # Kill orphaned processes
./run_type_isolation_test.sh # Restart- Create
.cppfile intest_modules/following naming:test_<category>_<specific>.cpp - Include minimal code isolating the type being tested
- Run test suite to verify
Basic template:
#include <spacetimedb.h>
using namespace SpacetimeDB;
struct TestTable { /* fields */ };
SPACETIMEDB_STRUCT(TestTable, /* field list */)
SPACETIMEDB_TABLE(TestTable, test_table, Public)
SPACETIMEDB_INIT(init, ReducerContext ctx) {
LOG_INFO("Test module initialized");
return Ok();
}CI/CD example:
./run_type_isolation_test.sh
SUCCESS_RATE=$(grep "Success rate:" test_summary_live.txt | grep -o '[0-9]*%')
[[ "${SUCCESS_RATE}" == "89%" ]] || exit 1 # Expected rate with intentional failuresThe test suite validates the C++ bindings type system by testing individual types in isolation, ensuring reliable constraint validation and error detection.