Files
aego/app/docsview/component_runtime_persist_test.go
sanspie 50be5c04bc
ci-platforms / darwin amd64 smoke (push) Skipped
GitHub / linux amd64 native GitHub-hosted native CI: success
ci-platforms / windows amd64 smoke (push) Skipped
GitHub / windows amd64 native GitHub-hosted native CI: success
GitHub / darwin arm64 native GitHub-hosted native CI: success
GitHub / darwin amd64 native GitHub-hosted native CI: success
ci / checks (push) Failing after 1h21m34s
ci / native-authoring (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
github-native / gitea-pending (push) Skipped
github-native / darwin amd64 native (push) Skipped
github-native / linux amd64 native (push) Skipped
github-native / windows amd64 native (push) Skipped
github-native / darwin arm64 native (push) Skipped
github-native / gitea-result (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 12m4s
ci / release (push) Skipped
Stage 12.5: Art Workspace and asset authoring
Add dockable Art tools, animation and previews, guarded asset workflows,
and the Web Asset Studio built on the shared Art Core. Expand English and
Russian documentation, interactive Try scenes, examples and editor icons.

Add audio waveform navigation, source analysis, guarded previews and a
browser Worker mixer. Preserve source changes and recovery with bounded
checks, and strengthen native, browser and interoperability CI.

Prepare version 0.12.5 and manually built native artifact candidates.
Fix the production site image demo build dependency.
Reuse immutable scene indices when capturing keyframes.
Wait for real Persist save/load completion in component tests.
Stabilize browser Game View captures outside pointer hover.
Aseprite interchange and persistent Audio EDL recovery remain limited;
the artifact workflow does not publish releases or change stable.
2026-11-15 10:37:50 +03:00

104 lines
3.3 KiB
Go

//go:build aego_editor
package docsview
import (
"sync"
"testing"
"time"
"aego/modules/savegame"
)
func TestPersistCycleEventsRequireBothCompletionsAndCleanup(t *testing.T) {
for _, order := range [][]string{{"game saved", "game loaded"}, {"game loaded", "game saved"}} {
t.Run(order[0], func(t *testing.T) {
var events persistCycleEvents
if events.complete(true) {
t.Fatal("accepted no completion events")
}
events.record([]Line{{Text: order[0]}})
if events.complete(true) {
t.Fatal("accepted only one completion event")
}
events.record([]Line{{Text: order[1]}})
if events.complete(false) || !events.complete(true) {
t.Fatal("completion must also require deletion of the temporary slot")
}
events = persistCycleEvents{}
if events.complete(true) {
t.Fatal("completion events leaked into the next cycle")
}
})
}
}
func TestComponentContractPersistWaitsForDelayedWorker(t *testing.T) {
for _, target := range []string{"initial reset", "action", "final reset"} {
t.Run(target, func(t *testing.T) {
resets, held, waited := 0, false, false
var release func()
hooks := componentRuntimeHooks{only: "save.Persist"}
hooks.beforeCycle = func(t *testing.T, a *App, phase string) {
if phase == "reset" {
resets++
}
selected := target == "action" && phase == "action" ||
target == "initial reset" && phase == "reset" && resets == 1 ||
target == "final reset" && phase == "reset" && resets == 2
if !selected {
return
}
jobs := a.e.Jobs()
if jobs.Workers() < 1 {
t.Fatal("no save worker available")
}
entered := make(chan struct{}, jobs.Workers())
gate := make(chan struct{})
var once sync.Once
release = func() { once.Do(func() { close(gate) }) }
t.Cleanup(release)
for range jobs.Workers() {
jobs.Submit(func() { entered <- struct{}{}; <-gate })
}
timer := time.NewTimer(10 * time.Second)
defer timer.Stop()
for range jobs.Workers() {
select {
case <-entered:
case <-timer.C:
t.Fatal("could not hold the save worker")
}
}
held = true
}
hooks.onWait = func(t *testing.T, a *App, phase string, events persistCycleEvents) {
if !held || waited {
return
}
if target == "action" && phase != "action" ||
target == "initial reset" && (phase != "reset" || resets != 1) ||
target == "final reset" && (phase != "reset" || resets != 2) {
t.Fatalf("%s continued into %s before waiting", target, phase)
}
world := a.session.Controller().World()
if world == nil {
t.Fatal("Try world is not running")
}
service := savegame.Of(world)
reply := a.Call("inspect", []byte(`{"component":"save.Persist","fields":["save.Persist.PositionX"]}`))
if events.saved || events.loaded || service == nil || service.Exists("persist-demo") ||
reply.Error != "" || reply.Inspection == nil || reply.Inspection.Observables["save.Persist.PositionX"] != float64(2) {
t.Fatalf("worker delay did not hold the four-frame state: events=%+v inspection=%+v", events, reply)
}
waited = true
release()
}
runComponentContractRuntimeObservables(t, hooks)
if !held || !waited {
t.Fatalf("%s did not wait for the delayed worker: held=%v waited=%v", target, held, waited)
}
})
}
}