M1b: Brücke und Hülle #6

Merged
steven merged 21 commits from m1b-bruecke-und-huelle into main 2026-10-01 11:46:02 +00:00
3 changed files with 25 additions and 9 deletions
Showing only changes of commit dff213cc61 - Show all commits
+1 -1
View File
@@ -39,7 +39,7 @@ Drei Wächter prüfen das. `core/clippy.toml` sperrt Pfade wie `std::collections
- GDScript mit Typangaben schreiben (`var x := …`, Rückgabetypen an jeder Funktion). - GDScript mit Typangaben schreiben (`var x := …`, Rückgabetypen an jeder Funktion).
- Eingabeaktionen legt `game/scripts/input_setup.gd` an, nicht `project.godot`. - Eingabeaktionen legt `game/scripts/input_setup.gd` an, nicht `project.godot`.
- Alle Texte, die Spieler sehen, stehen in `game/i18n/texts.csv` (Deutsch und Englisch) und werden über `tr()` geholt. - Alle Texte, die Spieler sehen, stehen in `game/i18n/texts.csv` (Deutsch und Englisch) und werden über `tr()` geholt.
- Tests, die Dateien schreiben, nutzen `TestFiles.temporary_dir()`, nie den echten Benutzerordner. - Tests, die Dateien schreiben, nutzen `TestFiles.temporary_dir()` (Ordner unter `user://tests`), nie die echten Dateien des Spielers.
- Godot erzeugt beim Import zu jedem Skript eine `.uid`-Datei. Sie gehört ins Archiv. Der Ordner `game/.godot/` gehört nicht hinein. - Godot erzeugt beim Import zu jedem Skript eine `.uid`-Datei. Sie gehört ins Archiv. Der Ordner `game/.godot/` gehört nicht hinein.
## Prüfen ## Prüfen
+5
View File
@@ -44,6 +44,11 @@ func _initialize() -> void:
func _run_all() -> void: func _run_all() -> void:
# Remove what runs that stopped early left behind, before the error
# counter starts. Only if the folder exists, because Godot reports an
# error when it lists a missing one.
if DirAccess.dir_exists_absolute(TestFiles.ROOT):
TestFiles.remove_dir(TestFiles.ROOT)
var counter := ErrorCounter.new() var counter := ErrorCounter.new()
OS.add_logger(counter) OS.add_logger(counter)
var passed := 0 var passed := 0
+19 -8
View File
@@ -1,18 +1,29 @@
class_name TestFiles class_name TestFiles
extends RefCounted extends RefCounted
## Temporary folders below user://tests for tests that write files, so that ## Temporary folders below user://tests for tests that write files. That
## tests never touch the player's real key, save or recordings. ## folder lies inside the game's real user folder, next to the player's own
## key, save and recordings, so nothing outside it may be deleted here.
## The only folder the tests write to and remove_dir deletes from.
const ROOT := "user://tests"
static func temporary_dir(label: String) -> String: static func temporary_dir(label: String) -> String:
var path := "user://tests".path_join("%s-%d" % [label, Time.get_ticks_usec()]) var path := ROOT.path_join("%s-%d" % [label, Time.get_ticks_usec()])
DirAccess.make_dir_recursive_absolute(path) DirAccess.make_dir_recursive_absolute(path)
return path return path
## Deletes the folder `path` with everything in it. Refuses every path that is
## not ROOT or below it, with an error and without deleting anything: a wrong
## argument must never delete the player's real files.
static func remove_dir(path: String) -> void: static func remove_dir(path: String) -> void:
for file in DirAccess.get_files_at(path): var clean := path.simplify_path()
DirAccess.remove_absolute(path.path_join(file)) if clean != ROOT and not clean.begins_with(ROOT + "/"):
for directory in DirAccess.get_directories_at(path): push_error("TestFiles.remove_dir refuses %s: it is not %s or below it" % [path, ROOT])
remove_dir(path.path_join(directory)) return
DirAccess.remove_absolute(path) for file in DirAccess.get_files_at(clean):
DirAccess.remove_absolute(clean.path_join(file))
for directory in DirAccess.get_directories_at(clean):
remove_dir(clean.path_join(directory))
DirAccess.remove_absolute(clean)