增加持久化构建记录、历史 APK 恢复、断点下载、Gradle 缓存复用、系统代理与按工程选择服务端 JDK。 支持已有工程目录、Git 状态检查、原生忽略规则和文本换行等价比较,修复干净检出与历史同步快照不一致时的误拦截。 优化插件设备可选构建、侧栏滚动、左右日志布局、时间显示和构建变体快速选择,并补充部署与协议文档。 验证:17 项 Go 测试、22 项插件测试及 HTTP/HTTPS 两条端到端测试通过;Linux/macOS 服务端交叉编译通过。
69 lines
2.2 KiB
Go
69 lines
2.2 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestTextComparisonPreservesRemoteBytes(t *testing.T) {
|
|
s := testServer(t)
|
|
p := project(t, s)
|
|
path := filepath.Join(s.work(p), "Source.kt")
|
|
original := []byte("val x = 1\r\nval y = 2\r\n")
|
|
os.WriteFile(path, original, 0600)
|
|
s.projects[p].Files["Source.kt"] = File{Hash: digest(original)}
|
|
f := s.manifest(p).Files["Source.kt"]
|
|
if f.TextHash != digest([]byte("val x = 1\nval y = 2\n")) || f.Hash != digest(original) {
|
|
t.Fatal("EOL or raw digest incorrect", f)
|
|
}
|
|
w := call(t, s, "POST", "/projects/"+p+"/sync", SyncRequest{Revision: "equivalent", Files: map[string]File{"Source.kt": {Hash: f.Hash}}})
|
|
if w.Code != 200 {
|
|
t.Fatal(w.Body.String())
|
|
}
|
|
b, _ := os.ReadFile(path)
|
|
if string(b) != string(original) {
|
|
t.Fatal("remote EOL rewritten")
|
|
}
|
|
for _, name := range []string{"image.bin", "script.sh", "gradlew"} {
|
|
q := filepath.Join(s.work(p), name)
|
|
os.WriteFile(q, original, 0600)
|
|
actual, _ := comparisonFile(q)
|
|
if actual.TextHash != "" {
|
|
t.Fatalf("binary/script normalized: %s", name)
|
|
}
|
|
}
|
|
for _, b := range [][]byte{{0xff, 0xfe, 13, 10}, []byte("a\x00\r\n")} {
|
|
os.WriteFile(path, b, 0600)
|
|
actual, _ := comparisonFile(path)
|
|
if actual.TextHash != "" {
|
|
t.Fatal("non-UTF8/NUL data normalized")
|
|
}
|
|
}
|
|
}
|
|
func TestDiscoveredJDKRequiredAndReleaseParsed(t *testing.T) {
|
|
s := testServer(t)
|
|
if _, e := s.selectedJDK(filepath.Join(t.TempDir(), "arbitrary")); e == nil {
|
|
t.Fatal("undiscovered executable accepted")
|
|
}
|
|
home := t.TempDir()
|
|
os.MkdirAll(filepath.Join(home, "bin"), 0700)
|
|
for _, n := range []string{"java", "javac"} {
|
|
os.WriteFile(filepath.Join(home, "bin", javaExecutable(n)), []byte("placeholder"), 0600)
|
|
}
|
|
os.WriteFile(filepath.Join(home, "release"), []byte("JAVA_VERSION=\"21.0.8\"\n"), 0600)
|
|
j, ok := inspectJDK(home, "test")
|
|
if !ok || j.Version != "21.0.8" {
|
|
t.Fatal("installed JDK release not recognized")
|
|
}
|
|
os.Remove(filepath.Join(home, "bin", javaExecutable("javac")))
|
|
if _, ok := inspectJDK(home, "test"); ok {
|
|
t.Fatal("JRE without javac offered as JDK")
|
|
}
|
|
w := call(t, s, "GET", "/jdks", nil)
|
|
if w.Code != 200 || !strings.Contains(w.Body.String(), `"defaultJavaHome"`) {
|
|
t.Fatal(w.Body.String())
|
|
}
|
|
}
|