ci-platforms / build (amd64, darwin, macos-15-intel) (push) Skipped
ci-platforms / build (amd64, windows, windows-2022) (push) Skipped
ci-platforms / build (arm64, darwin, macos-15) (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Failing after 12m43s
ci / checks (push) Successful in 16m57s
71 lines
1.4 KiB
Go
71 lines
1.4 KiB
Go
package docstool
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"strings"
|
|
|
|
"aego/app/playground"
|
|
"aego/engine/docs"
|
|
)
|
|
|
|
const tryFrames = 60
|
|
|
|
func CheckTry(reg *docs.Registry, w io.Writer) int {
|
|
pg, err := playground.New()
|
|
if err != nil {
|
|
fmt.Fprintln(w, "try: cannot start the docs runtime:", err)
|
|
return 1
|
|
}
|
|
pg.SetGame(playground.GameConfig{Headless: true, FrameTime: 1.0 / 60})
|
|
defer func() {
|
|
if g := pg.Game(); g != nil {
|
|
g.Close()
|
|
}
|
|
}()
|
|
sandbox := map[string]bool{}
|
|
for _, e := range pg.TryScenes() {
|
|
sandbox[e.ID] = true
|
|
}
|
|
bad := 0
|
|
for _, e := range reg.All() {
|
|
if e.Try == "" {
|
|
continue
|
|
}
|
|
var msgs []string
|
|
add := func(msg string) {
|
|
for _, m := range msgs {
|
|
if m == msg || strings.Contains(m, msg) || strings.Contains(msg, m) {
|
|
return
|
|
}
|
|
}
|
|
msgs = append(msgs, msg)
|
|
}
|
|
switch res := pg.PlayScene(e.ID, []byte(e.Try)); {
|
|
case !sandbox[e.ID]:
|
|
add("belongs to a module the docs runtime does not include")
|
|
case !res.Started:
|
|
add("does not load: " + res.Error)
|
|
default:
|
|
if err := pg.Game().Step(tryFrames); err != nil {
|
|
add("stops the engine: " + err.Error())
|
|
}
|
|
}
|
|
poll := pg.Poll()
|
|
for _, l := range poll.Log {
|
|
if l.Level != "INFO" && l.Level != "DEBUG" {
|
|
add(l.Text)
|
|
}
|
|
}
|
|
for _, f := range poll.Faults {
|
|
add(f.Code + " " + f.Message)
|
|
}
|
|
for _, m := range msgs {
|
|
fmt.Fprintf(w, "%s: error: try scene %s\n", e.ID, m)
|
|
}
|
|
bad += len(msgs)
|
|
}
|
|
pg.Stop()
|
|
return bad
|
|
}
|