Skip to content

Commit 2f9eeea

Browse files
jeffallenianlancetaylor
authored andcommitted
cmd/go: document testdata directory in "go help test"
Document the correct use of the testdata directory where test writers might be expecting to find it. It seems that alldocs.go was out of date, so it has picked up some other changes with this commit. Fixes #14715. Change-Id: I0a22676bb7a64b2a61b56495f7ea38db889d8b37 Reviewed-on: https://go-review.googlesource.com/23353 Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent a0abecf commit 2f9eeea

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/cmd/go/alldocs.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,8 @@ syntax of package template. The default output is equivalent to -f
570570
Stale bool // would 'go install' do anything for this package?
571571
StaleReason string // explanation for Stale==true
572572
Root string // Go root or Go path dir containing this package
573+
ConflictDir string // this directory shadows Dir in $GOPATH
574+
BinaryOnly bool // binary-only package: cannot be recompiled from sources
573575
574576
// Source files
575577
GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
@@ -704,6 +706,9 @@ Each listed package causes the execution of a separate test binary.
704706
Test files that declare a package with the suffix "_test" will be compiled as a
705707
separate package, and then linked and run with the main test binary.
706708
709+
The go tool will ignore a directory named "testdata", making it available
710+
to hold ancillary data needed by the tests.
711+
707712
By default, go test needs no arguments. It compiles and tests the package
708713
with source in the current directory, including tests, and runs the tests.
709714
@@ -882,7 +887,15 @@ the extension of the file name. These extensions are:
882887
Files of each of these types except .syso may contain build
883888
constraints, but the go command stops scanning for build constraints
884889
at the first item in the file that is not a blank line or //-style
885-
line comment.
890+
line comment. See the go/build package documentation for
891+
more details.
892+
893+
Non-test Go source files can also include a //go:binary-only-package
894+
comment, indicating that the package sources are included
895+
for documentation only and must not be used to build the
896+
package binary. This enables distribution of Go packages in
897+
their compiled form alone. See the go/build package documentation
898+
for more details.
886899
887900
888901
GOPATH environment variable
@@ -1457,7 +1470,6 @@ control the execution of any test:
14571470
14581471
-trace trace.out
14591472
Write an execution trace to the specified file before exiting.
1460-
Writes test binary as -c would.
14611473
14621474
-v
14631475
Verbose output: log all tests as they are run. Also print all

src/cmd/go/test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ Each listed package causes the execution of a separate test binary.
5959
Test files that declare a package with the suffix "_test" will be compiled as a
6060
separate package, and then linked and run with the main test binary.
6161
62+
The go tool will ignore a directory named "testdata", making it available
63+
to hold ancillary data needed by the tests.
64+
6265
By default, go test needs no arguments. It compiles and tests the package
6366
with source in the current directory, including tests, and runs the tests.
6467

0 commit comments

Comments
 (0)