From a457f47ba270b8aaa55d617b739beaee4233b2a0 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Mon, 21 Oct 2024 11:49:26 -0400 Subject: [PATCH 1/4] 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 Reviewed-by: Michael Pratt Reviewed-by: Dmitri Shuralyov Auto-Submit: Dmitri Shuralyov --- cases/context_test.go | 3 ++- encoding/japanese/all_test.go | 6 ++++-- secure/bidirule/bidirule_test.go | 3 ++- unicode/norm/transform_test.go | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cases/context_test.go b/cases/context_test.go index de6ba3f8c..eb4d69321 100644 --- a/cases/context_test.go +++ b/cases/context_test.go @@ -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 { diff --git a/encoding/japanese/all_test.go b/encoding/japanese/all_test.go index a8b53e2eb..888300649 100644 --- a/encoding/japanese/all_test.go +++ b/encoding/japanese/all_test.go @@ -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) { @@ -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++ { @@ -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 } diff --git a/secure/bidirule/bidirule_test.go b/secure/bidirule/bidirule_test.go index e8fde3383..e1bc11cef 100644 --- a/secure/bidirule/bidirule_test.go +++ b/secure/bidirule/bidirule_test.go @@ -10,6 +10,7 @@ import ( "golang.org/x/text/internal/testtext" "golang.org/x/text/unicode/bidi" + "golang.org/x/text/unicode/norm" ) const ( @@ -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) }) diff --git a/unicode/norm/transform_test.go b/unicode/norm/transform_test.go index 2690fc360..9ff30d485 100644 --- a/unicode/norm/transform_test.go +++ b/unicode/norm/transform_test.go @@ -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 { From fefda1abda0b8b7ada7be0c47594528770c4c162 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Mon, 21 Oct 2024 11:59:22 -0400 Subject: [PATCH 2/4] internal/texttest: remove Run and Bench helpers Versions of Go whose testing package doesn't yet support subtests and sub-benchmarks are no longer supported. Drop an intermediate layer of compatibility from the ./internal/texttest package. The initial version of this change was git-generate'd with the script: rm internal/testtext/go1_{6,7}.go gofmt -r 'testtext.Run(t, n, f) -> t.Run(n, f)' -w . gofmt -r 'testtext.Bench(b, n, f) -> b.Run(n, f)' -w . goimports -w . Unfortunately it seems gofmt -r dropped inner comments inside f, and also added some spurious blank lines. So it was manually amended not to include those changes. Change-Id: I5bcb553b90ce392aada7896d576194be479f2616 Reviewed-on: https://go-review.googlesource.com/c/text/+/621575 Auto-Submit: Dmitri Shuralyov LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Pratt Reviewed-by: Dmitri Shuralyov --- cases/context_test.go | 3 +-- cases/icu_test.go | 3 +-- cases/map_test.go | 16 ++++++++-------- internal/export/idna/idna_test.go | 2 +- internal/number/number_test.go | 3 +-- internal/testtext/go1_6.go | 23 ----------------------- internal/testtext/go1_7.go | 17 ----------------- language/display/display_test.go | 5 ++--- runes/runes_test.go | 4 ++-- secure/bidirule/bench_test.go | 4 +--- secure/bidirule/bidirule_test.go | 3 +-- secure/precis/benchmark_test.go | 4 +--- secure/precis/enforce_test.go | 2 +- secure/precis/profile_test.go | 3 +-- transform/transform_test.go | 14 +++++++------- unicode/cldr/collate_test.go | 8 ++++---- unicode/norm/normalize_test.go | 5 ++--- width/transform_test.go | 2 +- 18 files changed, 35 insertions(+), 86 deletions(-) delete mode 100644 internal/testtext/go1_6.go delete mode 100644 internal/testtext/go1_7.go diff --git a/cases/context_test.go b/cases/context_test.go index eb4d69321..db84ca25f 100644 --- a/cases/context_test.go +++ b/cases/context_test.go @@ -9,7 +9,6 @@ import ( "testing" "unicode" - "golang.org/x/text/internal/testtext" "golang.org/x/text/language" "golang.org/x/text/transform" "golang.org/x/text/unicode/norm" @@ -214,7 +213,7 @@ func TestCCC(t *testing.T) { func TestWordBreaks(t *testing.T) { for _, tt := range breakTest { desc := norm.NFC.String(tt) - testtext.Run(t, desc, func(t *testing.T) { + t.Run(desc, func(t *testing.T) { parts := strings.Split(tt, "|") want := "" for _, s := range parts { diff --git a/cases/icu_test.go b/cases/icu_test.go index 6d9703501..2c5cdc0b4 100644 --- a/cases/icu_test.go +++ b/cases/icu_test.go @@ -11,7 +11,6 @@ import ( "strings" "testing" - "golang.org/x/text/internal/testtext" "golang.org/x/text/language" "golang.org/x/text/unicode/norm" ) @@ -83,7 +82,7 @@ func TestICUConformance(t *testing.T) { if exclude(c, tag, s) { continue } - testtext.Run(t, path.Join(c, tag, s), func(t *testing.T) { + t.Run(path.Join(c, tag, s), func(t *testing.T) { want := doICU(tag, c, s) got := doGo(tag, c, s) if norm.NFC.String(got) != norm.NFC.String(want) { diff --git a/cases/map_test.go b/cases/map_test.go index 8cfb89e59..bea6c085f 100644 --- a/cases/map_test.go +++ b/cases/map_test.go @@ -205,7 +205,7 @@ func TestAlloc(t *testing.T) { // func() Caser { return Title(language.Und) }, // func() Caser { return Title(language.Und, HandleFinalSigma(false)) }, } { - testtext.Run(t, "", func(t *testing.T) { + t.Run("", func(t *testing.T) { var c Caser v := testtext.AllocsPerRun(10, func() { c = f() @@ -234,7 +234,7 @@ func testHandover(t *testing.T, c Caser, src string) { // Test handover for each substring of the prefix. for i := 0; i < pSrc; i++ { - testtext.Run(t, fmt.Sprint("interleave/", i), func(t *testing.T) { + t.Run(fmt.Sprint("interleave/", i), func(t *testing.T) { dst := make([]byte, 4*len(src)) c.Reset() nSpan, _ := c.Span([]byte(src[:i]), false) @@ -299,7 +299,7 @@ func TestHandover(t *testing.T) { "'", "n bietje", }} for _, tc := range testCases { - testtext.Run(t, tc.desc, func(t *testing.T) { + t.Run(tc.desc, func(t *testing.T) { src := tc.first + tc.second want := tc.t.String(src) tc.t.Reset() @@ -601,7 +601,7 @@ func init() { func TestShortBuffersAndOverflow(t *testing.T) { for i, tt := range bufferTests { - testtext.Run(t, tt.desc, func(t *testing.T) { + t.Run(tt.desc, func(t *testing.T) { buf := make([]byte, tt.dstSize) got := []byte{} var nSrc, nDst int @@ -827,7 +827,7 @@ func TestSpan(t *testing.T) { err: transform.ErrEndOfSpan, t: Title(language.Afrikaans), }} { - testtext.Run(t, tt.desc, func(t *testing.T) { + t.Run(tt.desc, func(t *testing.T) { for p := 0; p < len(tt.want); p += utf8.RuneLen([]rune(tt.src[p:])[0]) { tt.t.Reset() n, err := tt.t.Span([]byte(tt.src[:p]), false) @@ -901,7 +901,7 @@ func BenchmarkCasers(b *testing.B) { {"title", bytes.ToTitle}, {"upper", bytes.ToUpper}, } { - testtext.Bench(b, path.Join(s.name, "bytes", f.name), func(b *testing.B) { + b.Run(path.Join(s.name, "bytes", f.name), func(b *testing.B) { b.SetBytes(int64(len(src))) for i := 0; i < b.N; i++ { f.fn(src) @@ -921,7 +921,7 @@ func BenchmarkCasers(b *testing.B) { } { c := Caser{t.caser} dst := make([]byte, len(src)) - testtext.Bench(b, path.Join(s.name, t.name, "transform"), func(b *testing.B) { + b.Run(path.Join(s.name, t.name, "transform"), func(b *testing.B) { b.SetBytes(int64(len(src))) for i := 0; i < b.N; i++ { c.Reset() @@ -934,7 +934,7 @@ func BenchmarkCasers(b *testing.B) { continue } spanSrc := c.Bytes(src) - testtext.Bench(b, path.Join(s.name, t.name, "span"), func(b *testing.B) { + b.Run(path.Join(s.name, t.name, "span"), func(b *testing.B) { c.Reset() if n, _ := c.Span(spanSrc, true); n < len(spanSrc) { b.Fatalf("spanner is not recognizing text %q as done (at %d)", spanSrc, n) diff --git a/internal/export/idna/idna_test.go b/internal/export/idna/idna_test.go index a13b67348..543fe527b 100644 --- a/internal/export/idna/idna_test.go +++ b/internal/export/idna/idna_test.go @@ -81,7 +81,7 @@ func doTest(t *testing.T, f func(string) (string, error), name, input, want, err in = strings.Replace(in, `\U`, "#", -1) name = fmt.Sprintf("%s/%s/%s", name, in, test) - testtext.Run(t, name, func(t *testing.T) { + t.Run(name, func(t *testing.T) { got, err := f(input) if err != nil { diff --git a/internal/number/number_test.go b/internal/number/number_test.go index cbc28ab49..6fe81f790 100644 --- a/internal/number/number_test.go +++ b/internal/number/number_test.go @@ -8,7 +8,6 @@ import ( "fmt" "testing" - "golang.org/x/text/internal/testtext" "golang.org/x/text/language" ) @@ -93,7 +92,7 @@ func TestFormats(t *testing.T) { {"zgh", "#,##0 %", tagToPercent}, } for _, tc := range testCases { - testtext.Run(t, tc.lang, func(t *testing.T) { + t.Run(tc.lang, func(t *testing.T) { got := formatForLang(language.MustParse(tc.lang), tc.index) want, _ := ParsePattern(tc.pattern) if *got != *want { diff --git a/internal/testtext/go1_6.go b/internal/testtext/go1_6.go deleted file mode 100644 index d7b4947e4..000000000 --- a/internal/testtext/go1_6.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !go1.7 - -package testtext - -import "testing" - -func Run(t *testing.T, name string, fn func(t *testing.T)) bool { - t.Logf("Running %s...", name) - fn(t) - return t.Failed() -} - -// Bench runs the given benchmark function. This pre-1.7 implementation renders -// the measurement useless, but allows the code to be compiled at least. -func Bench(b *testing.B, name string, fn func(b *testing.B)) bool { - b.Logf("Running %s...", name) - fn(b) - return b.Failed() -} diff --git a/internal/testtext/go1_7.go b/internal/testtext/go1_7.go deleted file mode 100644 index 8153af67c..000000000 --- a/internal/testtext/go1_7.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build go1.7 - -package testtext - -import "testing" - -func Run(t *testing.T, name string, fn func(t *testing.T)) bool { - return t.Run(name, fn) -} - -func Bench(b *testing.B, name string, fn func(b *testing.B)) bool { - return b.Run(name, fn) -} diff --git a/language/display/display_test.go b/language/display/display_test.go index f26bace14..94a1cfce1 100644 --- a/language/display/display_test.go +++ b/language/display/display_test.go @@ -11,7 +11,6 @@ import ( "testing" "unicode" - "golang.org/x/text/internal/testtext" "golang.org/x/text/language" "golang.org/x/text/message" ) @@ -40,7 +39,7 @@ func TestValues(t *testing.T) { // checkDefined checks that a value exists in a Namer. checkDefined := func(x interface{}, namers []testcase) { for _, n := range namers { - testtext.Run(t, fmt.Sprintf("%s.Name(%s)", n.kind, x), func(t *testing.T) { + t.Run(fmt.Sprintf("%s.Name(%s)", n.kind, x), func(t *testing.T) { if n.n.Name(x) == "" { // As of version 28 there is no data for az-Arab in English, // although there is useful data in other languages. @@ -449,7 +448,7 @@ func TestLanguage(t *testing.T) { {"en", "sr-Latn-ME", "Serbo-Croatian"}, // See comments in TestTag. } for _, tt := range tests { - testtext.Run(t, tt.dict+"/"+tt.tag, func(t *testing.T) { + t.Run(tt.dict+"/"+tt.tag, func(t *testing.T) { name, fmtName := splitName(tt.name) dict := language.MustParse(tt.dict) tag := language.Raw.MustParse(tt.tag) diff --git a/runes/runes_test.go b/runes/runes_test.go index 23c5bc952..b5d8c6e1d 100644 --- a/runes/runes_test.go +++ b/runes/runes_test.go @@ -626,7 +626,7 @@ func doBench(b *testing.B, t Transformer) { dst := make([]byte, 2*len(bc.data)) src := []byte(bc.data) - testtext.Bench(b, bc.name+"/transform", func(b *testing.B) { + b.Run(bc.name+"/transform", func(b *testing.B) { b.SetBytes(int64(len(src))) for i := 0; i < b.N; i++ { t.Transform(dst, src, true) @@ -634,7 +634,7 @@ func doBench(b *testing.B, t Transformer) { }) src = t.Bytes(src) t.Reset() - testtext.Bench(b, bc.name+"/span", func(b *testing.B) { + b.Run(bc.name+"/span", func(b *testing.B) { b.SetBytes(int64(len(src))) for i := 0; i < b.N; i++ { t.Span(src, true) diff --git a/secure/bidirule/bench_test.go b/secure/bidirule/bench_test.go index 2db922bfd..34ed5b8e8 100644 --- a/secure/bidirule/bench_test.go +++ b/secure/bidirule/bench_test.go @@ -6,8 +6,6 @@ package bidirule import ( "testing" - - "golang.org/x/text/internal/testtext" ) var benchData = []struct{ name, data string }{ @@ -18,7 +16,7 @@ var benchData = []struct{ name, data string }{ func doBench(b *testing.B, fn func(b *testing.B, data string)) { for _, d := range benchData { - testtext.Bench(b, d.name, func(b *testing.B) { fn(b, d.data) }) + b.Run(d.name, func(b *testing.B) { fn(b, d.data) }) } } diff --git a/secure/bidirule/bidirule_test.go b/secure/bidirule/bidirule_test.go index e1bc11cef..e797eba3b 100644 --- a/secure/bidirule/bidirule_test.go +++ b/secure/bidirule/bidirule_test.go @@ -8,7 +8,6 @@ import ( "fmt" "testing" - "golang.org/x/text/internal/testtext" "golang.org/x/text/unicode/bidi" "golang.org/x/text/unicode/norm" ) @@ -57,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:%[3]s", rule, i, norm.NFC.String(tc.in)) - testtext.Run(t, name, func(t *testing.T) { + t.Run(name, func(t *testing.T) { fn(t, tc) }) } diff --git a/secure/precis/benchmark_test.go b/secure/precis/benchmark_test.go index 4abebd85b..f8d05ae5d 100644 --- a/secure/precis/benchmark_test.go +++ b/secure/precis/benchmark_test.go @@ -8,8 +8,6 @@ package precis import ( "testing" - - "golang.org/x/text/internal/testtext" ) var benchData = []struct{ name, str string }{ @@ -33,7 +31,7 @@ var benchProfiles = []struct { func doBench(b *testing.B, f func(b *testing.B, p *Profile, s string)) { for _, bp := range benchProfiles { for _, d := range benchData { - testtext.Bench(b, bp.name+"/"+d.name, func(b *testing.B) { + b.Run(bp.name+"/"+d.name, func(b *testing.B) { f(b, bp.p, d.str) }) } diff --git a/secure/precis/enforce_test.go b/secure/precis/enforce_test.go index ac2aad2c6..0ced110a9 100644 --- a/secure/precis/enforce_test.go +++ b/secure/precis/enforce_test.go @@ -24,7 +24,7 @@ func doTests(t *testing.T, fn func(t *testing.T, p *Profile, tc testCase)) { for _, g := range enforceTestCases { for i, tc := range g.cases { name := fmt.Sprintf("%s:%d:%+q", g.name, i, tc.input) - testtext.Run(t, name, func(t *testing.T) { + t.Run(name, func(t *testing.T) { fn(t, g.p, tc) }) } diff --git a/secure/precis/profile_test.go b/secure/precis/profile_test.go index 4edb28a76..cf922a7a6 100644 --- a/secure/precis/profile_test.go +++ b/secure/precis/profile_test.go @@ -10,7 +10,6 @@ import ( "testing" "unicode" - "golang.org/x/text/internal/testtext" "golang.org/x/text/transform" ) @@ -114,7 +113,7 @@ func doCompareTests(t *testing.T, fn func(t *testing.T, p *Profile, tc compareTe for _, g := range compareTestCases { for i, tc := range g.cases { name := fmt.Sprintf("%s:%d:%+q", g.name, i, tc.a) - testtext.Run(t, name, func(t *testing.T) { + t.Run(name, func(t *testing.T) { fn(t, g.p, tc) }) } diff --git a/transform/transform_test.go b/transform/transform_test.go index 62fad2bc9..1ce36c812 100644 --- a/transform/transform_test.go +++ b/transform/transform_test.go @@ -642,7 +642,7 @@ var testCases = []testCase{ func TestReader(t *testing.T) { for _, tc := range testCases { - testtext.Run(t, tc.desc, func(t *testing.T) { + t.Run(tc.desc, func(t *testing.T) { r := NewReader(strings.NewReader(tc.src), tc.t) // Differently sized dst and src buffers are not part of the // exported API. We override them manually. @@ -665,7 +665,7 @@ func TestWriter(t *testing.T) { sizes = []int{tc.ioSize} } for _, sz := range sizes { - testtext.Run(t, fmt.Sprintf("%s/%d", tc.desc, sz), func(t *testing.T) { + t.Run(fmt.Sprintf("%s/%d", tc.desc, sz), func(t *testing.T) { bb := &bytes.Buffer{} w := NewWriter(bb, tc.t) // Differently sized dst and src buffers are not part of the @@ -1149,7 +1149,7 @@ func testString(t *testing.T, f func(Transformer, string) (string, int, error)) // The result string will be different. continue } - testtext.Run(t, tt.desc, func(t *testing.T) { + t.Run(tt.desc, func(t *testing.T) { got, n, err := f(tt.t, tt.src) if tt.wantErr != err { t.Errorf("error: got %v; want %v", err, tt.wantErr) @@ -1193,7 +1193,7 @@ func TestAppend(t *testing.T) { } func TestString(t *testing.T) { - testtext.Run(t, "transform", func(t *testing.T) { testString(t, String) }) + t.Run("transform", func(t *testing.T) { testString(t, String) }) // Overrun the internal destination buffer. for i, s := range []string{ @@ -1211,7 +1211,7 @@ func TestString(t *testing.T) { aaa[:1*initialBufSize+0] + "A", aaa[:1*initialBufSize+1] + "A", } { - testtext.Run(t, fmt.Sprint("dst buffer test using lower/", i), func(t *testing.T) { + t.Run(fmt.Sprint("dst buffer test using lower/", i), func(t *testing.T) { got, _, _ := String(lowerCaseASCII{}, s) if want := strings.ToLower(s); got != want { t.Errorf("got %s (%d); want %s (%d)", got, len(got), want, len(want)) @@ -1228,7 +1228,7 @@ func TestString(t *testing.T) { aaa[:2*initialBufSize+0], aaa[:2*initialBufSize+1], } { - testtext.Run(t, fmt.Sprint("src buffer test using rleEncode/", i), func(t *testing.T) { + t.Run(fmt.Sprint("src buffer test using rleEncode/", i), func(t *testing.T) { got, _, _ := String(rleEncode{}, s) if want := fmt.Sprintf("%da", len(s)); got != want { t.Errorf("got %s (%d); want %s (%d)", got, len(got), want, len(want)) @@ -1246,7 +1246,7 @@ func TestString(t *testing.T) { aaa[:initialBufSize+1], aaa[:10*initialBufSize], } { - testtext.Run(t, fmt.Sprint("alloc/", i), func(t *testing.T) { + t.Run(fmt.Sprint("alloc/", i), func(t *testing.T) { if n := testtext.AllocsPerRun(5, func() { String(&lowerCaseASCIILookahead{}, s) }); n > 1 { t.Errorf("#allocs was %f; want 1", n) } diff --git a/unicode/cldr/collate_test.go b/unicode/cldr/collate_test.go index f6721639a..e5237416b 100644 --- a/unicode/cldr/collate_test.go +++ b/unicode/cldr/collate_test.go @@ -164,13 +164,13 @@ func TestRuleProcessor(t *testing.T) { }, { desc: "err empty anchor", - in: " & ", - out: "E:1: missing string", + in: " & ", + out: "E:1: missing string", }, { desc: "err anchor invalid special 1", - in: " & [ foo ", - out: "E:1: unmatched bracket", + in: " & [ foo ", + out: "E:1: unmatched bracket", }, { desc: "err anchor invalid special 2", diff --git a/unicode/norm/normalize_test.go b/unicode/norm/normalize_test.go index 678ca403d..855e7b595 100644 --- a/unicode/norm/normalize_test.go +++ b/unicode/norm/normalize_test.go @@ -18,7 +18,6 @@ import ( "testing" "unicode/utf8" - "golang.org/x/text/internal/testtext" "golang.org/x/text/transform" ) @@ -467,7 +466,7 @@ var quickSpanNFCTests = []spanTest{ func runSpanTests(t *testing.T, name string, f Form, testCases []spanTest) { for i, tc := range testCases { s := fmt.Sprintf("Bytes/%s/%d=%+q/atEOF=%v", name, i, pc(tc.input), tc.atEOF) - ok := testtext.Run(t, s, func(t *testing.T) { + ok := t.Run(s, func(t *testing.T) { n, err := f.Span([]byte(tc.input), tc.atEOF) if n != tc.n || err != tc.err { t.Errorf("\n got %d, %v;\nwant %d, %v", n, err, tc.n, tc.err) @@ -477,7 +476,7 @@ func runSpanTests(t *testing.T, name string, f Form, testCases []spanTest) { continue // Don't do the String variant if the Bytes variant failed. } s = fmt.Sprintf("String/%s/%d=%+q/atEOF=%v", name, i, pc(tc.input), tc.atEOF) - testtext.Run(t, s, func(t *testing.T) { + t.Run(s, func(t *testing.T) { n, err := f.SpanString(tc.input, tc.atEOF) if n != tc.n || err != tc.err { t.Errorf("\n got %d, %v;\nwant %d, %v", n, err, tc.n, tc.err) diff --git a/width/transform_test.go b/width/transform_test.go index f9122d6db..f14c7c66d 100644 --- a/width/transform_test.go +++ b/width/transform_test.go @@ -65,7 +65,7 @@ type transformTest struct { } func (tc *transformTest) doTest(t *testing.T, tr Transformer) { - testtext.Run(t, tc.desc, func(t *testing.T) { + t.Run(tc.desc, func(t *testing.T) { b := make([]byte, tc.nBuf) nDst, nSrc, err := tr.Transform(b, []byte(tc.src), tc.atEOF) if got := string(b[:nDst]); got != tc.dst[:nDst] { From 8a0e65e7b4f02a20d3127cd6960cdf11941d2ad4 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 31 Oct 2024 15:46:39 -0700 Subject: [PATCH 3/4] README: don't recommend go get These days people will just import the packages and the go tool will do the right thing. We don't need to explain it. Add a pointer to the git repo, though. For golang/go#62645 Change-Id: I0a1721eb456645c1422580497e3dcc9906a41223 Reviewed-on: https://go-review.googlesource.com/c/text/+/624296 Auto-Submit: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Commit-Queue: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Reviewed-by: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov --- README.md | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2f0c20fc9..c77f322ee 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ [![Go Reference](https://pkg.go.dev/badge/golang.org/x/text.svg)](https://pkg.go.dev/golang.org/x/text) -This repository holds supplementary Go libraries for text processing, many involving Unicode. +This repository holds supplementary Go packages for text processing, +many involving Unicode. ## CLDR Versioning @@ -11,13 +12,11 @@ by your Go compiler. The `x/text` repository supports multiple versions of Unicode and will match the version of Unicode to that of the Go compiler. At the moment this is supported for Go compilers from version 1.7. -## Download/Install +## Contribute -The easiest way to install is to run `go get -u golang.org/x/text`. You can -also manually git clone the repository to `$GOPATH/src/golang.org/x/text`. +To submit changes to this repository, see http://go.dev/doc/contribute. -## Contribute -To submit changes to this repository, see http://golang.org/doc/contribute.html. +The git repository is https://go.googlesource.com/text. To generate the tables in this repository (except for the encoding tables), run go generate from this directory. By default tables are generated for the @@ -29,6 +28,7 @@ directory, which holds all files that are used as a source for generating the tables. This directory will also serve as a cache. ## Testing + Run go test ./... @@ -52,6 +52,7 @@ directory which holds all files that are used as a source for generating the tables. This directory will also serve as a cache. ## Versions + To update a Unicode version run UNICODE_VERSION=x.x.x go generate @@ -73,11 +74,8 @@ So updating to a different version may not work. The files in DATA/{iana|icu|w3|whatwg} are currently not versioned. -## Report Issues / Send Patches - -This repository uses Gerrit for code changes. To learn how to submit changes to -this repository, see https://golang.org/doc/contribute.html. +## Report Issues -The main issue tracker for the image repository is located at -https://github.com/golang/go/issues. Prefix your issue with "x/text:" in the +The main issue tracker for the text repository is located at +https://go.dev/issues. Prefix your issue with "x/text:" in the subject line, so it is easy to find. From efd25daf282ae4d20d3625f1ccb4452fe40967ae Mon Sep 17 00:00:00 2001 From: Gopher Robot Date: Thu, 7 Nov 2024 21:07:52 +0000 Subject: [PATCH 4/4] go.mod: update golang.org/x dependencies Update golang.org/x dependencies to their latest tagged versions. Change-Id: I6b939f9a4f016b265d30fbd408f34705f89c0982 Reviewed-on: https://go-review.googlesource.com/c/text/+/626375 Reviewed-by: Dmitri Shuralyov Reviewed-by: David Chase Auto-Submit: Gopher Robot LUCI-TryBot-Result: Go LUCI --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d63758175..923796718 100644 --- a/go.mod +++ b/go.mod @@ -6,4 +6,4 @@ require golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // tagx:ignore require golang.org/x/mod v0.17.0 // indirect; tagx:ignore -require golang.org/x/sync v0.8.0 // indirect +require golang.org/x/sync v0.9.0 // indirect diff --git a/go.sum b/go.sum index 8fe49db44..ceec7e868 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=