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

MismatchedPkgName with external test package and GOPACKAGESDRIVER #3273

Closed
dt opened this issue Aug 18, 2022 · 3 comments
Closed

MismatchedPkgName with external test package and GOPACKAGESDRIVER #3273

dt opened this issue Aug 18, 2022 · 3 comments

Comments

@dt
Copy link

dt commented Aug 18, 2022

What version of rules_go are you using?

v0.34.0

What version of gazelle are you using?

v0.26.0

What version of Bazel are you using?

5.2.0

Does this issue reproduce with the latest releases of all the above?

These are the latest.

What operating system and processor architecture are you using?

macOS 12.5 Arm M1 Pro

Any other potentially useful information about your toolchain?

n/a

What did you do?

I have a ready-to-run minimal reproduction at https://github.com/dt/externdemo, but essentially it is:

  • a directory containing foo.go, foo_test.go and foo_test_external.go, where the first two of those declare package foo while the last has package foo_test,
  • a gazelle-generated BUILD file for those files, which defines the expected go_library and a go_test targets, for foo.go and the two _test.go files, respectively,
  • a bin/gopackagesdriver.sh, script which is a thin launcher for @io_bazel_rules_go//go/tools/gopackagesdriver ,
  • a VSCode settings file pointing GOPACKAGESDRIVER at said launcher,
  • ... and of course a basic WORKSPACE file to set up latest rules_go and gazelle.

I then launched VSCode in this repo.

What did you expect to see?

bazel-powered gopls providing highlighting and analysis, including in foo_external_test.go.

What did you see instead?

package foo_test; expected foo (MismatchedPkgName) on line 1 of foo_external_test.go

@dt dt changed the title MismatchedPkgName with external test package MismatchedPkgName with external test package and GOPACKAGESDRIVER Aug 18, 2022
@dt
Copy link
Author

dt commented Sep 7, 2022

This looks very similar to the closed issue #3015, but that was marked as fixed by @illicitonion and @linzhp in #3116, which is in v0.34.0, which is what I am using in my reproduction repo above, so maybe this one is distinct?

@JamyDev
Copy link
Contributor

JamyDev commented Dec 7, 2023

This should be resolved in #3750 and #3777, however I would recommend even your external tests to still end in _test.go for this to work properly.

@dt
Copy link
Author

dt commented Dec 8, 2023

Yep, I can confirm that in the minimal reproduction repro I linked in the issue, if I bump rules_go to use git_repository and commit 37ba8d5, the error no longer reproduces. Thanks so much for fixing this!

@dt dt closed this as completed Dec 8, 2023
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

No branches or pull requests

2 participants