Skip to content

Commit

Permalink
encoding/japanese, language: shorten very long sub-test names
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dmitshur authored and gopherbot committed Jun 26, 2023
1 parent 2df65d7 commit e503480
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
13 changes: 12 additions & 1 deletion encoding/japanese/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"strings"
"testing"
"unicode/utf8"

"golang.org/x/text/encoding"
"golang.org/x/text/encoding/internal"
Expand Down Expand Up @@ -126,7 +127,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, tc.src), func(t *testing.T) {
t.Run(fmt.Sprintf("%s/%v/%q", dir, tc.e, short(tc.src)), func(t *testing.T) {
dst := make([]byte, 100000)
src := []byte(tc.src)
for i := 0; i <= len(tc.src); i++ {
Expand All @@ -147,6 +148,16 @@ func TestNonRepertoire(t *testing.T) {
}
}

func short(s string) string {
if len(s) <= 50 {
return s
}
var i int
for i = 1; i < utf8.UTFMax && !utf8.RuneStart(s[50-i]); i++ {
}
return s[:50-i] + "…"
}

func TestCorrect(t *testing.T) {
testCases := []struct {
init func(e encoding.Encoding) (string, transform.Transformer, error)
Expand Down
15 changes: 13 additions & 2 deletions language/match_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"path/filepath"
"strings"
"testing"
"unicode/utf8"

"golang.org/x/text/internal/testtext"
"golang.org/x/text/internal/ucd"
Expand All @@ -30,11 +31,11 @@ func TestCompliance(t *testing.T) {
t.Fatal(err)
}
ucd.Parse(r, func(p *ucd.Parser) {
name := strings.Replace(path.Join(p.String(0), p.String(1)), " ", "", -1)
name := strings.ReplaceAll(path.Join(p.String(0), p.String(1)), " ", "")
if skip[name] {
return
}
t.Run(info.Name()+"/"+name, func(t *testing.T) {
t.Run(info.Name()+"/"+short(name), func(t *testing.T) {
supported := makeTagList(p.String(0))
desired := makeTagList(p.String(1))
gotCombined, index, conf := NewMatcher(supported).Match(desired...)
Expand All @@ -56,6 +57,16 @@ func TestCompliance(t *testing.T) {
})
}

func short(s string) string {
if len(s) <= 50 {
return s
}
var i int
for i = 1; i < utf8.UTFMax && !utf8.RuneStart(s[50-i]); i++ {
}
return s[:50-i] + "…"
}

var skip = map[string]bool{
// TODO: bugs
// Honor the wildcard match. This may only be useful to select non-exact
Expand Down

0 comments on commit e503480

Please sign in to comment.