Add checks against leftover children and orphan nodes
This commit is contained in:
parent
7e050aa6ab
commit
82cf251ece
1 changed files with 11 additions and 2 deletions
|
@ -2,8 +2,8 @@ extends Control
|
|||
|
||||
# Configuration for the configuration
|
||||
var config: Node = Node.new()
|
||||
var config_path: String = "res://addons/besseretests_config.gd"
|
||||
var config_keys: Dictionary = {"test_directory": TYPE_STRING}
|
||||
const config_path: String = "res://addons/besseretests_config.gd"
|
||||
const config_keys: Dictionary = { "test_directory": TYPE_STRING }
|
||||
|
||||
# Configuration
|
||||
var config_test_directory: String = "res://tests"
|
||||
|
@ -157,7 +157,16 @@ func lsanitize(message: String) -> String:
|
|||
# Terminates the engine
|
||||
func terminate(exit_code: int = 0) -> void:
|
||||
config.queue_free()
|
||||
check_children()
|
||||
check_orphan_nodes()
|
||||
linfo("Shutting down...")
|
||||
await get_tree().create_timer(0.25).timeout
|
||||
queue_free()
|
||||
get_tree().quit(exit_code)
|
||||
|
||||
# Checks
|
||||
func check_children() -> void:
|
||||
if get_tree().root.get_child_count() != 1: lwarn("There are still '" + str(get_tree().root.get_child_count()-1) + "' children active in the scene tree. Please make sure to call 'remove_child' on them in your tests.")
|
||||
|
||||
func check_orphan_nodes() -> void:
|
||||
if Performance.get_monitor(Performance.OBJECT_ORPHAN_NODE_COUNT) != 4: lwarn("There are still '" + str(Performance.get_monitor(Performance.OBJECT_ORPHAN_NODE_COUNT)) + "' orphan nodes loaded. Please make sure to call 'queue_free' or 'free' on them in your tests.")
|
||||
|
|
Loading…
Reference in a new issue