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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/cases/context_test.go b/cases/context_test.go
index de6ba3f..eb4d693 100644
--- a/cases/context_test.go
+++ b/cases/context_test.go
@@ -213,7 +213,8 @@
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 {
diff --git a/encoding/japanese/all_test.go b/encoding/japanese/all_test.go
index a8b53e2..8883006 100644
--- a/encoding/japanese/all_test.go
+++ b/encoding/japanese/all_test.go
@@ -14,6 +14,7 @@
"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) {
@@ -127,7 +128,7 @@
}
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++ {
@@ -148,7 +149,8 @@
}
}
-func short(s string) string {
+func shortNFC(s string) string {
+ s = norm.NFC.String(s)
if len(s) <= 50 {
return s
}
diff --git a/secure/bidirule/bidirule_test.go b/secure/bidirule/bidirule_test.go
index e8fde33..e1bc11c 100644
--- a/secure/bidirule/bidirule_test.go
+++ b/secure/bidirule/bidirule_test.go
@@ -10,6 +10,7 @@
"golang.org/x/text/internal/testtext"
"golang.org/x/text/unicode/bidi"
+ "golang.org/x/text/unicode/norm"
)
const (
@@ -55,7 +56,7 @@
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)
})
diff --git a/unicode/norm/transform_test.go b/unicode/norm/transform_test.go
index 2690fc3..9ff30d4 100644
--- a/unicode/norm/transform_test.go
+++ b/unicode/norm/transform_test.go
@@ -69,7 +69,7 @@
}
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 {