Fix issues and memory leaking issues

This commit is contained in:
JeremyStar™ 2024-03-28 17:39:05 +01:00
parent b0ee910326
commit e27e29b3c8

View file

@ -92,7 +92,6 @@ func _ready() -> void:
# Runs a test suite
func run_suite(suite: String) -> void:
linfo("Running suite \"" + suite + "\"")
# Load test suite
var suite_node: BessereTestsTest = BessereTestsTest.new()
suite_node.set_script(load(config_test_directory + "/" + suite + ".gd"))
@ -110,34 +109,36 @@ func run_suite(suite: String) -> void:
if !test_method["name"].begins_with("test_"): continue
# Check if function has any arguments
if test_method["args"].size() != 0:
lerror("Test \"" + test_method["name"] + "\" in suite \"" + suite + "\" is not allowed to have arguments")
lerror("Test \"" + test_method["name"].replace("test_", "") + "\" in suite \"" + suite + "\" is not allowed to have arguments")
continue
lverb("Running test \"" + suite + "\":\"" + test_method["name"].replace("test_", "") + "\"")
suite_node.test_status = 505
suite_node.test_message = ""
# Execute before_each()
suite_node.lfunc = "before_each"
await suite_node.before_each()
# Execute test function
suite_node.lfunc = test_method["name"]
suite_node.lfunc = test_method["name"].replace("test_", "")
await suite_node.call(test_method["name"])
# Execute after_each()
suite_node.lfunc = "after_each"
await suite_node.after_each()
# Merge result into result dictionary
results.merge({ suite + ":" + test_method["name"]: { "status": suite_node.test_status, "message": lsanitize(suite_node.test_message) if suite_node.test_message != "" else "[i]No message has been set.[/i]" } })
results.merge({ suite + ":" + test_method["name"].replace("test_", ""): { "status": suite_node.test_status, "message": lsanitize(suite_node.test_message) if suite_node.test_message != "" else "[i]No message has been set.[/i]" } })
# Execute after_all()
suite_node.lfunc = "after_all"
await suite_node.after_all()
# Remove suite node
remove_child(suite_node)
get_tree().root.remove_child(suite_node)
suite_node.queue_free()
# Logging
func lresu(message: String, origin: String = "Bessere Tests") -> void: print_rich("[color=white]RESU " + origin + ": " + message + "[/color]")
func ldiag(message: String, origin: String = "Bessere Tests") -> void: print_rich("[color=dark_gray]DIAG " + origin + ": " + message + "[/color]")
func ldiag(message: String, origin: String = "Bessere Tests") -> void: print_rich("[color=gray]DIAG " + origin + ": " + message + "[/color]")
func lverb(message: String, origin: String = "Bessere Tests") -> void: print_rich("[color=gray]VERB " + origin + ": " + message + "[/color]")
func linfo(message: String, origin: String = "Bessere Tests") -> void: print_rich("[color=white]INFO " + origin + ": " + message + "[/color]")
func lwarn(message: String, origin: String = "Bessere Tests") -> void: print_rich("[color=yellow]WARN " + origin + ": " + message + "[/color]")
@ -152,9 +153,8 @@ func lsanitize(message: String) -> String:
# Terminates the engine
func terminate(exit_code: int = 0) -> void:
config.queue_free()
linfo("Shutting down...")
await get_tree().create_timer(0.25).timeout
queue_free()
get_tree().quit(exit_code)
await get_tree().create_timer(5).timeout
printerr("Godot hasn't shutdown yet (bug?)")
await get_tree().create_timer(99999999).timeout