libreoffice support started, still broken. Some updates to how wine-access gets called.

This commit is contained in:
Storm Dragon committed 2026-10-14 16:24:49 -04:00
1 parent 8e76d2341c
commit 7f78177786
26 files changed
+1173 -21

No files matched your search

+56 -1
View File
@@ -119,7 +119,18 @@ func TestHelperPathPrefersConfiguredThenLocalHelper(t *testing.T) {
t.Setenv("HOME", root)
t.Setenv("CTHULHU_WINE_ACCESS_HELPER", "")
local := filepath.Join(root, ".local", "libexec", "cthulhu", "wine", "cthulhu-wine-access.exe")
legacy := filepath.Join(root, ".local", "libexec", "cthulhu", "wine", "cthulhu-wine-access.exe")
if err := os.MkdirAll(filepath.Dir(legacy), 0700); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(legacy, []byte("#!/bin/sh\n"), 0700); err != nil {
t.Fatal(err)
}
if got := helperPath(); got != legacy {
t.Fatalf("helperPath() = %q, want existing user helper %q", got, legacy)
}
local := filepath.Join(root, ".local", "libexec", "wine-access", "wine-access.exe")
if err := os.MkdirAll(filepath.Dir(local), 0700); err != nil {
t.Fatal(err)
}
@@ -140,6 +151,50 @@ func TestHelperPathPrefersConfiguredThenLocalHelper(t *testing.T) {
}
}
func TestFindHelperPrecedenceAndExecutableFiltering(t *testing.T) {
root := t.TempDir()
t.Setenv("CTHULHU_WINE_ACCESS_HELPER", "")
t.Setenv("PATH", root)
candidates := []string{
filepath.Join(root, "user", "wine-access.exe"),
filepath.Join(root, "usr-local", "wine-access.exe"),
filepath.Join(root, "usr", "wine-access.exe"),
}
for _, path := range candidates {
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
t.Fatal(err)
}
}
if got := findHelper(candidates); got != "" {
t.Fatalf("missing helpers = %q, want empty", got)
}
legacy := filepath.Join(root, "cthulhu-wine-access.exe")
pathHelper := filepath.Join(root, "wine-access.exe")
for _, path := range []string{legacy, pathHelper, candidates[2], candidates[1], candidates[0]} {
if err := os.WriteFile(path, []byte("#!/bin/sh\n"), 0700); err != nil {
t.Fatal(err)
}
if got := findHelper(candidates); got != path {
t.Fatalf("findHelper() = %q, want %q", got, path)
}
}
if err := os.Chmod(candidates[0], 0600); err != nil {
t.Fatal(err)
}
t.Setenv("CTHULHU_WINE_ACCESS_HELPER", candidates[0])
if got := findHelper(candidates); got != candidates[1] {
t.Fatalf("non-executable override/user helper = %q, want %q", got, candidates[1])
}
t.Setenv("CTHULHU_WINE_ACCESS_HELPER", root)
if got := findHelper(candidates); got != candidates[1] {
t.Fatalf("directory override = %q, want %q", got, candidates[1])
}
t.Setenv("CTHULHU_WINE_ACCESS_HELPER", pathHelper)
if got := findHelper(candidates); got != pathHelper {
t.Fatalf("executable override = %q, want %q", got, pathHelper)
}
}
func TestManagerLaunchesAndStopsHelperForActivePrefix(t *testing.T) {
root := t.TempDir()
procRoot := filepath.Join(root, "proc")