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: go build fails on directory with only test files (behavior change from 1.2) #8279

Closed
pmezard opened this issue Jun 24, 2014 · 5 comments

Comments

@pmezard
Copy link
Contributor

pmezard commented Jun 24, 2014

What does 'go version' print?

go version go1.3 windows/amd64

What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.

In a working Go environment:

  $ mkdir src/somedir/dummy
  $ echo "package dummy" > src/somedir/dummy/dummy_test.go
  $ go build somedir/...
  go build somedir/dummy: no buildable Go source files in /path/to/somedir/dummy
  $ echo $?
  1

There are other valid packages under somedir/

What should have happened instead?

In go 1.2, the build was successful. A simple workaround is to add a dummy non-test file
in the package.

Since it broke our build and I cannot see it mentioned in the release notes I wondered
if the change was intentional. And if so, I was curious to know why.
@gopherbot
Copy link

Comment 1 by dsavints:

I was bitten by this as well (on Mac and Linux) - it broke the build scripts that were
working with 1.2.  I used subdirectories with only *_test.go files to organize
functional tests and keep them separately from the main .go source files and unit tests.
 It would be great to make "go build" and "go install" to skip the directories with only
_test.go files so that <pkgdir>/... invocation could work as before.
Adding a dummy.go file (with only "package <packagename>" line) works but it feels
like a rather non-elegant workaround.

@gopherbot
Copy link

Comment 2 by dsavints:

A better workaround is to use build tags - something like
// +build functional
which allows go install to proceed without a failure, and then you can still run "go
test -tags functional <pkgname>/... " (or give explicity file name[s] to go test)

@minux
Copy link
Member

minux commented Jun 25, 2014

Comment 3:

see also issue #7915.
probably we just need to document in go1.3.html.

Labels changed: added release-go1.4, repo-main.

Status changed to Thinking.

@rsc
Copy link
Contributor

rsc commented Sep 15, 2014

Comment 4:

Labels changed: added release-go1.5, removed release-go1.4.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
otiai10 added a commit to otiai10/gosseract that referenced this issue Mar 26, 2015
@rsc rsc removed the repo-main label Apr 14, 2015
@rsc
Copy link
Contributor

rsc commented Jul 14, 2015

This is difficult to support nicely, because it's hard to
distinguish "no Go source files" from "no Go source files
due to build tags excluding them all", and you do want
to behave differently in those cases.
But then a directory with just a "// +build ignore" file
is kind of a mix of both.

Since we've been living with this since 1.3, I think it is
fine to keep living with.

@rsc rsc closed this as completed Jul 14, 2015
tommie added a commit to tommie/acme-cli that referenced this issue Jan 17, 2016
tommie added a commit to tommie/acme-cli that referenced this issue Jan 17, 2016
@golang golang locked and limited conversation to collaborators Jul 13, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants