mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
More robust fetching of grapheme break test data in Go test
This commit is contained in:
@@ -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