mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
More robust fetching of grapheme break test data in Go test
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -23,6 +23,7 @@ __pycache__/
|
||||
/docs/_build/
|
||||
/docs/generated/
|
||||
/tools/simdstring/simdstring.test
|
||||
/tools/wcswidth/GraphemeBreakTest.json
|
||||
/.mypy_cache
|
||||
/.ruff_cache
|
||||
.DS_Store
|
||||
|
||||
@@ -10,7 +10,7 @@ import sys
|
||||
import time
|
||||
import unittest
|
||||
from collections.abc import Callable, Generator, Iterator, Sequence
|
||||
from contextlib import contextmanager
|
||||
from contextlib import contextmanager, suppress
|
||||
from functools import lru_cache
|
||||
from tempfile import TemporaryDirectory
|
||||
from threading import Thread
|
||||
@@ -184,6 +184,8 @@ def run_go(packages: set[str], names: str) -> GoProc:
|
||||
for name in names:
|
||||
cmd.extend(('-run', name))
|
||||
cmd += go_pkg_args
|
||||
with suppress(FileExistsError):
|
||||
os.link('kitty_tests/GraphemeBreakTest.json', 'tools/wcswidth/GraphemeBreakTest.json')
|
||||
return GoProc(cmd)
|
||||
|
||||
|
||||
|
||||
@@ -3,17 +3,18 @@ package wcswidth
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
"kitty/tools/utils"
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
//go:embed GraphemeBreakTest.json
|
||||
var test_data []byte
|
||||
|
||||
type GraphemeBreakTest struct {
|
||||
Data []string `json:"data"`
|
||||
Comment string `json:"comment"`
|
||||
@@ -29,19 +30,8 @@ func TestSplitIntoGraphemes(t *testing.T) {
|
||||
t.Fatalf("Failed to split %#v into graphemes: %s", text, diff)
|
||||
}
|
||||
}
|
||||
cmd := exec.Command(utils.KittyExe(), "+runpy", `
|
||||
from kitty.constants import read_kitty_resource
|
||||
import sys
|
||||
sys.stdout.buffer.write(read_kitty_resource("GraphemeBreakTest.json", "kitty_tests"))
|
||||
sys.stdout.flush()
|
||||
`)
|
||||
var output []byte
|
||||
var err error
|
||||
if output, err = cmd.Output(); err != nil {
|
||||
t.Fatalf("Getting GraphemeBreakTest.json failed with error: %s", err)
|
||||
}
|
||||
tests := []GraphemeBreakTest{}
|
||||
if err = json.Unmarshal(output, &tests); err != nil {
|
||||
if err := json.Unmarshal(test_data, &tests); err != nil {
|
||||
t.Fatalf("Failed to parse GraphemeBreakTest JSON with error: %s", err)
|
||||
}
|
||||
for i, x := range tests {
|
||||
|
||||
Reference in New Issue
Block a user