Nicer way to include grapheme test data in Go tests
This commit is contained in:
parent
e76daa3736
commit
9e1601a9b5
5 changed files with 18 additions and 8 deletions
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
|
run: which python && python -m mypy --version && ./test.py mypy
|
||||||
|
|
||||||
- name: Run go vet
|
- 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
|
- name: Build man page
|
||||||
run: make FAIL_WARN=1 man
|
run: make FAIL_WARN=1 man
|
||||||
|
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -23,7 +23,6 @@ __pycache__/
|
||||||
/docs/_build/
|
/docs/_build/
|
||||||
/docs/generated/
|
/docs/generated/
|
||||||
/tools/simdstring/simdstring.test
|
/tools/simdstring/simdstring.test
|
||||||
/tools/wcswidth/GraphemeBreakTest.json
|
|
||||||
/.mypy_cache
|
/.mypy_cache
|
||||||
/.ruff_cache
|
/.ruff_cache
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
|
||||||
|
|
@ -180,11 +180,10 @@ def wait(self, timeout=None) -> None:
|
||||||
def run_go(packages: set[str], names: str) -> GoProc:
|
def run_go(packages: set[str], names: str) -> GoProc:
|
||||||
go = go_exe()
|
go = go_exe()
|
||||||
go_pkg_args = [f'kitty/{x}' for x in packages]
|
go_pkg_args = [f'kitty/{x}' for x in packages]
|
||||||
cmd = [go, 'test', '-v']
|
cmd = [go, 'test', '--tags', 'testing', '-v']
|
||||||
for name in names:
|
for name in names:
|
||||||
cmd.extend(('-run', name))
|
cmd.extend(('-run', name))
|
||||||
cmd += go_pkg_args
|
cmd += go_pkg_args
|
||||||
shutil.copy2('kitty_tests/GraphemeBreakTest.json', 'tools/wcswidth/GraphemeBreakTest.json')
|
|
||||||
return GoProc(cmd)
|
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"
|
_ "embed"
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
|
|
||||||
|
"kitty"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = fmt.Print
|
var _ = fmt.Print
|
||||||
|
|
||||||
//go:embed GraphemeBreakTest.json
|
|
||||||
var test_data []byte
|
|
||||||
|
|
||||||
type GraphemeBreakTest struct {
|
type GraphemeBreakTest struct {
|
||||||
Data []string `json:"data"`
|
Data []string `json:"data"`
|
||||||
Comment string `json:"comment"`
|
Comment string `json:"comment"`
|
||||||
|
|
@ -31,7 +30,7 @@ func TestSplitIntoGraphemes(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tests := []GraphemeBreakTest{}
|
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)
|
t.Fatalf("Failed to parse GraphemeBreakTest JSON with error: %s", err)
|
||||||
}
|
}
|
||||||
for i, x := range tests {
|
for i, x := range tests {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue