Skip to content

Commit e503480

Browse files
dmitshurgopherbot
authored andcommitted
encoding/japanese, language: shorten very long sub-test names
Some of the generated sub-test names end up being excessively long, which doesn't mix well with them being stored as test IDs that track test runs over time. Replacing test case names with numbers harms their readability, so start by trimming a few that end up being 500+ bytes in length. Change-Id: Id3b22105efc08eb1bb51436aa257682d357d662c Reviewed-on: https://go-review.googlesource.com/c/text/+/506416 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
1 parent 2df65d7 commit e503480

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

encoding/japanese/all_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"strings"
1010
"testing"
11+
"unicode/utf8"
1112

1213
"golang.org/x/text/encoding"
1314
"golang.org/x/text/encoding/internal"
@@ -126,7 +127,7 @@ func TestNonRepertoire(t *testing.T) {
126127
}
127128
for _, tc := range testCases {
128129
dir, tr, wantErr := tc.init(tc.e)
129-
t.Run(fmt.Sprintf("%s/%v/%q", dir, tc.e, tc.src), func(t *testing.T) {
130+
t.Run(fmt.Sprintf("%s/%v/%q", dir, tc.e, short(tc.src)), func(t *testing.T) {
130131
dst := make([]byte, 100000)
131132
src := []byte(tc.src)
132133
for i := 0; i <= len(tc.src); i++ {
@@ -147,6 +148,16 @@ func TestNonRepertoire(t *testing.T) {
147148
}
148149
}
149150

151+
func short(s string) string {
152+
if len(s) <= 50 {
153+
return s
154+
}
155+
var i int
156+
for i = 1; i < utf8.UTFMax && !utf8.RuneStart(s[50-i]); i++ {
157+
}
158+
return s[:50-i] + "…"
159+
}
160+
150161
func TestCorrect(t *testing.T) {
151162
testCases := []struct {
152163
init func(e encoding.Encoding) (string, transform.Transformer, error)

language/match_test.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"path/filepath"
1414
"strings"
1515
"testing"
16+
"unicode/utf8"
1617

1718
"golang.org/x/text/internal/testtext"
1819
"golang.org/x/text/internal/ucd"
@@ -30,11 +31,11 @@ func TestCompliance(t *testing.T) {
3031
t.Fatal(err)
3132
}
3233
ucd.Parse(r, func(p *ucd.Parser) {
33-
name := strings.Replace(path.Join(p.String(0), p.String(1)), " ", "", -1)
34+
name := strings.ReplaceAll(path.Join(p.String(0), p.String(1)), " ", "")
3435
if skip[name] {
3536
return
3637
}
37-
t.Run(info.Name()+"/"+name, func(t *testing.T) {
38+
t.Run(info.Name()+"/"+short(name), func(t *testing.T) {
3839
supported := makeTagList(p.String(0))
3940
desired := makeTagList(p.String(1))
4041
gotCombined, index, conf := NewMatcher(supported).Match(desired...)
@@ -56,6 +57,16 @@ func TestCompliance(t *testing.T) {
5657
})
5758
}
5859

60+
func short(s string) string {
61+
if len(s) <= 50 {
62+
return s
63+
}
64+
var i int
65+
for i = 1; i < utf8.UTFMax && !utf8.RuneStart(s[50-i]); i++ {
66+
}
67+
return s[:50-i] + "…"
68+
}
69+
5970
var skip = map[string]bool{
6071
// TODO: bugs
6172
// Honor the wildcard match. This may only be useful to select non-exact

0 commit comments

Comments
 (0)