Add gdlint and gdformat scripts

This commit is contained in:
2025-09-27 20:40:13 +04:00
parent 86439abea8
commit 06f0f87970
40 changed files with 2314 additions and 732 deletions

View File

@@ -10,6 +10,7 @@ const TestHelper = preload("res://tests/helpers/TestHelper.gd")
var discovered_scenes: Array[String] = []
var validation_results: Dictionary = {}
func _initialize():
# Wait for autoloads to initialize
await process_frame
@@ -20,6 +21,7 @@ func _initialize():
# Exit after tests complete
quit()
func run_tests():
TestHelper.print_test_header("Scene Validation")
@@ -34,14 +36,12 @@ func run_tests():
TestHelper.print_test_footer("Scene Validation")
func test_scene_discovery():
TestHelper.print_step("Scene Discovery")
# Discover scenes in key directories
var scene_directories = [
"res://scenes/",
"res://examples/"
]
var scene_directories = ["res://scenes/", "res://examples/"]
for directory in scene_directories:
discover_scenes_in_directory(directory)
@@ -53,6 +53,7 @@ func test_scene_discovery():
for scene_path in discovered_scenes:
print(" - %s" % scene_path)
func discover_scenes_in_directory(directory_path: String):
var dir = DirAccess.open(directory_path)
if not dir:
@@ -74,12 +75,14 @@ func discover_scenes_in_directory(directory_path: String):
file_name = dir.get_next()
func test_scene_loading():
TestHelper.print_step("Scene Loading Validation")
for scene_path in discovered_scenes:
validate_scene_loading(scene_path)
func validate_scene_loading(scene_path: String):
var scene_name = scene_path.get_file()
@@ -104,6 +107,7 @@ func validate_scene_loading(scene_path: String):
validation_results[scene_path] = "Loading successful"
TestHelper.assert_true(true, "%s - Scene loads successfully" % scene_name)
func test_scene_instantiation():
TestHelper.print_step("Scene Instantiation Testing")
@@ -112,6 +116,7 @@ func test_scene_instantiation():
if validation_results.get(scene_path, "") == "Loading successful":
validate_scene_instantiation(scene_path)
func validate_scene_instantiation(scene_path: String):
var scene_name = scene_path.get_file()
@@ -126,7 +131,9 @@ func validate_scene_instantiation(scene_path: String):
return
# Validate the instance
TestHelper.assert_not_null(scene_instance, "%s - Scene instantiation creates valid node" % scene_name)
TestHelper.assert_not_null(
scene_instance, "%s - Scene instantiation creates valid node" % scene_name
)
# Clean up the instance
scene_instance.queue_free()
@@ -135,6 +142,7 @@ func validate_scene_instantiation(scene_path: String):
if validation_results[scene_path] == "Loading successful":
validation_results[scene_path] = "Full validation successful"
func test_critical_scenes():
TestHelper.print_step("Critical Scene Validation")
@@ -149,11 +157,15 @@ func test_critical_scenes():
for scene_path in critical_scenes:
if scene_path in discovered_scenes:
var status = validation_results.get(scene_path, "Unknown")
TestHelper.assert_equal("Full validation successful", status,
"Critical scene %s must pass all validation" % scene_path.get_file())
TestHelper.assert_equal(
"Full validation successful",
status,
"Critical scene %s must pass all validation" % scene_path.get_file()
)
else:
TestHelper.assert_false(true, "Critical scene missing: %s" % scene_path)
func print_validation_summary():
print("\n=== Scene Validation Summary ===")
@@ -176,4 +188,4 @@ func print_validation_summary():
if failed_scenes == 0:
print("✅ All scenes passed validation!")
else:
print("%d scene(s) failed validation" % failed_scenes)
print("%d scene(s) failed validation" % failed_scenes)