Skip to content

Commit

Permalink
all: normalize subtest names to NFC
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dmitshur authored and gopherbot committed Oct 21, 2024
1 parent 3043346 commit a457f47
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion cases/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ func TestCCC(t *testing.T) {

func TestWordBreaks(t *testing.T) {
for _, tt := range breakTest {
testtext.Run(t, tt, func(t *testing.T) {
desc := norm.NFC.String(tt)
testtext.Run(t, desc, func(t *testing.T) {
parts := strings.Split(tt, "|")
want := ""
for _, s := range parts {
Expand Down
6 changes: 4 additions & 2 deletions encoding/japanese/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"golang.org/x/text/encoding/internal"
"golang.org/x/text/encoding/internal/enctest"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/norm"
)

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

func short(s string) string {
func shortNFC(s string) string {
s = norm.NFC.String(s)
if len(s) <= 50 {
return s
}
Expand Down
3 changes: 2 additions & 1 deletion secure/bidirule/bidirule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"golang.org/x/text/internal/testtext"
"golang.org/x/text/unicode/bidi"
"golang.org/x/text/unicode/norm"
)

const (
Expand Down Expand Up @@ -55,7 +56,7 @@ func init() {
func doTests(t *testing.T, fn func(t *testing.T, tc ruleTest)) {
for rule, cases := range testCases {
for i, tc := range cases {
name := fmt.Sprintf("%d/%d:%+q:%s", rule, i, tc.in, tc.in)
name := fmt.Sprintf("%d/%d:%+q:%[3]s", rule, i, norm.NFC.String(tc.in))
testtext.Run(t, name, func(t *testing.T) {
fn(t, tc)
})
Expand Down
2 changes: 1 addition & 1 deletion unicode/norm/transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestTransform(t *testing.T) {
}
b := make([]byte, 100)
for i, tt := range tests {
t.Run(fmt.Sprintf("%d:%s", i, tt.in), func(t *testing.T) {
t.Run(fmt.Sprint(i), func(t *testing.T) {
nDst, _, err := tt.f.Transform(b[:tt.dstSize], []byte(tt.in), tt.eof)
out := string(b[:nDst])
if out != tt.out || err != tt.err {
Expand Down

0 comments on commit a457f47

Please sign in to comment.