Feature 57 (config and provisioning): modules declare config and provisions, their files rendered from templates; synced with main (issues of feature 57, 874)
This commit is contained in:
@@ -25,11 +25,13 @@ type manifest struct {
|
||||
Claims []any `json:"claims"`
|
||||
Seats []any `json:"seats"`
|
||||
Shell []any `json:"shell"`
|
||||
Contributions []struct {
|
||||
Seat string `json:"seat"`
|
||||
Kind string `json:"kind"`
|
||||
Content string `json:"content"`
|
||||
} `json:"contributions"`
|
||||
Moved bool `json:"moved"`
|
||||
Contributions []any `json:"contributions"`
|
||||
Items []struct {
|
||||
Collection string `json:"collection"`
|
||||
Name string `json:"name"`
|
||||
Template string `json:"template"`
|
||||
} `json:"items"`
|
||||
Environment any `json:"environment"`
|
||||
Build struct {
|
||||
Artifacts []map[string]any `json:"artifacts"`
|
||||
@@ -69,7 +71,7 @@ func TestTheToolsAgreeWithTheManifest(t *testing.T) {
|
||||
for name := range served {
|
||||
t.Errorf("the bundle serves %s, which module.json does not list", name)
|
||||
}
|
||||
if len(m.Build.Artifacts) != 1 {
|
||||
if len(m.Build.Artifacts) != 2 { // the tools bundle and the archive of its template
|
||||
t.Fatalf("%v", m.Build.Artifacts)
|
||||
}
|
||||
b := m.Build.Artifacts[0]
|
||||
@@ -93,11 +95,8 @@ func TestItDeclaresNoPackageAndContributesTheTraysOneStart(t *testing.T) {
|
||||
if m.Resources != nil || m.Capabilities != nil || m.Claims != nil || m.Seats != nil || m.Environment != nil || m.Shell != nil {
|
||||
t.Fatal("no package (outside the official repositories), no seat, no environment, no xinitrc start")
|
||||
}
|
||||
if len(m.Contributions) != 1 || m.Contributions[0].Seat != "node-display-session" || m.Contributions[0].Kind != "config" {
|
||||
t.Fatalf("%+v", m.Contributions)
|
||||
}
|
||||
var code []string
|
||||
for _, l := range strings.Split(m.Contributions[0].Content, "\n") {
|
||||
for _, l := range strings.Split(displayLines(t, m), "\n") {
|
||||
if l = strings.TrimSpace(l); l != "" && !strings.HasPrefix(l, "#") {
|
||||
code = append(code, l)
|
||||
}
|
||||
@@ -121,8 +120,23 @@ func TestTheContributionParsesInI3(t *testing.T) {
|
||||
}
|
||||
m, _ := readManifest(t)
|
||||
path := filepath.Join(t.TempDir(), "config")
|
||||
os.WriteFile(path, []byte("set $mod Mod4\n"+m.Contributions[0].Content), 0o644)
|
||||
os.WriteFile(path, []byte("set $mod Mod4\n"+displayLines(t, m)), 0o644)
|
||||
if out, err := exec.Command(i3, "-C", "-c", path).CombinedOutput(); err != nil || strings.Contains(string(out), "ERROR") {
|
||||
t.Fatalf("i3 -C: %v %s", err, out)
|
||||
}
|
||||
}
|
||||
|
||||
// displayLines is the module's lines for the window manager: the text of the template of its one item of the
|
||||
// collection contribution:node-display-session:config (design 57 L3, issue 848).
|
||||
func displayLines(t *testing.T, m manifest) string {
|
||||
t.Helper()
|
||||
if !m.Moved || len(m.Contributions) != 0 || len(m.Items) != 1 ||
|
||||
m.Items[0].Collection != "contribution:node-display-session:config" {
|
||||
t.Fatalf("moved %v, contributions %v, items %+v", m.Moved, m.Contributions, m.Items)
|
||||
}
|
||||
text, err := os.ReadFile(filepath.Join("..", "..", m.Items[0].Template))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return string(text)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# The Razer peripherals' tray (module polychromatic, novox/hq ADR 0208, ADR 0212). Owned by the mesh:
|
||||
# replaced at every push. This line is the tray's one start, at the session's start (exec, not
|
||||
# exec_always, so a reload starts nothing). The package's own login helper starts it too while the
|
||||
# application's setting "Start the tray applet when I log on" is ticked; polychromatic_check names
|
||||
# that as a second start.
|
||||
exec --no-startup-id polychromatic-tray-applet
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"module": "polychromatic",
|
||||
"version": "1",
|
||||
"moved": true,
|
||||
"requires": [
|
||||
"x11-display"
|
||||
],
|
||||
@@ -9,11 +10,11 @@
|
||||
"polychromatic_restart",
|
||||
"polychromatic_check"
|
||||
],
|
||||
"contributions": [
|
||||
"items": [
|
||||
{
|
||||
"seat": "node-display-session",
|
||||
"kind": "config",
|
||||
"content": "# The Razer peripherals' tray (module polychromatic, novox/hq ADR 0208, ADR 0212). Owned by the mesh:\n# replaced at every push. This line is the tray's one start, at the session's start (exec, not\n# exec_always, so a reload starts nothing). The package's own login helper starts it too while the\n# application's setting \"Start the tray applet when I log on\" is ticked; polychromatic_check names\n# that as a second start.\nexec --no-startup-id polychromatic-tray-applet\n"
|
||||
"collection": "contribution:node-display-session:config",
|
||||
"name": "display-session",
|
||||
"template": "files/display-session"
|
||||
}
|
||||
],
|
||||
"build": {
|
||||
@@ -28,6 +29,11 @@
|
||||
"loads": [
|
||||
"polychromatic-tools"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "files",
|
||||
"kind": "archive",
|
||||
"from": "files"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user