Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: make -coverpkg properly ignore special directories #66171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on May 28, 2024

  1. cmd/go: fix -coverpkg not ignoring special directories

    The pattern passed to `-coverpkg` when running `go test` would not
    ignore directories usually ignored by the `go` command, i.e. those
    beginning with "." or "_" are ignored by the go tool, as are directories
    named "testdata".
    
    Fix this by adding an explicit check for these (by following a similar
    check in `src/cmd/doc/dirs.go`[1]) allowing us to ignore them. The
    scope of the change is limted to package matching to only the -coverpkg
    flag of `go test` to avoid impacting -gcflags and the other per package
    flags, e.g. we don't want to change behaviour for a user building
    something that imports a leading dot package who wants to set gcflags
    for it
    
    Two tests are added for this change, one is a regression test attempting
    to directly replicate the behaviour described in the issue, the other is
    updating another test I saw fail when trialling other solutions to this
    issue so I thought it worthwhile to be explicit about the change there.
    
    See linked issue for a reproduction.
    
    Fixes golang#66038
    
    [1] https://go.googlesource.com/go/+/16e5d24480dca7ddcbdffb78a8ed5de3e5155dec/src/cmd/doc/dirs.go#136
    matthewhughes934 committed May 28, 2024
    Configuration menu
    Copy the full SHA
    f48bd17 View commit details
    Browse the repository at this point in the history