Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
68 lines
2.1 KiB
Go
68 lines
2.1 KiB
Go
//go:build windows
|
|
|
|
package d3d11
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
const testEffect = "float4 effect(float2 p, Effect e) { return float4(e.p0.rgb, 1); }\n"
|
|
|
|
// TestEffectCache checks that an effect's code compiles once for all its
|
|
// users, as CompileEffect compiles it, and that a later launch reads it
|
|
// from the disk.
|
|
func TestEffectCache(t *testing.T) {
|
|
want, err := CompileEffect(testEffect)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
dir := t.TempDir()
|
|
c := &effectCache{byKey: map[string]*effectEntry{}, dir: dir}
|
|
got, err := c.code(testEffect)
|
|
if err != nil || !bytes.Equal(got, want) {
|
|
t.Fatalf("code: %d bytes, %v; want %d bytes", len(got), err, len(want))
|
|
}
|
|
if again, _ := c.code(testEffect); &again[0] != &got[0] {
|
|
t.Error("the code compiled again")
|
|
}
|
|
files, _ := filepath.Glob(filepath.Join(dir, "*.dxbc"))
|
|
if len(files) != 1 {
|
|
t.Fatalf("files kept: %v", files)
|
|
}
|
|
// A file that is not whole compiles again.
|
|
os.WriteFile(files[0], want[:len(want)/2], 0o644)
|
|
if got, _ := (&effectCache{byKey: map[string]*effectEntry{}, dir: dir}).code(testEffect); !bytes.Equal(got, want) {
|
|
t.Error("a broken file was read")
|
|
}
|
|
// The next launch reads the file.
|
|
marked := append([]byte(nil), want...)
|
|
marked[len(marked)-1] ^= 1
|
|
os.WriteFile(files[0], marked, 0o644)
|
|
if got, _ := (&effectCache{byKey: map[string]*effectEntry{}, dir: dir}).code(testEffect); !bytes.Equal(got, marked) {
|
|
t.Error("the file was not read")
|
|
}
|
|
}
|
|
|
|
// TestTrimEffectCache checks that the cache removes the files least
|
|
// recently used beyond its size.
|
|
func TestTrimEffectCache(t *testing.T) {
|
|
dir := t.TempDir()
|
|
big := make([]byte, effectCacheSize/2)
|
|
for i, name := range []string{"a", "b", "c"} {
|
|
path := filepath.Join(dir, name)
|
|
os.WriteFile(path, big, 0o644)
|
|
at := time.Unix(int64(1000*(3-i)), 0) // a is the newest
|
|
os.Chtimes(path, at, at)
|
|
}
|
|
trimEffectCache(dir)
|
|
for name, kept := range map[string]bool{"a": true, "b": true, "c": false} {
|
|
if _, err := os.Stat(filepath.Join(dir, name)); (err == nil) != kept {
|
|
t.Errorf("%s: kept %v, want %v", name, err == nil, kept)
|
|
}
|
|
}
|
|
}
|