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.
133 lines
4.8 KiB
Go
133 lines
4.8 KiB
Go
//go:build aego_editor
|
|
|
|
package docsview
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"io"
|
|
"strings"
|
|
"testing"
|
|
|
|
"aego/engine/docs/democheck"
|
|
)
|
|
|
|
// traceTryRunner streams progress before opening each real component environment.
|
|
type traceTryRunner struct {
|
|
runner democheck.Runner
|
|
output io.Writer
|
|
}
|
|
|
|
var _ democheck.Runner = traceTryRunner{}
|
|
|
|
func (r traceTryRunner) Open(ctx context.Context, contract democheck.Contract, env string) (democheck.Instance, error) {
|
|
if r.output != nil {
|
|
fmt.Fprintf(r.output, "component-try open component=%q environment=%q\n", contract.ComponentID, env)
|
|
}
|
|
instance, err := r.runner.Open(ctx, contract, env)
|
|
if r.output != nil {
|
|
state := "ready"
|
|
if err != nil {
|
|
state = "error"
|
|
} else if instance == nil {
|
|
state = "no-instance"
|
|
}
|
|
fmt.Fprintf(r.output, "component-try open-result component=%q environment=%q state=%s\n", contract.ComponentID, env, state)
|
|
}
|
|
return instance, err
|
|
}
|
|
|
|
type traceRunnerFunc func(context.Context, democheck.Contract, string) (democheck.Instance, error)
|
|
|
|
func (f traceRunnerFunc) Open(ctx context.Context, contract democheck.Contract, env string) (democheck.Instance, error) {
|
|
return f(ctx, contract, env)
|
|
}
|
|
|
|
type traceTestInstance struct{}
|
|
|
|
func (*traceTestInstance) Observe(context.Context) (democheck.Observation, error) {
|
|
return democheck.Observation{}, nil
|
|
}
|
|
func (*traceTestInstance) Action(context.Context, democheck.Action) error { return nil }
|
|
func (*traceTestInstance) Reset(context.Context, string) error { return nil }
|
|
func (*traceTestInstance) Close() error { return nil }
|
|
|
|
func TestTraceTryRunnerPreservesResultsAndStreamsBeforeOpen(t *testing.T) {
|
|
for _, fail := range []bool{false, true} {
|
|
name := "success"
|
|
if fail {
|
|
name = "failure"
|
|
}
|
|
t.Run(name, func(t *testing.T) {
|
|
var output bytes.Buffer
|
|
want := &traceTestInstance{}
|
|
failure := errors.New("underlying open failed")
|
|
ctx := context.Background()
|
|
contract := democheck.Contract{ComponentID: "engine.Example"}
|
|
runner := traceTryRunner{output: &output, runner: traceRunnerFunc(func(gotCtx context.Context, got democheck.Contract, env string) (democheck.Instance, error) {
|
|
if gotCtx != ctx || got.ComponentID != contract.ComponentID || env != "firefox" {
|
|
t.Fatal("runner changed the open request")
|
|
}
|
|
if got := output.String(); got != "component-try open component=\"engine.Example\" environment=\"firefox\"\n" {
|
|
t.Fatalf("start was not streamed before opening: %q", got)
|
|
}
|
|
if fail {
|
|
return nil, failure
|
|
}
|
|
return want, nil
|
|
})}
|
|
got, err := runner.Open(ctx, contract, "firefox")
|
|
if fail {
|
|
if got != nil || err != failure || !strings.Contains(output.String(), "state=error\n") {
|
|
t.Fatalf("failure changed: instance=%v error=%v trace=%q", got, err, output.String())
|
|
}
|
|
} else if got != want || err != nil || !strings.Contains(output.String(), "state=ready\n") {
|
|
t.Fatalf("success changed: instance=%v error=%v trace=%q", got, err, output.String())
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
type traceErrorWriter struct{}
|
|
|
|
func (traceErrorWriter) Write([]byte) (int, error) { return 0, errors.New("trace is unavailable") }
|
|
|
|
func TestTraceTryRunnerDoesNotChangeOpenOnTraceFailure(t *testing.T) {
|
|
want := &traceTestInstance{}
|
|
runner := traceRunnerFunc(func(context.Context, democheck.Contract, string) (democheck.Instance, error) {
|
|
return want, nil
|
|
})
|
|
for _, output := range []io.Writer{nil, traceErrorWriter{}} {
|
|
got, err := (traceTryRunner{runner: runner, output: output}).Open(context.Background(), democheck.Contract{}, "native")
|
|
if got != want || err != nil {
|
|
t.Fatalf("trace failure changed the runner result: instance=%v error=%v", got, err)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestTraceTryRunnerEscapesNames(t *testing.T) {
|
|
var output bytes.Buffer
|
|
runner := traceTryRunner{output: &output, runner: traceRunnerFunc(func(context.Context, democheck.Contract, string) (democheck.Instance, error) {
|
|
return &traceTestInstance{}, nil
|
|
})}
|
|
if _, err := runner.Open(context.Background(), democheck.Contract{ComponentID: "engine.Example\nnext"}, "firefox"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if strings.Count(output.String(), "\n") != 2 || !strings.Contains(output.String(), `engine.Example\nnext`) {
|
|
t.Fatalf("component name broke the progress log: %q", output.String())
|
|
}
|
|
}
|
|
|
|
func TestTraceTryRunnerDoesNotClaimMissingInstanceIsReady(t *testing.T) {
|
|
var output bytes.Buffer
|
|
runner := traceTryRunner{output: &output, runner: traceRunnerFunc(func(context.Context, democheck.Contract, string) (democheck.Instance, error) {
|
|
return nil, nil
|
|
})}
|
|
got, err := runner.Open(context.Background(), democheck.Contract{}, "native")
|
|
if got != nil || err != nil || !strings.Contains(output.String(), "state=no-instance\n") {
|
|
t.Fatalf("missing instance changed or misreported: instance=%v error=%v trace=%q", got, err, output.String())
|
|
}
|
|
}
|