gdext icon indicating copy to clipboard operation
gdext copied to clipboard

Add mocks for some builtin types for use when Godot isn't running

Open lilizoey opened this issue 9 months ago • 5 comments

In some cases it would be nice to be able to use at least some basic features of some builtin types even when Godot isn't running.

For instance, in doctests we cannot use GString or StringName because they only work when Godot is running. However these are "just" strings. It would be nice if we could make doctests and unit tests for types and functions that use these types anyway.

This should only be used in cases where the exact values and behavior of these types is not what's being tested beyond some basic features, such as equality.

We could override some of the ffi-functions with stubs/mocks when Godot isn't running. And maybe we should make it an explicit opt-in, like for instance we could have a global function pub unsafe fn enable_builtin_mocks() function to enable this. This should be unsafe imo because otherwise we may need to reimplement a lot of functionality for relevant types as we may rely on some behavior for safety.

lilizoey avatar May 05 '24 15:05 lilizoey