diff --git a/README.md b/README.md index c2711e1..8d04a05 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,10 @@ extends Node # What directory should tests be located in? var test_directory: String = "res://tests" +# If Bessere Tests should complain about orphan nodes. +# This behaviour is reportedly broken and does not work correctly (see #1). +# Rely on Godot's debug/verbose output for this instead (use Bessere Tests' command line script). +var print_orphan_nodes: bool = false ``` This is the default configuration. If you want to keep a config key to it's default simply comment it out. diff --git a/addons/besseretests/src/runtimescene.gd b/addons/besseretests/src/runtimescene.gd index d2ce75e..c6f7fab 100644 --- a/addons/besseretests/src/runtimescene.gd +++ b/addons/besseretests/src/runtimescene.gd @@ -3,10 +3,11 @@ extends Control # Configuration for the configuration var config: Node = Node.new() const config_path: String = "res://addons/besseretests_config.gd" -const config_keys: Dictionary = { "test_directory": TYPE_STRING } +const config_keys: Dictionary = { "test_directory": TYPE_STRING, "print_orphan_nodes": TYPE_BOOL } # Configuration var config_test_directory: String = "res://tests" +var config_print_orphan_nodes: bool = false # Statistics <3 & results var results: Dictionary = {} @@ -165,8 +166,6 @@ func terminate(exit_code: int = 0) -> void: 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_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)-4) + "' orphan nodes loaded. Please make sure to call 'queue_free' or 'free' on them in your tests.") +func check_orphan_nodes() -> void: if config_print_orphan_nodes: if Performance.get_monitor(Performance.OBJECT_ORPHAN_NODE_COUNT) != 4: lwarn("There are still '" + str(Performance.get_monitor(Performance.OBJECT_ORPHAN_NODE_COUNT)-4) + "' orphan nodes loaded. Please make sure to call 'queue_free' or 'free' on them in your tests.") diff --git a/addons/besseretests_config.gd b/addons/besseretests_config.gd index a51384f..b6191d8 100644 --- a/addons/besseretests_config.gd +++ b/addons/besseretests_config.gd @@ -1,3 +1,4 @@ extends Node var test_directory: String = "res://addons/besseretests/examples/" +var print_orphan_nodes: bool = true