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

The test adapter should ignore underscored packages #2908

Open
firelizzard18 opened this issue Aug 2, 2023 · 4 comments
Open

The test adapter should ignore underscored packages #2908

firelizzard18 opened this issue Aug 2, 2023 · 4 comments
Labels
go-test issues related to go test support (test output, test explorer, ...) NeedsFix The path to resolution is known, but the work has not been done.

Comments

@firelizzard18
Copy link
Contributor

Given the following project:

  • go.mod
  • foo
    • foo_test.go
  • _bar
    • bar_test.go

If I run go test ./..., the underscored package (_bar) is skipped. I can run those tests by running go test ./_bar so they're not completely disabled, but ... evidently does not resolve underscored packages.

However the test resolver does resolve underscored packages. I think it's OK for underscored packages to appear in the test explorer, since Go does let you build/test those packages, but they should be skipped when running all tests. Though maybe there should be a setting to control whether they're resolved at all. If they are resolved but skipped, that would need to be handled by GoTestRunner.run IIRC. This issue is reproduced by this project.

$ go list ./...
underscore-test/foo

image

image
@gopherbot gopherbot added this to the Untriaged milestone Aug 2, 2023
@firelizzard18
Copy link
Contributor Author

@hyangah do you have an opinion on whether underscored packages should be completely ignored (excluded by the resolver) or simply skipped if they're not explicitly selected, like benchmarks?

@hyangah
Copy link
Contributor

hyangah commented Aug 2, 2023

Surprised to learn that go test ./_bar works. I wonder how common this type of
project structure is common.

Files whose names begin with "_" or "." are ignored
according to https://pkg.go.dev/cmd/go#hdr-Test_packages
and many people depend on this to avoid unnecessary scanning.
I am inclined to align with the go's behavior and skip _ or . prefixed
directories. (testdata too).

@firelizzard18
Copy link
Contributor Author

In my case there was some old code I wanted to continue referencing but not maintaining, so I underscored it. I discovered this issue because another developer used "Run all tests" and a test failed (and apparently the package still builds). I've done this a few other times, but in every case my assumption was that it would be totally ignored given that gopls and go build ignored it.

@suzmue suzmue added NeedsFix The path to resolution is known, but the work has not been done. go-test issues related to go test support (test output, test explorer, ...) labels Aug 3, 2023
@suzmue suzmue modified the milestones: Untriaged, vscode-go/later Aug 3, 2023
@firelizzard18
Copy link
Contributor Author

If this is still a problem after #3523, it needs to be fixed in gopls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go-test issues related to go test support (test output, test explorer, ...) NeedsFix The path to resolution is known, but the work has not been done.
Projects
Status: No status
Development

No branches or pull requests

4 participants