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: document that files beginning with . or _ are ignored #5655

Closed
gopherbot opened this issue Jun 6, 2013 · 8 comments
Closed

cmd/go: document that files beginning with . or _ are ignored #5655

gopherbot opened this issue Jun 6, 2013 · 8 comments

Comments

@gopherbot
Copy link

gopherbot commented Jun 6, 2013

by timbray:

"go help test" says...

>'Go test' recompiles each package along with any files with names matching
>the file pattern "*_test.go".

http://golang.org/doc/code.html#Testing says...

>You write a test by creating a file with a name ending in _test.go

However, if the filename is just _test.go it won't run that.  This is unfortunate,
because if I have a directory full of *.go files making up a package, having the tests
in _test.go would be set apart visually in the directory listing.

I think the documentation is correct and the "testing" package is wrong.

Which version are you using?  (run 'go version') Observed in both "go1.0.3
(appengine-1.8.0)" and "version go1.1 darwin/amd64"
@robpike
Copy link
Contributor

robpike commented Jun 6, 2013

Comment 1:

We use all_test.go as a rule, which has similar properties, but if there is an
inconsistency between behavior and documentation one should be fixed.

Labels changed: added priority-later, removed priority-triage.

Status changed to Accepted.

@minux
Copy link
Member

minux commented Jun 12, 2013

Comment 2:

This issue was closed by revision da634dd.

Status changed to Fixed.

@gopherbot
Copy link
Author

gopherbot commented Jun 16, 2013

Comment 3 by timbray:

Excuse me?!  If I read the diffs correctly, you just changed  the docs to say “ends
with _test.go”.  Well, the filename _test.go also ends with “_test.go”, so this
fix is a no-op.
If you’re determined to just change the documentation you have to sa y “ends with
_test.go but with one or more characters preceding the _”  Which, if I were writing
it, would make me ask “why does this artificial restriction exist?”

@adg
Copy link
Contributor

adg commented Jun 19, 2013

Comment 4:

You're right, this is a non-fix.
I've dug into it. We don't explicitly ignore files named "_test.go", but the build
infrastructure does explicitly ignore any file that begins with a dot or an underscore.
So the docs are technically correct by omission. :P
So, the cmd/go docs need to be updated to mention that files beginning with . and _ are
ignored.
The go/build package docs do mention it, though:
http://golang.org/pkg/go/build/#Context.Import

Owner changed to @adg.

Status changed to Accepted.

@adg
Copy link
Contributor

adg commented Jun 19, 2013

Comment 5:

https://golang.org/cl/10410045
I should note that we can't change the tool to accept "_test.go", as it would be
incompatible with earlier versions of Go.

Status changed to Started.

@adg
Copy link
Contributor

adg commented Jun 20, 2013

Comment 6:

This issue was closed by revision 2f70ac1.

Status changed to Fixed.

@minux
Copy link
Member

minux commented May 2, 2014

Comment 7:

Issue #7909 has been merged into this issue.

@ianlancetaylor
Copy link
Contributor

ianlancetaylor commented May 3, 2014

Comment 8:

Issue #7909 has been merged into this issue.

This issue was closed.
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