Uses a dummy test run class for tests when the Godot runtime isn't running.
Adds some logging to clearly delineate the time when the tests are running in the engine
Filters out non-engine tests when running in the engine (previously tests that just inherit from XCTestCase were running twice)
Using the dummy run class makes the test suites appear to contain no tests when they are run outside the engine:
Test Suite 'AABBTests' started at 2024-11-01 12:30:53.297.
Test Suite 'AABBTests' passed at 2024-11-01 12:30:53.297.
Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.000) seconds
Later when they run in the engine, the tests will show up:
Test Suite 'AABBTests' started at 2024-11-01 12:30:56.593.
Test Case '-[SwiftGodotEngineTests.AABBTests testBasicGetters]' started.
Test Case '-[SwiftGodotEngineTests.AABBTests testBasicGetters]' passed (0.016 seconds).
Test Case '-[SwiftGodotEngineTests.AABBTests testBasicSetters]' started.
Test Case '-[SwiftGodotEngineTests.AABBTests testBasicSetters]' passed (0.013 seconds).
... etc
This is marginally less confusing as you can search for the name of a specific test like testBasicGetters and find it in just one place.
The logging I've added around the initialisation and shutdown of the engine itself makes it a little clearer what's going on:
Starting Godot Engine
=====================
LibGodot initialization
Godot Engine v4.3.1.rc.custom_build.7e451cc34 (2024-10-05 04:48:09 UTC) - https://godotengine.org
TextServer: Added interface "Dummy"
TextServer: Added interface "ICU / HarfBuzz / Graphite (Built-in)"
Using "default" pen tablet driver...
TextServer: Primary interface set to: "ICU / HarfBuzz / Graphite (Built-in)".
CameraServer: Registered camera Razer Kiyo Pro with ID 1 and position 0 at index 0
[1;31mERROR:[0;91m Could not load global script cache.
[0;90m at: get_global_class_list (core/config/project_settings.cpp:1231)[0m
CORE API HASH: 2488069049
EDITOR API HASH: 1114809042
Running Tests in Godot Engine
=============================
Test Suite 'All Godot Tests' started at 2024-11-01 12:30:56.593.
Test Suite 'AABBTests' started at 2024-11-01 12:30:56.593.
Test Case '-[SwiftGodotEngineTests.AABBTests testBasicGetters]' started.
...etc
Test Suite 'WrappedTests' passed at 2024-11-01 12:31:28.200.
Executed 1 test, with 0 failures (0 unexpected) in 0.055 (0.055) seconds
Test Suite 'All Godot Tests' passed at 2024-11-01 12:31:28.200.
Executed 258 tests, with 0 failures (0 unexpected) in 31.565 (31.607) seconds
Done Godot Engine Tests
=======================
258 tests run, 0 failures.
Shutting Down Engine
====================
Loaded system CA certificates
XR: Clearing primary interface
XR: Removed interface "Native mobile"
XR: Removed interface "OpenXR"
[1;33mWARNING:[0;93m 1 RID of type "CanvasItem" was leaked.
[0;90m at: _free_rids (servers/rendering/renderer_canvas_cull.cpp:2511)[0m
[1;33mWARNING:[0;93m ObjectDB instances leaked at exit (run with --verbose for details).
[0;90m at: cleanup (core/object/object.cpp:2291)[0m
Leaked instance: GridMap:26809992446 - Node name:
Leaked instance: GridMap:26843546881 - Node name:
Leaked instance: Node:64491619586 - Node name:
Leaked instance: Node:64458065155 - Node name:
Leaked instance: Node:64525174020 - Node name:
Leaked instance: Node:64541951237 - Node name:
Leaked instance: Node:64575505670 - Node name:
Leaked instance: GridMap:64659391751 - Node name:
Leaked instance: GridMap:64692946184 - Node name:
Leaked instance: GridMap:64726500617 - Node name:
Leaked instance: GridMap:64760055050 - Node name:
Leaked instance: Sprite2D:65984791819 - Node name:
Leaked instance: Node:66018346252 - Node name:
Leaked instance: Node:66035123469 - Node name:
Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not freed (with `free()` or `queue_free()`).
Orphan StringName: _enter_tree (static: 0, total: 14)
Orphan StringName: name (static: 0, total: 1)
Orphan StringName: _unhandled_input (static: 0, total: 14)
Orphan StringName: _ready (static: 0, total: 14)
Orphan StringName: _exit_tree (static: 0, total: 14)
Orphan StringName: RandomNumberGenerator (static: 1, total: 2)
Orphan StringName: proxy (static: 0, total: 1)
Orphan StringName: mySignal (static: 0, total: 1)
Orphan StringName: DuplicateClassTestNode (static: 0, total: 1)
Orphan StringName: UndoRedo (static: 1, total: 2)
Orphan StringName: Sprite2D (static: 1, total: 3)
Orphan StringName: age (static: 0, total: 1)
Orphan StringName: _input (static: 0, total: 14)
Orphan StringName: Image (static: 1, total: 2004)
Orphan StringName: AStar3D (static: 1, total: 104)
Orphan StringName: _shortcut_input (static: 0, total: 14)
Orphan StringName: _process (static: 0, total: 14)
Orphan StringName: Node (static: 1, total: 20)
Orphan StringName: _unhandled_key_input (static: 0, total: 14)
Orphan StringName: GridMap (static: 1, total: 10)
Orphan StringName: Object (static: 1, total: 463)
Orphan StringName: _get_configuration_warnings (static: 0, total: 14)
Orphan StringName: _draw (static: 0, total: 1)
Orphan StringName: _physics_process (static: 0, total: 14)
StringName: 24 unclaimed string names at exit.
Engine Shut Down Done
=====================
Test Case '-[SwiftGodotTestability.__GodotTestRunner testRunEverythingInGodot]' started.
Test Case '-[SwiftGodotTestability.__GodotTestRunner testRunEverythingInGodot]' passed (0.001 seconds).
Test Suite '__GodotTestRunner' passed at 2024-11-01 12:31:28.954.
Executed 1 test, with 0 failures (0 unexpected) in 0.001 (32.658) seconds
Test Suite 'SwiftGodotPackageTests.xctest' passed at 2024-11-01 12:31:28.954.
Executed 84 tests, with 0 failures (0 unexpected) in 2.995 (35.657) seconds
Test Suite 'All tests' passed at 2024-11-01 12:31:28.954.
Executed 84 tests, with 0 failures (0 unexpected) in 2.995 (35.658) seconds
This change does a few things:
Using the dummy run class makes the test suites appear to contain no tests when they are run outside the engine:
Later when they run in the engine, the tests will show up:
This is marginally less confusing as you can search for the name of a specific test like
testBasicGetters
and find it in just one place.The logging I've added around the initialisation and shutdown of the engine itself makes it a little clearer what's going on: