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

Conversation

matthewhughes934
Copy link

@matthewhughes934 matthewhughes934 commented Mar 7, 2024

This change fixes "go test -coverpkg" to properly ignore
special directories that are typically ignored by the "go" command
for example directories beginnning with "." or "_" or "testdata"

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 trialing other solutions to this
issue so I thought it worthwhile to be explicit about the change there.

Fixes #66038

@gopherbot
Copy link

This PR (HEAD: 63eb9f4) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/569895.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Gopher Robot:

Patch Set 1:

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.

During May-July and Nov-Jan the Go project is in a code freeze, during which
little code gets reviewed or merged. If a reviewer responds with a comment like
R=go1.11 or adds a tag like "wait-release", it means that this CL will be
reviewed as part of the next development cycle. See https://go.dev/s/release
for more details.


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Than McIntosh:

Patch Set 1:

(4 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Than McIntosh:

Patch Set 1: Commit-Queue+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 1:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2024-03-07T20:26:10Z","revision":"d5dac6a21a14a19b1eb45dfacf35bdc8488894bc"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Than McIntosh:

Patch Set 1: -Commit-Queue


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 1:

This CL has failed the run. Reason:

Tryjob golang/try/x_tools-gotip-linux-amd64 has failed with summary (view all results):


FAILURE

Error:
failed to run "test golang.org/x/tools module": exit status 1
failed to run "test golang.org/x/tools/gopls module": exit status 1

Links:


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 1: LUCI-TryBot-Result-1


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@matthewhughes934 matthewhughes934 force-pushed the fix-coverpkg-not-ignoring-special-directories branch from 63eb9f4 to 9396509 Compare March 7, 2024 20:50
@gopherbot
Copy link

Message from Matthew Hughes:

Patch Set 1:

(4 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Matthew Hughes:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

This PR (HEAD: 9396509) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/569895.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link

Message from Than McIntosh:

Patch Set 2: Commit-Queue+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 2:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2024-03-07T20:57:14Z","revision":"88466b937d61663e96ed462c4b285d1f36287a49"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 2: LUCI-TryBot-Result-1


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Than McIntosh:

Patch Set 3:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Emmanuel Odeke:

Patch Set 3: Hold+1

(4 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@matthewhughes934 matthewhughes934 changed the title cmd/go: fix -coverpkg not ignoring special directories cmd/go: make -coverpkg properly ignore special directories Mar 8, 2024
@gopherbot
Copy link

This PR (HEAD: 4ba4bea) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/569895.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link

Message from Matthew Hughes:

Patch Set 4:

(5 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Emmanuel Odeke:

Patch Set 4: -Hold Code-Review+1 Commit-Queue+1 Run-TryBot+1

(3 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 4:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2024-03-19T18:58:12Z","revision":"4f35b335166bbf175ec73f9b1b1f0e54251f0fd9"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Gopher Robot:

Patch Set 4:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@matthewhughes934 matthewhughes934 force-pushed the fix-coverpkg-not-ignoring-special-directories branch from 4ba4bea to 7093c8e Compare March 19, 2024 19:16
@gopherbot
Copy link

Message from Matthew Hughes:

Patch Set 4:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

This PR (HEAD: 7093c8e) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/569895.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link

Message from Gopher Robot:

Patch Set 4:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Gopher Robot:

Patch Set 4: TryBot-Result-1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 5:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2024-03-19T20:12:53Z","revision":"9946d047e78efdf1a6387157745ddbb8ef8d8d6f"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Than McIntosh:

Patch Set 5: -Commit-Queue


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 5:

This CL has passed the run


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 5: LUCI-TryBot-Result+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@matthewhughes934 matthewhughes934 force-pushed the fix-coverpkg-not-ignoring-special-directories branch from 7093c8e to ee689e7 Compare March 24, 2024 21:20
@gopherbot
Copy link

This PR (HEAD: ee689e7) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/569895.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link

Message from Matthew Hughes:

Patch Set 5:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Emmanuel Odeke:

Patch Set 6: Code-Review+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

This PR (HEAD: 29c8bd9) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/569895.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link

Message from Matthew Hughes:

Patch Set 6:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Emmanuel Odeke:

Patch Set 7: Code-Review+1 Commit-Queue+1 Run-TryBot+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 7:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2024-03-24T23:24:53Z","revision":"64b6014edf67e7c3c4e19511f628a30f5a17298e"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Gopher Robot:

Patch Set 7:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Emmanuel Odeke:

Patch Set 7: -Commit-Queue


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 7:

This CL has failed the run. Reason:

Tryjob golang/try/gotip-linux-386 has failed with summary (view all results):


FAILURE

Tests failed. See all test results.

Error:
shard 1: failed to run "go tool dist test -json": exit status 1

Links:


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Gopher Robot:

Patch Set 7: TryBot-Result+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 7: LUCI-TryBot-Result-1


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Michael Matloob:

Patch Set 7:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Matthew Hughes:

Patch Set 7:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@matthewhughes934 matthewhughes934 force-pushed the fix-coverpkg-not-ignoring-special-directories branch from 29c8bd9 to 84888c7 Compare April 11, 2024 19:11
@gopherbot
Copy link

This PR (HEAD: 84888c7) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/569895.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

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 matthewhughes934 force-pushed the fix-coverpkg-not-ignoring-special-directories branch from 84888c7 to 09944b0 Compare April 11, 2024 19:15
@gopherbot
Copy link

This PR (HEAD: 09944b0) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/569895.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link

Message from Matthew Hughes:

Patch Set 9:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Than McIntosh:

Patch Set 9: Commit-Queue+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 9:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2024-04-15T12:49:58Z","revision":"dfc007b2baa838f2713d400bc183480a81b2d778"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Than McIntosh:

Patch Set 9: -Commit-Queue


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 9:

This CL has passed the run


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 9: LUCI-TryBot-Result+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/569895.
After addressing review feedback, remember to publish your drafts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cmd/go: coverpkg doesn't ignore directories starting with '.'
2 participants