Skip to content

Add unit testing infrastructure#45

Merged
dsrw merged 16 commits intomainfrom
unittests
Jan 5, 2026
Merged

Add unit testing infrastructure#45
dsrw merged 16 commits intomainfrom
unittests

Conversation

@dsrw
Copy link
Collaborator

@dsrw dsrw commented Dec 11, 2025

Summary

  • Add three types of tests: unit tests, VM script tests, and in-world tests
  • Add nimble test command that runs all test types with proper exit codes
  • Integrate tests into CI workflows (macOS and Windows get world tests, Linux skips due to server build)

Changes

Test Infrastructure

  • Unit tests (tests/unit/) - test ScriptCtx, serializers without Godot
  • VM tests (tests/vm/) - test vmlib API via command-line script execution
  • In-world tests (vmlib/worlds/tests/) - tests that run inside Enu

Command Line Flags

  • --level-dir <path> - load specific level directory
  • --enu-test - enable test mode (auto-exit when scripts finish)

New API

  • has_block_at(position) - check if block exists at world position
  • block_color_at(position) - get color of block at world position

Bug Fixes

  • Fixed voxel lookup to also check batched voxels during script execution

Known Bugs (documented with commented-out tests)

  • left/right/up/down in move mode all move in forward direction

Test plan

  • nimble unit_tests passes
  • nimble vm_tests passes
  • nimble world_tests passes
  • nimble test runs all three and reports correctly

dsrw added 3 commits December 11, 2025 12:47
- Unit tests using unittest2 for ScriptCtx (tests/unit/)
- VM script tests with custom runner (tests/vm/)
- Custom testing framework for VM (vmlib/enu/testing.nim)
- Nimble tasks: unit_tests, vm_tests, test
- CI integration in all dist workflows
- Unit tests for Color, Vector3, and Transform JSON serialization
- VM tests for state_machine loop and transitions
- VM tests for parse_sig macro helper
- Additional mock functions in runner for sleep, action_running
Tests round-trip JSON serialization for Build and Bot units,
including id, transform origin, and color preservation.
@dsrw dsrw force-pushed the unittests branch 5 times, most recently from 9b4c2e5 to 9f80580 Compare December 11, 2025 17:52
- Add --level-dir and --enu-test command line flags for test mode
- Add has_block_at() and block_color_at() API for block queries
- Add test world with bot movement and block placement tests
- Update nimble test task to run unit, VM, and world tests
- Add world tests to macOS and Windows CI workflows
- Auto-exit with proper exit code when all test scripts complete

Known bugs documented with commented-out tests:
- left/right/up/down in move mode all move in forward direction
- has_block_at doesn't find blocks at negative local coordinates
@dsrw dsrw force-pushed the unittests branch 7 times, most recently from 5897102 to a51b9eb Compare December 15, 2025 13:14
@dsrw dsrw force-pushed the unittests branch 3 times, most recently from cdeaa97 to 90f2560 Compare January 4, 2026 14:44
dsrw added 8 commits January 4, 2026 11:45
- Add build task to tasks.nim
- Update GitHub Actions to nim 2.2.6
- Replace nimble setup with atlas install && atlas rep
- Replace nimble task calls with nim task calls
- Update CLAUDE.md with new build commands
- world_tests now propagates exit codes so CI fails when tests fail
- Bot movement calculates finish position upfront instead of reading
  potentially stale model position (matches Build behavior)
…tests

- Comment out world_tests in Windows CI (no headless support until Godot 4)
- Move atlas install/rep to nim prereqs task, remove from CI scripts
- Disable mouse/keyboard input when TestMode is active
- Fix rotation getter to return -180..180 range instead of 0..360
The dist_package build uses -d:dist which sets lib_dir paths
relative to the packaged distribution layout. Headless tests run
from vendor/godot/bin/ so need a non-dist build.
dsrw added 3 commits January 4, 2026 16:27
nim.cfg is gitignored and generated by atlas rep. On cache hit,
dist_prereqs was skipped, leaving no nim.cfg and causing builds
to fail with "cannot open file: pkg/compiler/nimeval".
Godot incorrectly added control:true to macOS keybindings when
the project was opened. Reverted to control:false while keeping
the Godot 3.6 serialization updates (canceled property).
@dsrw dsrw merged commit 541f70f into main Jan 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant