mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
Nicer way to include grapheme test data in Go tests
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -121,7 +121,7 @@ jobs:
|
||||
run: which python && python -m mypy --version && ./test.py mypy
|
||||
|
||||
- name: Run go vet
|
||||
run: cp kitty_tests/GraphemeBreakTest.json tools/wcswidth && go version && go vet ./...
|
||||
run: go version && go vet -tags testing ./...
|
||||
|
||||
- name: Build man page
|
||||
run: make FAIL_WARN=1 man
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -23,7 +23,6 @@ __pycache__/
|
||||
/docs/_build/
|
||||
/docs/generated/
|
||||
/tools/simdstring/simdstring.test
|
||||
/tools/wcswidth/GraphemeBreakTest.json
|
||||
/.mypy_cache
|
||||
/.ruff_cache
|
||||
.DS_Store
|
||||
|
||||
@@ -180,11 +180,10 @@ class GoProc(Thread):
|
||||
def run_go(packages: set[str], names: str) -> GoProc:
|
||||
go = go_exe()
|
||||
go_pkg_args = [f'kitty/{x}' for x in packages]
|
||||
cmd = [go, 'test', '-v']
|
||||
cmd = [go, 'test', '--tags', 'testing', '-v']
|
||||
for name in names:
|
||||
cmd.extend(('-run', name))
|
||||
cmd += go_pkg_args
|
||||
shutil.copy2('kitty_tests/GraphemeBreakTest.json', 'tools/wcswidth/GraphemeBreakTest.json')
|
||||
return GoProc(cmd)
|
||||
|
||||
|
||||
|
||||
13
testing_exports.go
Normal file
13
testing_exports.go
Normal file
@@ -0,0 +1,13 @@
|
||||
//go:build testing
|
||||
|
||||
package kitty
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
//go:embed kitty_tests/GraphemeBreakTest.json
|
||||
var GraphemeBreakTestData []byte
|
||||
@@ -8,13 +8,12 @@ import (
|
||||
|
||||
_ "embed"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
"kitty"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
//go:embed GraphemeBreakTest.json
|
||||
var test_data []byte
|
||||
|
||||
type GraphemeBreakTest struct {
|
||||
Data []string `json:"data"`
|
||||
Comment string `json:"comment"`
|
||||
@@ -31,7 +30,7 @@ func TestSplitIntoGraphemes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
tests := []GraphemeBreakTest{}
|
||||
if err := json.Unmarshal(test_data, &tests); err != nil {
|
||||
if err := json.Unmarshal(kitty.GraphemeBreakTestData, &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