Skip to content

Commit a457f47

Browse files
dmitshurgopherbot
authored andcommitted
all: normalize subtest names to NFC
LUCI builders upload test results to ResultDB, which permits printable Unicode characters in test names, provided they're written in NFC form. Change-Id: I0abf67beb52da722af97e6981c308c4b4d801cbb Reviewed-on: https://go-review.googlesource.com/c/text/+/621555 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]>
1 parent 3043346 commit a457f47

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

cases/context_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ func TestCCC(t *testing.T) {
213213

214214
func TestWordBreaks(t *testing.T) {
215215
for _, tt := range breakTest {
216-
testtext.Run(t, tt, func(t *testing.T) {
216+
desc := norm.NFC.String(tt)
217+
testtext.Run(t, desc, func(t *testing.T) {
217218
parts := strings.Split(tt, "|")
218219
want := ""
219220
for _, s := range parts {

encoding/japanese/all_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"golang.org/x/text/encoding/internal"
1515
"golang.org/x/text/encoding/internal/enctest"
1616
"golang.org/x/text/transform"
17+
"golang.org/x/text/unicode/norm"
1718
)
1819

1920
func dec(e encoding.Encoding) (dir string, t transform.Transformer, err error) {
@@ -127,7 +128,7 @@ func TestNonRepertoire(t *testing.T) {
127128
}
128129
for _, tc := range testCases {
129130
dir, tr, wantErr := tc.init(tc.e)
130-
t.Run(fmt.Sprintf("%s/%v/%q", dir, tc.e, short(tc.src)), func(t *testing.T) {
131+
t.Run(fmt.Sprintf("%s/%v/%q", dir, tc.e, shortNFC(tc.src)), func(t *testing.T) {
131132
dst := make([]byte, 100000)
132133
src := []byte(tc.src)
133134
for i := 0; i <= len(tc.src); i++ {
@@ -148,7 +149,8 @@ func TestNonRepertoire(t *testing.T) {
148149
}
149150
}
150151

151-
func short(s string) string {
152+
func shortNFC(s string) string {
153+
s = norm.NFC.String(s)
152154
if len(s) <= 50 {
153155
return s
154156
}

secure/bidirule/bidirule_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"golang.org/x/text/internal/testtext"
1212
"golang.org/x/text/unicode/bidi"
13+
"golang.org/x/text/unicode/norm"
1314
)
1415

1516
const (
@@ -55,7 +56,7 @@ func init() {
5556
func doTests(t *testing.T, fn func(t *testing.T, tc ruleTest)) {
5657
for rule, cases := range testCases {
5758
for i, tc := range cases {
58-
name := fmt.Sprintf("%d/%d:%+q:%s", rule, i, tc.in, tc.in)
59+
name := fmt.Sprintf("%d/%d:%+q:%[3]s", rule, i, norm.NFC.String(tc.in))
5960
testtext.Run(t, name, func(t *testing.T) {
6061
fn(t, tc)
6162
})

unicode/norm/transform_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func TestTransform(t *testing.T) {
6969
}
7070
b := make([]byte, 100)
7171
for i, tt := range tests {
72-
t.Run(fmt.Sprintf("%d:%s", i, tt.in), func(t *testing.T) {
72+
t.Run(fmt.Sprint(i), func(t *testing.T) {
7373
nDst, _, err := tt.f.Transform(b[:tt.dstSize], []byte(tt.in), tt.eof)
7474
out := string(b[:nDst])
7575
if out != tt.out || err != tt.err {

0 commit comments

Comments
 (0)