aboutsummaryrefslogtreecommitdiff
path: root/internal/engine/examples_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/engine/examples_test.go')
-rw-r--r--internal/engine/examples_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/internal/engine/examples_test.go b/internal/engine/examples_test.go
new file mode 100644
index 0000000..5f3d8e2
--- /dev/null
+++ b/internal/engine/examples_test.go
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package engine
+
+import (
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+)
+
+// TestExamplesLoad: every shipped example directory file loads without a
+// diagnostic, so a change to the config language cannot leave the examples
+// installed under share/doc/krino broken (triage 34o).
+func TestExamplesLoad(t *testing.T) {
+ examples, err := filepath.Glob(filepath.Join("..", "..", "examples", "*.conf"))
+ if err != nil || len(examples) == 0 {
+ t.Fatalf("no examples found: %v", err)
+ }
+ for _, ex := range examples {
+ t.Run(filepath.Base(ex), func(t *testing.T) {
+ h := sandbox(t)
+ for _, d := range []string{"Downloads", "Pictures"} {
+ os.MkdirAll(filepath.Join(h, d), 0o755)
+ }
+ body, err := os.ReadFile(ex)
+ if err != nil {
+ t.Fatal(err)
+ }
+ name := strings.TrimSuffix(filepath.Base(ex), ".conf")
+ main := writeConfig(t, h, `(include "`+name+`")`, map[string]string{name: string(body)})
+ if _, errs := Load(main); len(errs) > 0 {
+ t.Errorf("%s: %v", ex, errs)
+ }
+ })
+ }
+}