67 lines
2.9 KiB
GDScript3
67 lines
2.9 KiB
GDScript3
|
|
extends SceneTree
|
||
|
|
|
||
|
|
# The setup registry has to find its maps in an EXPORTED build, not only when
|
||
|
|
# run from source.
|
||
|
|
#
|
||
|
|
# An export converts text resources to binary and ships "<name>.tres.remap"
|
||
|
|
# in place of "<name>.tres" - the remap points at the converted file and
|
||
|
|
# ResourceLoader follows it when asked for the original path. The scan matched
|
||
|
|
# on ".tres", so in the exported web build it found nothing: every planet drew
|
||
|
|
# no setup, and since #211 the setup IS the garrison, so every world was
|
||
|
|
# empty. Nothing was logged; the planets were simply deserted.
|
||
|
|
#
|
||
|
|
# The suite runs from source, where the bug cannot appear, so this tests the
|
||
|
|
# name resolution directly against what a pack actually contains.
|
||
|
|
#
|
||
|
|
# Covers:
|
||
|
|
# A. the names a source tree lists
|
||
|
|
# B. the names an exported pack lists - the case that was broken
|
||
|
|
# C. things that are not setups are still ignored
|
||
|
|
# D. and the shipped maps really are all found when run from source
|
||
|
|
|
||
|
|
const SETUPS = preload("res://surface/PlanetSetups.gd")
|
||
|
|
|
||
|
|
|
||
|
|
func _initialize() -> void:
|
||
|
|
# --- A. from source ------------------------------------------------
|
||
|
|
for name in ["rocky_default.tres", "gas_default.tres"]:
|
||
|
|
if SETUPS.setup_file_name(name) != name:
|
||
|
|
return _fail("'%s' is not recognised from a source tree" % name)
|
||
|
|
|
||
|
|
# --- B. from a pack ------------------------------------------------
|
||
|
|
# Exactly the entries found inside the built index.pck.
|
||
|
|
for name in ["rocky_default.tres.remap", "ResearchLabSetup.tres.remap",
|
||
|
|
"researtch_lab_garrison.tres.remap", "gas_default.tres.remap"]:
|
||
|
|
var resolved: String = SETUPS.setup_file_name(name)
|
||
|
|
if resolved != name.get_basename():
|
||
|
|
return _fail("exported entry '%s' resolved to '%s', expected '%s'" \
|
||
|
|
% [name, resolved, name.get_basename()])
|
||
|
|
# A binary resource shipped directly is a setup too.
|
||
|
|
if SETUPS.setup_file_name("rocky_default.res") != "rocky_default.res":
|
||
|
|
return _fail("a binary .res setup is not recognised")
|
||
|
|
print("both spellings resolve: rocky_default.tres and .tres.remap")
|
||
|
|
|
||
|
|
# --- C. and nothing else is dragged in -----------------------------
|
||
|
|
for name in ["rocky_default.tres.import", "notes.txt", "icon.png",
|
||
|
|
"rocky_default.png.remap", ""]:
|
||
|
|
if SETUPS.setup_file_name(name) != "":
|
||
|
|
return _fail("'%s' was taken for a setup" % name)
|
||
|
|
print("non-setup entries are ignored, remapped or not")
|
||
|
|
|
||
|
|
# --- D. the shipped maps are all found -----------------------------
|
||
|
|
# Guards the other half: a resolver that is right about names is no use
|
||
|
|
# if the scan around it stops finding the real files.
|
||
|
|
var found: Array = []
|
||
|
|
for setup in SETUPS.all():
|
||
|
|
found.append(String(setup.setup_id))
|
||
|
|
if found.size() < 4:
|
||
|
|
return _fail("the registry found %d shipped setups: %s" % [found.size(), found])
|
||
|
|
print("registry finds %d shipped setups: %s" % [found.size(), found])
|
||
|
|
|
||
|
|
print("TEST_PLANET_SETUP_EXPORT_NAMES: PASS")
|
||
|
|
quit(0)
|
||
|
|
|
||
|
|
|
||
|
|
func _fail(message: String) -> void:
|
||
|
|
print("TEST_PLANET_SETUP_EXPORT_NAMES: FAIL (%s)" % message)
|
||
|
|
quit(1)
|