0.6.1: Emberwild is now Cinderwild (the old name's taken on Steam). Saves, identity and settings are copied across from the Emberwild folder on first start; the site moves to cinderwild.psbailey.uk; same protocol (18), so 0.6.0 and 0.6.1 play together
This commit is contained in:
71
tests/test_boot.gd
Normal file
71
tests/test_boot.gd
Normal file
@@ -0,0 +1,71 @@
|
||||
extends SceneTree
|
||||
## The rename (Emberwild -> Cinderwild, 0.6.1): the first start copies your
|
||||
## saves, identity and settings across from the old user-data folder, once,
|
||||
## without overwriting anything already there, and only from the newest old
|
||||
## name (so a world you deleted under Emberwild doesn't come back from the
|
||||
## Valheimlike folder).
|
||||
## Run: godot --headless --path . --script res://tests/test_boot.gd
|
||||
|
||||
var _fails := 0
|
||||
|
||||
func check(cond: bool, what: String) -> void:
|
||||
print((" ok " if cond else " FAIL ") + what)
|
||||
if not cond:
|
||||
_fails += 1
|
||||
|
||||
func _write(path: String, text: String) -> void:
|
||||
DirAccess.make_dir_recursive_absolute(path.get_base_dir())
|
||||
var f := FileAccess.open(path, FileAccess.WRITE)
|
||||
f.store_string(text)
|
||||
f.close()
|
||||
|
||||
func _read(path: String) -> String:
|
||||
return FileAccess.get_file_as_string(path) if FileAccess.file_exists(path) else ""
|
||||
|
||||
func _rm(dir: String) -> void:
|
||||
if not DirAccess.dir_exists_absolute(dir):
|
||||
return
|
||||
var da := DirAccess.open(dir)
|
||||
for f in da.get_files():
|
||||
DirAccess.remove_absolute(dir.path_join(f))
|
||||
for d in da.get_directories():
|
||||
_rm(dir.path_join(d))
|
||||
DirAccess.remove_absolute(dir)
|
||||
|
||||
func _initialize() -> void:
|
||||
var B: Node = root.get_node("Boot")
|
||||
var base := OS.get_user_data_dir().path_join("test_boot")
|
||||
_rm(base)
|
||||
var ember := base.path_join("Emberwild")
|
||||
var valheim := base.path_join("Valheimlike")
|
||||
var cinder := base.path_join("Cinderwild")
|
||||
_write(ember.path_join("worlds/home/state.json"), "ember home")
|
||||
_write(ember.path_join("identity.json"), "me")
|
||||
_write(ember.path_join("logs/godot.log"), "old log")
|
||||
_write(ember.path_join("migrated_from_valheimlike.txt"), "old marker")
|
||||
_write(valheim.path_join("worlds/deleted/state.json"), "gone")
|
||||
_write(cinder.path_join("audio.json"), "new settings")
|
||||
_write(ember.path_join("audio.json"), "old settings")
|
||||
|
||||
print("the first start")
|
||||
var n: int = 0
|
||||
for old_name in B.OLD_NAMES:
|
||||
var old_dir := base.path_join(old_name)
|
||||
if DirAccess.dir_exists_absolute(old_dir):
|
||||
n = B.migrate_from(old_dir, cinder, old_name)
|
||||
break
|
||||
check(n == 2, "copies the old folder's files (%d)" % n)
|
||||
check(_read(cinder.path_join("worlds/home/state.json")) == "ember home" and _read(cinder.path_join("identity.json")) == "me",
|
||||
"your worlds and identity come across")
|
||||
check(_read(cinder.path_join("audio.json")) == "new settings", "nothing already there is overwritten")
|
||||
check(not FileAccess.file_exists(cinder.path_join("logs/godot.log")), "logs stay behind")
|
||||
check(not FileAccess.file_exists(cinder.path_join("worlds/deleted/state.json")), "the older Valheimlike folder isn't raked over")
|
||||
check(FileAccess.file_exists(ember.path_join("identity.json")), "the old folder's left as it was")
|
||||
check(FileAccess.file_exists(cinder.path_join("migrated_from_emberwild.txt")) and not FileAccess.file_exists(cinder.path_join("migrated_from_valheimlike.txt")),
|
||||
"a marker says it's done")
|
||||
print("the next start")
|
||||
_write(ember.path_join("worlds/later/state.json"), "later")
|
||||
check(B.migrate_from(ember, cinder, "Emberwild") == 0 and not FileAccess.file_exists(cinder.path_join("worlds/later/state.json")), "it only happens once")
|
||||
_rm(base)
|
||||
print("RESULT: %s (%d failures)" % ["PASS" if _fails == 0 else "FAIL", _fails])
|
||||
quit(1 if _fails > 0 else 0)
|
||||
Reference in New Issue
Block a user