-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: make go test build multiple executables
If -c is set while testing multiple packages, then allow to build testing binary executables to the current directory or to the directory that -o refers to. $ go test -c -o /tmp ./pkg1 ./pkg2 ./pkg2 $ ls /tmp pkg1.test pkg2.test pkg3.test Fixes #15513. Change-Id: I3aba01bebfa90e61e59276f2832d99c0d323b82e Reviewed-on: https://go-review.googlesource.com/c/go/+/466397 Run-TryBot: Bryan Mills <[email protected]> Auto-Submit: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
- Loading branch information
Showing
2 changed files
with
116 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[short] skip 'links test binaries' | ||
|
||
# Verify test -c can output multiple executables to a directory. | ||
|
||
go test -c -o $WORK/some/nonexisting/directory/ ./pkg/... | ||
exists -exec $WORK/some/nonexisting/directory/pkg1.test$GOEXE | ||
exists -exec $WORK/some/nonexisting/directory/pkg2.test$GOEXE | ||
|
||
go test -c ./pkg/... | ||
exists -exec pkg1.test$GOEXE | ||
exists -exec pkg2.test$GOEXE | ||
|
||
! go test -c -o $WORK/bin/test/bin.test.exe ./pkg/... | ||
stderr '^with multiple packages, -o must refer to a directory or '$devnull | ||
|
||
! go test -c ./... | ||
stderr '^cannot write test binary pkg1.test for multiple packages:\nexample/anotherpkg/pkg1\nexample/pkg/pkg1' | ||
|
||
! go test -c -o $WORK/bin/test/ ./... | ||
stderr '^cannot write test binary pkg1.test for multiple packages:\nexample/anotherpkg/pkg1\nexample/pkg/pkg1' | ||
|
||
! go test -o $WORK/bin/filename.exe ./pkg/... | ||
stderr '^with multiple packages, -o must refer to a directory or '$devnull | ||
|
||
! go test -o $WORK/bin/ ./... | ||
stderr '^cannot write test binary pkg1.test for multiple packages:\nexample/anotherpkg/pkg1\nexample/pkg/pkg1' | ||
|
||
go test -c -o $devnull ./... | ||
|
||
rm pkg1.test$GOEXE | ||
rm pkg2.test$GOEXE | ||
go test -o . ./pkg/... | ||
exists -exec pkg1.test$GOEXE | ||
exists -exec pkg2.test$GOEXE | ||
|
||
-- go.mod -- | ||
module example | ||
|
||
-- pkg/pkg1/pkg1_test.go -- | ||
package pkg1 | ||
|
||
-- pkg/pkg2/pkg2_test.go -- | ||
package pkg2 | ||
|
||
-- anotherpkg/pkg1/pkg1_test.go -- | ||
package pkg1 |