module
Lapis::Docs::H_TESTING_AND_BENCHMARKS::C_TESTING_ARCHITECTURE
Overview
Exhaustive Multi-Tier Test Suite Inventory & Phase Guide
Comprehensive architectural inventory and reference manual for Lapis's multi-tier test infrastructure, spanning 1,260+ asserted test blocks across 6 execution phases, headless compiler specs, in-editor tool runners, standalone binary hosts, 84 modular runtime suites, and quantitative zero-leak verification.
Executive Summary & Key Topics
| Topic | Method / Anchor | Description |
|---|---|---|
| Global Test Infrastructure Metrics | .topic_00_inventory_metrics |
High-level summary of total asserted tests, modular suites, spec files, and verification phases. |
| The Six-Phase Verification Pipeline | .topic_01_phases_architecture |
Detailed overview of the 6 execution phases from pre-flight checks to multi-addon smoke testing. |
| Crystal Specifications Breakdown | .topic_02_crystal_specifications |
Overview of the 70 engine unit specs, 19 CLI toolchain specs, and radare2 crash forensics specs. |
| Headless In-Editor Tool Tests | .topic_03_in_editor_tool_tests |
Executing @tool scripts, live reload, and clean shutdown verification in headless Godot Editor. |
| Standalone Binary Host Runners | .topic_04_standalone_host_runners |
Validating the pure LibGodot host paradigm with regular and portable embedded GDPC executables. |
| Runtime Test Suites Comprehensive Inventory | .topic_05_runtime_test_suites_inventory |
Exhaustive directory of all 84 modular runtime suites in spec/suites/ across 14 engine subsystems. |
| Quantitative Zero Memory Leak Verification | .topic_06_quantitative_zero_leak_verification |
Mathematical leak verification using Godot Performance monitors and Boehm GC. |
| Developer Test Commands Reference | .topic_07_developer_commands_and_cli |
Reference guide for invoking tests via Make and the Lapis CLI. |
Related Guides & Source References
- Test Harness & Runner:
src/libgodot/testing.cr - CLI Test Command:
tools/lapis/src/commands/test.cr - Root Host Entry & Registry:
src/main.cr - Runtime Test Suites:
spec/suites/ - Unit & Architectural Specs:
spec/
Defined in:
libgodot/docs/h_testing_and_benchmarks/c_testing_architecture.crClass Method Summary
-
.topic_00_inventory_metrics : Nil
Global Test Infrastructure Metrics: High-level summary of total asserted tests, modular suites, spec files, and verification phases.
-
.topic_01_phases_architecture : Nil
The Six-Phase Verification Pipeline: Detailed overview of the 6 execution phases from pre-flight checks to multi-addon smoke testing.
-
.topic_02_crystal_specifications : Nil
Crystal Specifications Breakdown: Overview of the 70 engine unit specs, 19 CLI toolchain specs, and radare2 crash forensics specs.
-
.topic_03_in_editor_tool_tests : Nil
Headless In-Editor Tool Tests: Executing @tool scripts, live reload, and clean shutdown verification in headless Godot Editor.
-
.topic_04_standalone_host_runners : Nil
Standalone Binary Host Runners: Validating the pure LibGodot host paradigm with regular and portable embedded GDPC executables.
-
.topic_05_runtime_test_suites_inventory : Nil
Runtime Test Suites Comprehensive Inventory: Exhaustive directory of all 84 modular runtime suites in spec/suites/ across 14 engine subsystems.
-
.topic_06_quantitative_zero_leak_verification : Nil
Quantitative Zero Memory Leak Verification: Mathematical leak verification using Godot Performance monitors and Boehm GC.
-
.topic_07_developer_commands_and_cli : Nil
Developer Test Commands Reference: Reference guide for invoking tests via Make and the Lapis CLI.
Class Method Detail
Global Test Infrastructure Metrics: High-level summary of total asserted tests, modular suites, spec files, and verification phases.
Key Topics & Information
- Total Asserted Test Blocks: 1,260+ tests
- Engine & Core Bindings Specs: 70 files (498 it-blocks)
- Toolchain & CLI Specs: 19 files (217 it-blocks)
- Modular In-Engine Test Suites: 84 suites across 51 categories (536 test-blocks)
- External Ecosystem Specs: 3 files (9 it-blocks)
- In-Editor Tool Testers: ToolTester2D and ToolTester3D
- Standalone Host Runners: Regular (tests.exe) and Portable Embedded GDPC (tests_portable.exe)
- Verification Execution Phases: 6 distinct tiers (0 through 6)
The Six-Phase Verification Pipeline: Detailed overview of the 6 execution phases from pre-flight checks to multi-addon smoke testing.
Lapis organizes all testing into a strict 6-phase pipeline ensuring that syntax, binding generation, memory safety, editor tooling, standalone binary embedding, and real-time physics simulation are verified:
| Phase | Name & Scope | Execution Command | Verification Criteria |
|---|---|---|---|
| Phase 0 | Pre-Flight & Prerequisites | crystal run tools/update_skill_tocs.cr -- --checklapis deps && lapis sync |
Toolchain discovery, TOC line-number parity, runtime DLL synchronization |
| Phase 1 | Crystal Unit Specifications | crystal spec spec tools/lapis/spec |
Language-level bindings, AST macros, CLI argument parsing, radare2 crash forensics |
| Phase 2 | Headless In-Editor @tool Tests | godot.exe --headless --editor --path . --quit-after 10000 |
In-editor scene tree manipulation, @tool buttons, live reload, clean shutdown (0 string leaks) |
| Phase 3 | Standalone Binary Host Runners | tests.exe --headless --quit-after 600 -- --autorun |
Embedded LibGodot host paradigm; standalone executable with regular and embedded GDPC PCK |
| Phase 4 | In-Project Runtime Test Runner | godot.exe --headless --path . --quit-after 600 -- --autorun |
84 modular test suites executed in main_test_runner.tscn with quantitative zero-leak verification |
| Phase 5 | Benchmarks & Stress Suites | make benchmarks-runmake perf_run |
Crystal vs GDScript 1-to-1 shootouts and 10,000+ entity stress benchmarking |
| Phase 6 | Addon Isolation & Consumer Smoke | powershell -File scripts/verify_editor.ps1 -Path template |
ClassDB multi-addon conflict isolation and template/example project smoke launches |
Crystal Specifications Breakdown: Overview of the 70 engine unit specs, 19 CLI toolchain specs, and radare2 crash forensics specs.
Phase 1 executes headless Crystal specs validating binding mechanics, type marshaling, and CLI tools:
Phase 1a: Engine & Core Bindings Specs (spec/ - 70 files, 498 tests)
core_spec.cr: Core Variant type conversions, StringName allocations, ObjectDB class lookups.math_spec.cr: Vector2, Vector3, Vector4, Transform2D, Transform3D, Basis, Quaternion, Color math.features_spec.cr: DSL syntax: node, @[Export], custom getters/setters, default values, signals.safety_spec.cr: Dead pointer protection, #check_alive!, DisposedObjectError enforcement.safety_and_bindings_spec.cr: Boehm GC lifetime retention, dynamic scaling (220+ properties), 10+ signal args.scene_pipeline_spec.cr: Typed instantiation via > operator, fluent .configure chaining.signal_operators_spec.cr: First-class signal operators (+=, -=, >>, >, <<).concurrency_spec.cr: Cooperative fibers, Fiber.yield, non-blocking channels, mutex contention.thread_safety_spec.cr: ThreadAffinityError when mutating SceneTree from background OS threads.match_spec.cr: Polymorphic pattern matching over Variant instances and downcasting.
Phase 1b: Lapis Toolchain & CLI Specs (tools/lapis/spec/ - 19 files, 217 tests)
cli_spec.cr&commands_spec.cr: Argument parsing, subcommand dispatches, flag normalization.standalone_spec.cr: Standalone game compilation, CRT linking, runtime DLL synchronization.tui_spec.cr&tui_views_spec.cr: Double-buffered ANSI terminal user interface and split views.analyze_spec.cr: Binary auditing with radare2, ASLR/DEP hardening checks, symbol budgeting.export_templates_spec.cr: Automated Godot export template downloading and checksum verification.
Phase 1d: Debugger & Crash Forensics Specs (17 files)
crash_handler_spec.cr: Windows SEH / Unix SIGSEGV interception and crash dump writing.plugin_forensics_spec.cr: Automated register extraction (RCX/RDI) and ObjectDB dead-pointer detection.decompiler_spec.cr: Disassembly into assembly (pdf) and pseudo-C (pdc) via radare2.
it "detects freed nodes and raises DisposedObjectError defensively" do
node = Godot.create(Godot::Node2D)
node_id = node.instance_id
node.alive?.should be_true
node.destroy
node.alive?.should be_false
node.destroyed?.should be_true
expect_raises(Godot::DisposedObjectError) do
node.set_position(Godot::Vector2.new(10.0_f32, 20.0_f32))
end
end
Headless In-Editor Tool Tests: Executing @tool scripts, live reload, and clean shutdown verification in headless Godot Editor.
Phase 2 boots the genuine Godot Editor in headless mode with CRYSTAL_TOOL_TEST=1 and GODOT_RUN_TOOL_TESTS=1.
Key Components:
- ToolTester2D (
src/main.cr): Active@toolclass derived fromGodot::Node2D. Auto-executesRegistry.run_category("2D", self), verifying 2D transform calculations, CanvasItem rendering, and in-editor tool buttons (ExportToolButton). Outputs.tool_tests_passedandjunit_tool_2d.xml. - ToolTester3D (
src/main.cr): Active@toolclass derived fromGodot::Node3D. Auto-executesRegistry.run_category("3D", self), verifying 3D transforms, MeshInstance3D generation, DirectionalLight3D, and Camera3D projections. Outputsjunit_tool_3d.xml. - Editor Live Reload & Shadow DLL Loading (
spec/editor_reload_spec.cr): Tests the Windows shadow DLL loading cycle where modified game libraries are recompiled and hot-reloaded viacrystal_bridge.cppwhile the editor remains open. - Clean Shutdown Protocol (
scripts/verify_editor.ps1): Verifies thatResourceFormatLoaderCrystalhandles.crfiles asScriptresources with zero loader errors, and ensures upon exit that exactly ZEROERROR: BUG: Unreferenced static string to 0errors occur.
@[Tool]
node ToolTester2D < Godot::Node2D do
@[ExportToolButton("▶ Run 2D Tool Tests")]
property run_tests_button = ->run_tool_tests
def _ready
if Godot.editor_hint?
Godot.print("[ToolTester2D] Editor detected. Auto-executing in-editor tests...")
run_tool_tests
end
end
def run_tool_tests
results = Registry.run_category("2D", self)
# ... asserts results and writes .tool_tests_passed ...
end
end
Standalone Binary Host Runners: Validating the pure LibGodot host paradigm with regular and portable embedded GDPC executables.
Phase 3 validates the Standalone Host Execution Paradigm (Mode B), where Crystal boots first and embeds
the Godot engine as a dynamic shared library (libgodot.dll / libgodot.so).
Phase 3a: Regular Standalone Runner (bin/tests.exe)
- Executed via:
tests.exe --headless --rendering-driver opengl3 --audio-driver Dummy --quit-after 600 -- --autorun - Accompanied by external
tests.pckon disk. - Proves that Crystal's CRT and Boehm GC cleanly bootstrap the Godot C-API and main loop.
Phase 3b: Portable Standalone Runner in Isolated Sandbox (bin/tests_portable.exe)
- The complete virtual filesystem
res://is appended directly to the executable using Godot's GDPC format. - Tested in an isolated sandbox directory (
scratch/test_portable_sandbox/) containing NO.pckfile on disk. - Proves that portable standalone distributions unpack and execute completely self-contained without external assets.
Runtime Test Suites Comprehensive Inventory: Exhaustive directory of all 84 modular runtime suites in spec/suites/ across 14 engine subsystems.
Phase 4 executes scenes/main_test_runner.tscn, running all 84 modular suites (536+ test cases):
| Subsystem | Suites Count | Representative Suites | Scope & Invariants Tested |
|---|---|---|---|
| 1. Core & Built-ins | 7 suites | test_core_builtins.cr, test_2d_nodes.cr, test_3d_nodes.cr, test_control_nodes.cr, test_scale_stress.cr |
Vector2/3/4 math, transforms, Node2D/3D hierarchies, GUI containers, 5,000-node stress allocation. |
| 2. Graphics & Shaders | 5 suites | test_meshes_materials.cr, test_shaders_compilation.cr, test_geometry_surfacetool.cr |
Procedural SurfaceTool meshes, custom GLSL shader compilation, materials, Viewport textures. |
| 3. Physics & Collision | 6 suites | test_physics_multiframe_pit_settling.cr, test_physics_cube_stack_stability.cr, test_physics_raycast_builder.cr |
200-ball falling pit settling over 60 frames, 10-tier cube stack stability, fluent raycasting DSL. |
| 4. Audio & Tweens | 4 suites | test_audio_animation.cr, test_tween_dsl.cr, test_tweens_animation.cr |
16-pillar fluent tween stepping DSL, AudioServer bus routing, AnimationPlayer keyframing. |
| 5. Resources & Scenes | 5 suites | test_resources_utilities.cr, test_scenes_persistence.cr, test_resource_card_lifecycle.cr |
PackedScene serialization, custom Resource cards, ConfigFile encryption, reference counting. |
| 6. Memory & Safety | 5 suites | test_dead_pointer_safety.cr, test_lifecycle_destruction.cr, test_destruction_and_threads_multiframe.cr |
Multi-wrapper aliasing dead-pointer traps, queue_free vs destroy, 50-node multi-frame cascade. |
| 7. Concurrency & Fibers | 6 suites | test_concurrency.cr, test_concurrency_actor_channel.cr, test_thread_safety_enforcement.cr |
Cooperative fibers yielding across frames, Actor Pattern worker channels, thread affinity gates. |
| 8. Signals & Events | 5 suites | test_callable_signals_advanced.cr, test_signal_safety_multiframe.cr, test_signal_bus_advanced.cr |
Custom Callables, dead listener auto-pruning, global decoupled signal buses, priority propagation. |
| 9. ClassDB & Reflection | 6 suites | test_classdb_coverage.cr, test_macros_dsl.cr, test_dsl_edge_cases_and_leaks.cr |
ClassDB method table reflection, AST macro expansion, onready? lazy binding, dynamic properties. |
| 10. GDScript Interop | 4 suites | test_gdscript_channel_signal_interop.cr, test_gdscript_inheritance_polymorphism.cr |
GDScript signals unboxing to Crystal channels, GDScript classes inheriting from Crystal nodes. |
| 11. Toolchain & Addons | 10 suites | test_multi_addon_isolation.cr, test_editor_plugins_comprehensive.cr, test_script_first_class.cr |
5-addon ClassDB conflict isolation, EditorPlugin dock lifecycle, CrystalScript engine resource. |
| 12. Deep Bindings & Servers | 5 suites | test_packed_arrays_containers.cr, test_variant_math_deep.cr, test_servers_low_level_rid.cr |
Contiguous PackedArrays, 38-variant math operators, low-level RenderingServer RID handles. |
| 13. Procedural & Navigation | 3 suites | test_noise_procedural_generation.cr, test_astar_navigation.cr, test_image_pixel_buffer.cr |
FastNoiseLite fractal octaves, AStar2D/3D weighted pathfinding, raw RGBA8 image pixel buffers. |
| 14. Gameplay & Architecture | 13 suites | test_fsm_dsl.cr, test_hsm_pushdown_automata.cr, test_node_pool_stress.cr, test_combat_scenario.cr |
Hierarchical State Machines, zero-allocation 1,000-bullet pooling, real-time combat simulation. |
Quantitative Zero Memory Leak Verification: Mathematical leak verification using Godot Performance monitors and Boehm GC.
Memory leaks are fatal in native game development. Lapis enforces quantitative zero-leak verification
via Lapis::Test.assert_no_leak, leveraging Godot's internal engine performance monitors:
def assert_no_leak(max_delta_objects : Int32 = 0, name : String = "Operation", &block)
5.times { Fiber.yield }
GC.collect
perf = Godot.performance
initial_objects = perf.get_monitor(Godot::Performance::Monitor::ObjectCount).to_i64
initial_nodes = perf.get_monitor(Godot::Performance::Monitor::ObjectNodeCount).to_i64
yield
5.times { Fiber.yield }
GC.collect
final_objects = perf.get_monitor(Godot::Performance::Monitor::ObjectCount).to_i64
final_nodes = perf.get_monitor(Godot::Performance::Monitor::ObjectNodeCount).to_i64
delta_objects = (final_objects - initial_objects).abs
delta_nodes = (final_nodes - initial_nodes).abs
assert_lte delta_objects, max_delta_objects, "#{name}: Object leak detected!"
assert_eq delta_nodes, 0, "#{name}: Node leak detected!"
end
Developer Test Commands Reference: Reference guide for invoking tests via Make and the Lapis CLI.
| Workflow | Command | Description |
|---|---|---|
| Full Test Suite | make test or bin/lapis test |
Executes Specs, Tool Tests, Standalone, and Runtime Project. |
| Interactive TUI | bin/lapis test --tui (or make test TUI=1) |
Launches double-buffered ANSI dashboard with live progress metrics. |
| Crystal Specs Only | make spec |
Runs Phase 1a and Phase 1b unit specifications. |
| Tool Tests Only | crystal spec spec/editor_driver_spec.cr |
Executes headless in-editor tool tests via EditorDriver. |
| Filter by Category | bin/lapis test -c "Concurrency" |
Runs only runtime test suites in the specified category. |
| Filter by Pattern | bin/lapis test -f "Signal" |
Runs only test cases whose names match the given regex pattern. |