mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-11 14:45:31 +03:00
Also add tests for bad lines
This commit is contained in:
parent
7b4738125b
commit
07f4adbab5
@ -17,7 +17,8 @@ func TestConfigParsing(t *testing.T) {
|
||||
tdir := t.TempDir()
|
||||
conf_file := filepath.Join(tdir, "a.conf")
|
||||
os.Mkdir(filepath.Join(tdir, "sub"), 0o700)
|
||||
os.WriteFile(conf_file, []byte(`
|
||||
os.WriteFile(conf_file, []byte(
|
||||
`error main
|
||||
# ignore me
|
||||
a one
|
||||
#: other
|
||||
@ -29,7 +30,7 @@ globinclude sub/c?.conf
|
||||
os.WriteFile(filepath.Join(tdir, "sub/b.conf"), []byte("incb cool\ninclude a.conf"), 0o600)
|
||||
os.WriteFile(filepath.Join(tdir, "sub/c1.conf"), []byte("inc1 cool"), 0o600)
|
||||
os.WriteFile(filepath.Join(tdir, "sub/c2.conf"), []byte("inc2 cool\nenvinclude ENVINCLUDE"), 0o600)
|
||||
os.WriteFile(filepath.Join(tdir, "sub/c.conf"), []byte("inc notcool"), 0o600)
|
||||
os.WriteFile(filepath.Join(tdir, "sub/c.conf"), []byte("inc notcool\nerror sub"), 0o600)
|
||||
|
||||
var parsed_lines []string
|
||||
pl := func(key, val string) error {
|
||||
@ -45,8 +46,17 @@ globinclude sub/c?.conf
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
diff := cmp.Diff([]string{"a one", "incb cool", "b ", "inc1 cool", "inc2 cool", "env cool", "inc notcool"}, parsed_lines)
|
||||
err = p.ParseOverrides("over one", "over two")
|
||||
diff := cmp.Diff([]string{"a one", "incb cool", "b ", "inc1 cool", "inc2 cool", "env cool", "inc notcool", "over one", "over two"}, parsed_lines)
|
||||
if diff != "" {
|
||||
t.Fatalf("Unexpected parsed config values:\n%s", diff)
|
||||
}
|
||||
bad_lines := []string{}
|
||||
for _, bl := range p.BadLines() {
|
||||
bad_lines = append(bad_lines, fmt.Sprintf("%s: %d", filepath.Base(bl.Src_file), bl.Line_number))
|
||||
}
|
||||
diff = cmp.Diff([]string{"a.conf: 1", "c.conf: 2"}, bad_lines)
|
||||
if diff != "" {
|
||||
t.Fatalf("Unexpected bad lines:\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user