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: don't make "build constraints exclude all Go files" a fatal error for go test #43424

Closed
josharian opened this issue Dec 30, 2020 · 2 comments
Labels
FrozenDueToAge GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@josharian
Copy link
Contributor

I would like to run all the tests for a module I'm working on. Usually I would do that with go test ./... Unfortunately, one of the packages is windows-only. go test ./... dies immediately with:

package path/to/the/package
	imports golang.org/x/sys/windows: build constraints exclude all Go files in /Users/josh/pkg/mod/golang.org/x/sys@v0.0.0-20201218084310-7d0127a74742/windows

It doesn't run any of the tests in any of the packages. I'd prefer if go test ./... informed me that it couldn't test the package in question, but continued to run the tests for the rest of the packages.

cc @bcmills @jayconrod

As a workaround, @alexbrainman @bradfitz are you OK with me adding a non-windows stub file to golang.org/x/sys/windows?

@dmitshur dmitshur added GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Dec 30, 2020
@dmitshur dmitshur added this to the Backlog milestone Dec 30, 2020
@dmitshur
Copy link
Contributor

dmitshur commented Dec 30, 2020

Unfortunately, one of the packages is windows-only. go test ./... dies immediately

If that package is windows-only, it wouldn't be picked up by the ./... pattern. Maybe one of its files is missing // +build windows constraints?

For example, on darwin/amd64, I can successfully run go test ./... at the root of the golang.org/x/sys module.

I think it's better to avoid adding non-windows stub files to a windows-only package, as that makes the package build on non-windows OSes but have a different API.

Edit: Also see the "Syscall must always be guarded with build tags." proverb. It applies to x/sys for the same reason, as I understand it.

@josharian
Copy link
Contributor Author

Arg. I got foiled again by the build tag syntax. Thank goodness the overhaul is happening soon. Sigh. Thanks.

@golang golang locked and limited conversation to collaborators Dec 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants