OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-tps / scenes / test / gate_sky_panel_sunshine.gd

72 lines · gd ref:
extends Node
## GATE: the F4 Atmosphere panel builds every Sunshine Clouds section -- IN AN
## EXPORTED BUILD, which is where it broke. The panel used to start at the
## script's category entry in get_property_list(), which Godot adds only in TOOLS
## builds; the installed game showed only Render and the effector's position
## while dev-run.sh showed everything (fixed in b0781f6).
##
## The editor run below passes either way. The run that matters is the export:
##   tools/gate-sky-panel-export.sh        (exports a pack, runs the release binary)
##   "$G" --path . --rendering-driver vulkan res://scenes/test/gate_sky_panel_sunshine.tscn
##
## Instantiates game.tscn as /root/Game, changes to the mountain, waits, then
## checks the panel's Sunshine Clouds section. Prints RESULT: PASS / FAIL.

const MAP := "res://scenes/maps/map_mountain.tscn"
const WAIT_S := 25.0
## Sections that come only from walking the scripts' exports. Missing any of these
## is the exported-build bug.
const REQUIRED: PackedStringArray = [
	"Basic Settings", "Basic Settings / Colors", "Basic Settings / Structure",
	"Advanced Settings / Visuals", "Driver / Wind Controls"]


func _ready() -> void:
	_run.call_deferred()


func _run() -> void:
	var game: Node = (load("res://scenes/game/game.tscn") as PackedScene).instantiate()
	game.name = "Game"
	get_tree().root.add_child(game)
	for i in 30:
		await get_tree().process_frame
	game.call("change_map", MAP, Vector3(0, 0, 0))
	var t0 := Time.get_ticks_msec()
	while (Time.get_ticks_msec() - t0) / 1000.0 < WAIT_S:
		await get_tree().process_frame
	var fails := 0
	var panel: Node = game.get("_sky_debug_panel")
	var box: VBoxContainer = panel.get("_sc_box") if panel != null else null
	if box == null:
		print("[GATE-SC] FAIL: no Sunshine Clouds section on the Atmosphere panel")
		_finish(1)
		return
	print("[GATE-SC] effect: %s" % str(panel.get("_sc_fx")))
	# header text -> control count of the content box that follows it
	var sections := {}
	var kids := box.get_children()
	for i in kids.size():
		var c: Node = kids[i]
		if c is Button and not c.is_queued_for_deletion() and i + 1 < kids.size():
			var title := (c as Button).text.substr(4)   # drop "[-] " / "[+] "
			sections[title] = kids[i + 1].get_child_count()
			print("[GATE-SC]   %-40s controls=%d" % [title, sections[title]])
	for title: String in REQUIRED:
		if int(sections.get(title, 0)) == 0:
			print("[GATE-SC] FAIL: section '%s' missing or empty" % title)
			fails += 1
	var total := 0
	for v: int in sections.values():
		total += v
	print("[GATE-SC] %d sections, %d controls" % [sections.size(), total])
	if sections.size() < 18:
		print("[GATE-SC] FAIL: expected 18 sections, got %d" % sections.size())
		fails += 1
	_finish(fails)


func _finish(fails: int) -> void:
	print("RESULT: %s" % ("PASS" if fails == 0 else "FAIL"))
	get_tree().quit(0 if fails == 0 else 1)