Skip to content

x/text: vet errors in example tests causing builds to fail #68967

@millerresearch

Description

@millerresearch

Go version

gotip on all platforms

Output of go env in your module/workspace:

"HOSTNAME=buildlet-linux-amd64-bookworm-rnf4eba85" "HOME=/root" "SHLVL=0" "DEBIAN_FRONTEND=noninteractive" "USER=root" "GO_STAGE0_NET_DELAY=15.1s" "GO_STAGE0_DL_DELAY=200ms" "WORKDIR=/workdir" "GOROOT_BOOTSTRAP=/workdir/go1.4" "GO_BUILDER_NAME=linux-amd64-bookworm" "GOROOT=/workdir/go" "GOPATH=/workdir/gopath" "GOPROXY=https://proxy.golang.org" "GO_DISABLE_OUTBOUND_NETWORK=0" "TMPDIR=/workdir/tmp" "GOCACHE=/workdir/gocache" "GOPLSCACHE=/workdir/goplscache" "PATH=/workdir/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" "PWD=/workdir/gopath/src/golang.org/x/text"

What did you do?

Builds running both on LUCI and coordinator, for example this one.

What did you see happen?

...
# golang.org/x/text/encoding_test
# [golang.org/x/text/encoding_test]
encoding/example_test.go:19:1: ExampleDecodeWindows1252 refers to unknown identifier: DecodeWindows1252
...
# golang.org/x/text/collate_test
# [golang.org/x/text/collate_test]
collate/sort_test.go:15:1: ExampleCollator_Strings refers to unknown field or method: Collator.Strings
FAIL	golang.org/x/text/collate [build failed]
?   	golang.org/x/text/collate/tools/colcmp	[no test files]
FAIL	golang.org/x/text/encoding [build failed]
...
# golang.org/x/text/feature/plural_test
# [golang.org/x/text/feature/plural_test]
feature/plural/example_test.go:13:1: ExampleSelect refers to unknown identifier: Select
FAIL	golang.org/x/text/feature/plural [build failed]

What did you expect to see?

Expected successful build.

The cause is vet errors from declaration of Example test functions which do not obey the convention described by go help testfunc:

Godoc displays the body of ExampleXxx to demonstrate the use of the function, constant, or variable Xxx.

For example in x/text/encoding/example_test.go, the funtion ExampleDecodeWindows1252 is declared, but there's no corresponding identifier DecodeWindows1252 declared in the package. A simple way to fix the error would be to rename ExampleDecodeWindows1252 to Example_decodeWindows1252.

This is similar to issue #68839

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions