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
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.
312 lines
11 KiB
Go
312 lines
11 KiB
Go
package main
|
|
|
|
import (
|
|
"io/fs"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestRepositoryRules(t *testing.T) {
|
|
cat, err := builtinCatalog()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
violations, err := Check(Config{Root: filepath.Join("..", ".."), Catalog: cat})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, v := range violations {
|
|
t.Error(v)
|
|
}
|
|
}
|
|
|
|
func TestMatch(t *testing.T) {
|
|
cases := []struct {
|
|
pattern, pkg string
|
|
want bool
|
|
}{
|
|
{"core/...", "core/mathx", true},
|
|
{"core/...", "core", true},
|
|
{"core/...", "coreutil", false},
|
|
{"platform", "platform/sdl", false},
|
|
{"platform/...", "platform/sdl", true},
|
|
{"...", "anything/at/all", true},
|
|
{"modules/*/editor", "modules/physics/editor", true},
|
|
{"modules/*/editor/...", "modules/physics/editor/x", true},
|
|
{"modules/*/editor", "modules/physics", false},
|
|
}
|
|
for _, c := range cases {
|
|
if got := match(c.pattern, c.pkg); got != c.want {
|
|
t.Fatalf("match(%q, %q) = %v", c.pattern, c.pkg, got)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestRuleSpecificity(t *testing.T) {
|
|
r, ok := ruleFor("platform/sdl")
|
|
if !ok || r.pkg != "platform/sdl" {
|
|
t.Fatalf("rule = %v ok=%v", r.pkg, ok)
|
|
}
|
|
r, _ = ruleFor("gpu/internal/glstate")
|
|
if r.pkg != "gpu/internal/..." {
|
|
t.Fatalf("internal rule = %v", r.pkg)
|
|
}
|
|
if _, ok := ruleFor("nowhere/at/all"); ok {
|
|
t.Fatal("unknown package matched a rule")
|
|
}
|
|
}
|
|
|
|
func TestStageSixGraph(t *testing.T) {
|
|
if _, ok := ruleFor("script/build"); ok {
|
|
t.Fatal("script/build must not have a rule, the package is removed")
|
|
}
|
|
for _, rt := range []string{"script/vm", "script/runtime", "modules/scripting/systems", "script/reload", "script/stdlib", "script/bind"} {
|
|
for _, dev := range []string{"script/workspace", "script/langsvc", "script/harness"} {
|
|
found := false
|
|
for _, d := range denied {
|
|
if match(d.pkg, rt) && allowed(d.deny, dev) {
|
|
found = true
|
|
}
|
|
}
|
|
if !found {
|
|
t.Errorf("%s may import %s", rt, dev)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestModuleGraph(t *testing.T) {
|
|
pairs := [][2]string{
|
|
{"modules/render2d", "modules/render3d"}, {"modules/render3d", "modules/render2d"},
|
|
{"modules/render2d", "modules/scripting"}, {"modules/render3d", "modules/scripting"},
|
|
{"modules/scripting", "modules/render2d"}, {"modules/scripting", "modules/render3d"},
|
|
{"engine/module", "editor/panels/inspector"}, {"scene", "engine/module"}, {"scene/frame", "engine/module"},
|
|
{"sdk", "app/assembly/builtin"}, {"editor/panels/inspector", "app/assembly/builtin"},
|
|
}
|
|
for _, p := range pairs {
|
|
from, _ := groupOf(p[0])
|
|
to, _ := groupOf(p[1])
|
|
if groupRule(from, to) == "" && layerRule(p[0], p[1]) == "" {
|
|
t.Errorf("%s may import %s", p[0], p[1])
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestArtAuthoringDependenciesStayOutOfRuntime(t *testing.T) {
|
|
if g, ok := groupOf("art"); !ok || g.kind != kKernel {
|
|
t.Fatal("art must have an explicit authoring-core group")
|
|
}
|
|
for _, pair := range [][2]string{
|
|
{"art", "art/internal/aseprite"},
|
|
{"asset/importers/artsource", "art"},
|
|
{"asset/importers/artsource", "asset/importers/texture"},
|
|
{"asset/importers/artsource", "asset/importers/animclip"},
|
|
{"editor/core/artedit", "art"},
|
|
{"modules/render2d/editor", "art"},
|
|
{"engine/docs", "engine/docs/democheck"},
|
|
{"engine/docs", "script/parser"},
|
|
{"engine/docs", "script/source"},
|
|
} {
|
|
if rule := layerRule(pair[0], pair[1]); rule != "" {
|
|
t.Errorf("required edge %s -> %s rejected by %s", pair[0], pair[1], rule)
|
|
}
|
|
}
|
|
for _, pair := range [][2]string{
|
|
{"art", "asset"},
|
|
{"art", "scene"},
|
|
{"art", "art/internal/unrelated"},
|
|
{"art/internal/aseprite", "art"},
|
|
{"art/internal/aseprite", "asset"},
|
|
{"scene", "art"},
|
|
{"asset/importers/texture", "art"},
|
|
{"engine/docs/democheck", "asset"},
|
|
{"engine/docs", "script/compiler"},
|
|
{"engine/docs", "asset/pipeline"},
|
|
} {
|
|
if layerRule(pair[0], pair[1]) == "" {
|
|
t.Errorf("unexpected authoring dependency %s -> %s allowed", pair[0], pair[1])
|
|
}
|
|
}
|
|
for _, pkg := range []string{"art", "art/internal/aseprite", "art/internal/future"} {
|
|
if !allowed(runtimeForbidden, pkg) || !allowed(wasmDenied, pkg) {
|
|
t.Fatalf("authoring package %s must not enter game runtime builds", pkg)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestNoLegacyPackages(t *testing.T) {
|
|
root := filepath.Join("..", "..")
|
|
needles := []string{`"aego/scene/components"`, `"aego/scene/systems"`, "importers.All", "stdlib.Register("}
|
|
err := filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if d.IsDir() {
|
|
if n := d.Name(); path != root && (strings.HasPrefix(n, ".") || n == "third_party" || n == "depcheck") {
|
|
return filepath.SkipDir
|
|
}
|
|
return nil
|
|
}
|
|
if !strings.HasSuffix(path, ".go") {
|
|
return nil
|
|
}
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
for _, n := range needles {
|
|
if strings.Contains(string(data), n) {
|
|
t.Errorf("%s still references %s", path, n)
|
|
}
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestRuntimePackagesExcludeDev(t *testing.T) {
|
|
pkgs, err := RuntimePackages(filepath.Join("..", ".."))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
have := map[string]bool{}
|
|
for _, p := range pkgs {
|
|
local := strings.TrimPrefix(p, "aego/")
|
|
if allowed(runtimeForbidden, local) {
|
|
t.Errorf("runtime list contains dev package %s", local)
|
|
}
|
|
have[local] = true
|
|
}
|
|
for _, want := range []string{"engine", "scene", "script/runtime", "sdk"} {
|
|
if !have[want] {
|
|
t.Errorf("runtime list misses %s", want)
|
|
}
|
|
}
|
|
for _, dev := range []string{"app", "app/docsview", "cmd/aego", "editor/core/context", "project", "script/compiler"} {
|
|
if have[dev] {
|
|
t.Errorf("runtime list contains %s", dev)
|
|
}
|
|
}
|
|
for _, dev := range []string{"app/docsview", "app/docsview/internal"} {
|
|
if !allowed(runtimeForbidden, dev) {
|
|
t.Errorf("runtime must forbid %s", dev)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestRuntimePackagesHaveBuildFiles(t *testing.T) {
|
|
root := filepath.Join("..", "..")
|
|
pkgs, err := RuntimePackages(root)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(pkgs) == 0 {
|
|
t.Fatal("runtime package list is empty")
|
|
}
|
|
args := []string{"list", "-tags=aego_runtime", "-f", "{{if not .GoFiles}}{{if not .CgoFiles}}{{.ImportPath}}{{end}}{{end}}"}
|
|
cmd := exec.Command("go", append(args, pkgs...)...)
|
|
cmd.Dir = root
|
|
cmd.Env = append(os.Environ(), "GOWORK=off")
|
|
output, err := cmd.CombinedOutput()
|
|
if err != nil {
|
|
t.Fatalf("cannot list runtime packages: %v\n%s", err, output)
|
|
}
|
|
if missing := strings.Fields(string(output)); len(missing) != 0 {
|
|
t.Errorf("runtime packages have no buildable Go files: %v", missing)
|
|
}
|
|
}
|
|
|
|
func TestRuleCases(t *testing.T) {
|
|
cases := []struct {
|
|
dir string
|
|
catalog *Catalog
|
|
want []string // "rule where" substrings; empty means clean
|
|
}{
|
|
{"clean", &Catalog{Modules: []CatalogModule{{ID: "foo", Dir: "modules/foo"}}}, nil},
|
|
{"module-module", nil, []string{"modules/a/a.go: [module-imports-module] imports modules/b"}},
|
|
{"kernel-module", nil, []string{"scene/x/x.go: [kernel-imports-module] imports modules/a"}},
|
|
{"panel-panel", nil, []string{"editor/panels/p1/p1.go: [panel-imports-panel] imports editor/panels/p2"}},
|
|
{"runtime-dev", nil, []string{"engine/y: [runtime-reaches-dev] reaches project via engine/y -> project"}},
|
|
{"module-own-editor", nil, []string{"modules/a/a.go: [module-imports-own-editor] imports modules/a/editor"}},
|
|
{"literal", &Catalog{Modules: []CatalogModule{{ID: "fakemod", Dir: "modules/fakemod"}}}, []string{
|
|
`editor/panels/inspector/inspector.go:3: [module-literal] "fakemod.Thing" names module fakemod`,
|
|
`scene/s/s.go:3: [module-literal] "FAK001" names module fakemod`,
|
|
}},
|
|
{"color-literal", &Catalog{}, []string{
|
|
"editor/panels/p/p.go:5: [color-literal] writes a mathx.Color literal",
|
|
"editor/panels/p/p.go:7: [color-literal] calls mathx.ColorRGB8",
|
|
"editor/panels/p/p.go:9: [color-literal] writes a mathx.Color literal",
|
|
}},
|
|
{"empty-reason", nil, []string{"[exception-syntax]", "has no reason", "unknown variant \"tset\""}},
|
|
{"unused-exception", nil, []string{"[exception-unused] core/a -> modules/x"}},
|
|
{"file-exception", nil, []string{"sdk/other.go: [sdk-imports-editor] imports editor/core/c"}},
|
|
{"wasm", nil, []string{"[wasm-reaches-forbidden] reaches modules/accessibility via cmd/aego-playground -> modules/accessibility"}},
|
|
{"wasm-std", nil, []string{
|
|
"cmd/aego-runtime: [wasm-reaches-std] reaches net/http via cmd/aego-runtime -> modules/net -> net/http",
|
|
"[wasm-reaches-forbidden] reaches update via cmd/aego-runtime -> update",
|
|
}},
|
|
{"no-group", nil, []string{"weird/x: [no-group]"}},
|
|
{"gameplay-modules", nil, []string{
|
|
"modules/gameplay/g.go: [module-imports-module] imports modules/physics",
|
|
"modules/gameplay/g.go: [module-imports-module] imports modules/camera",
|
|
"modules/gameplay/g.go: [module-imports-module] imports modules/audio",
|
|
}},
|
|
{"audio-render", nil, []string{"modules/audio/a.go: [layer:modules/audio] imports render/view", "modules/audio/editor/e.go: [layer:modules/audio/editor] imports render/view"}},
|
|
{"camera-render2d", nil, []string{"modules/camera/c.go: [module-imports-module] imports modules/render2d", "modules/camera/c.go: [layer:modules/camera] imports render/batch"}},
|
|
{"vorbis-internal", nil, []string{"audio/codec/vorbis/internal/vorbis/v.go: [layer:audio/codec/vorbis/internal/vorbis] imports core/mathx"}},
|
|
}
|
|
for _, c := range cases {
|
|
t.Run(c.dir, func(t *testing.T) {
|
|
vs, err := Check(Config{Root: filepath.Join("testdata", c.dir), Catalog: c.catalog})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var got []string
|
|
for _, v := range vs {
|
|
got = append(got, v.String())
|
|
}
|
|
all := strings.Join(got, "\n")
|
|
if len(c.want) == 0 && len(got) > 0 {
|
|
t.Fatalf("clean tree has violations:\n%s", all)
|
|
}
|
|
for _, w := range c.want {
|
|
if !strings.Contains(all, w) {
|
|
t.Errorf("missing %q in:\n%s", w, all)
|
|
}
|
|
}
|
|
if c.dir == "audio-render" && strings.Contains(all, "imports render/debug") {
|
|
t.Errorf("render/debug is allowed in the audio editor:\n%s", all)
|
|
}
|
|
if c.dir == "color-literal" && (strings.Contains(all, "ui/theme") || strings.Contains(all, "p.go:11") || strings.Contains(all, "p.go:13")) {
|
|
t.Errorf("the theme, a zero colour or a list of tokens is reported:\n%s", all)
|
|
}
|
|
if c.dir == "file-exception" && strings.Contains(all, "sdk/editor.go") {
|
|
t.Errorf("the excepted file is reported:\n%s", all)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestGoListErrorFails(t *testing.T) {
|
|
root := t.TempDir()
|
|
write := func(name, data string) {
|
|
p := filepath.Join(root, name)
|
|
if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(p, []byte(data), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
write("go.mod", "module aego\n\ngo 1.27\n")
|
|
write("scene/x/x.go", "package x\n\nimport _ \"aego/scene/missing\"\n")
|
|
if _, err := Check(Config{Root: root}); err == nil || !strings.Contains(err.Error(), "go list reported errors") {
|
|
t.Fatalf("err = %v", err)
|
|
}
|
|
}
|