Files
mesh-catalog/modules/picom/cmd/picom-tools/manifest_test.go
T
jschoubben ca1bd18de6
mesh/merge-gate pass: builds picom → g14, shanks; no bus step; every machine composes with the change as it did without (4 of 4 compose)
mesh/repo-check pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-check-typescript.sh (typescript)
mesh/delivery superseded: a newer delivery to the same trunk took over its walk
picom: keep the configuration trusted, so only the terminal sets the backend (review of #157)
A setting is pasted into picom.conf as it is, so a backend of xrender"; write-pid-path = "… adds an
option of the caller's: picom would then overwrite any file the operator can write. With the file
trusted, both settings are set at the controller's terminal alone until settings are typed and quoted
(hq issue 346).
2026-10-09 12:33:41 +02:00

95 lines
3.9 KiB
Go

package main
import (
"reflect"
"strings"
"testing"
)
// picom's shape (novox/hq ADR 0208): it claims node-compositor and serves no verb of it, requires the
// X display on its own machine, owns its configuration file, and is started once, by its package's
// XDG autostart entry, never by the window manager or the session's start as well.
func TestItClaimsTheCompositorSeatAndRequiresTheXDisplay(t *testing.T) {
m := readManifest(t)
if m.Module != "picom" || m.Seats != nil {
t.Fatalf("module %q declares seats %v", m.Module, m.Seats)
}
if !reflect.DeepEqual(m.Claims, []claim{{Name: "node-compositor", Scope: "node"}}) {
t.Fatalf("claims: %+v", m.Claims)
}
if !reflect.DeepEqual(m.Requires, []string{"x11-display"}) {
t.Fatalf("requires: %v", m.Requires)
}
if present, absent := m.packages(); !reflect.DeepEqual(present, []string{"picom", "xorg-xprop"}) || absent != nil {
t.Fatalf("packages: %v, absent %v", present, absent)
}
}
func TestItOwnsItsConfigurationAsWrittenInTheModule(t *testing.T) {
m := readManifest(t)
m.sameAsSource(t, "configuration", "files/picom.conf")
if p := m.resource(t, "configuration")["path"]; p != "${machine:account-home}/.config/picom/picom.conf" {
t.Fatalf("path: %v", p)
}
if d := m.resource(t, "configuration-dir"); d["type"] != "directory" || d["path"] != "${machine:account-home}/.config/picom" {
t.Fatalf("the directory: %v", d)
}
}
func TestThePackagesAutostartEntryIsItsOnlyStart(t *testing.T) {
m := readManifest(t)
// picom's package ships /etc/xdg/autostart/picom.desktop, which the session's dex runs. A second
// start from here would be a second compositor, refused by the first.
if m.Shell != nil {
t.Fatalf("a session-start line as well as the package's autostart entry: %+v", m.Shell)
}
for _, r := range m.Resources {
if p, _ := r["path"].(string); strings.Contains(p, "i3/config.d") || strings.Contains(p, "autostart") {
t.Fatalf("a second start: %v", r)
}
if r["type"] == "service" || r["type"] == "process" {
t.Fatalf("a unit: %v", r)
}
}
}
func TestTheToolsAgreeWithTheManifest(t *testing.T) {
m := readManifest(t)
checkTheToolsAgree(t, m)
checkNoSecretsOrInstallationNames(t)
}
// The backend and damage tracking are each machine's (novox/hq research 037: the backend depends on the
// machine's graphics driver; issue 345: a window left unpainted under glx is the first suspect). Both
// are settings whose defaults are what every machine ran before, so the file filled with them is today's.
func TestTheBackendAndDamageTrackingAreSettingsWithTodaysDefaults(t *testing.T) {
m := readManifest(t)
b, d := m.Settings["backend"], m.Settings["use-damage"]
if b.Kind != "preference" || b.Default != "glx" || b.Why == "" || d.Kind != "preference" || d.Default != true || d.Why == "" {
t.Fatalf("settings: %+v", m.Settings)
}
r := m.resource(t, "configuration")
c := r["content"].(string)
for _, want := range []string{`backend = "${setting:backend}";`, "use-damage = ${setting:use-damage};"} {
if !strings.Contains(c, want) {
t.Errorf("the file asks for %q", want)
}
}
// Trusted (unmarked): a value is pasted into the file as it is, so `xrender"; write-pid-path = "…`
// would add an option of the caller's. Until settings are typed and quoted (hq issue 346), only the
// controller's terminal sets them.
if _, marked := r["trusted"]; marked {
t.Fatal("the file stays trusted: its settings are set at the terminal alone (hq issue 346)")
}
got := parseRules("picom.conf", withDefaults(c), nil)
if got.Global["backend"] != "glx" || got.Global["use-damage"] != "true" || got.Global["vsync"] != "true" {
t.Fatalf("filled with the defaults: %v", got.Global)
}
}
// withDefaults fills the file's settings with their defaults, as a machine without its own values gets it.
func withDefaults(c string) string {
return strings.NewReplacer("${setting:backend}", "glx", "${setting:use-damage}", "true").Replace(c)
}