summaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata
Commit message (Collapse)AuthorAgeFilesLines
* testing: roll back CL 44352 (show in-progress tests upon SIGINT)Ian Lance Taylor2017-07-131-40/+0
| | | | | | | | | | | | | | | | CL 44352 changed the behavior of SIGINT, which can break tests that themselves use SIGINT. I think we can only implement this if the testing package has a way to know whether the code under test is using SIGINT, but os/signal does not provide an API for that. Roll back for 1.9 and think about this again for 1.10. Updates #19397 Change-Id: I021c314db2b9d0a80d0088b120a6ade685459990 Reviewed-on: https://go-review.googlesource.com/48370 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* cmd/go: be more precise when a directory cannot be builtRuss Cox2017-06-234-0/+8
| | | | | | | | | | | | | | | Maybe there are no Go files at all. Maybe they are all excluded by build constraints. Maybe there are only test Go files. Be specific. Fixes #17008. Fixes parts of #20760. Change-Id: If6ac82ba0ed437772e76e06763263747d3bc4f65 Reviewed-on: https://go-review.googlesource.com/46427 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/go: detect Go assembly before assembling with gccRuss Cox2017-06-232-0/+10
| | | | | | | | | | | | | Avoids confusing errors from the GNU assembler processing Go assembly source code. Fixes #19448. Change-Id: Ic2c68b2521847cca5a3d078a092e5c60ec340840 Reviewed-on: https://go-review.googlesource.com/46423 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* testing: harmonize handling of prefix-matched benchmarksRuss Cox2017-06-202-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | If you have BenchmarkX1 with sub-benchmark Y and you have BenchmarkX2 with no sub-benchmarks, then go test -bench=X/Y runs BenchmarkX1 once with b.N=1 (to find out about Y) and then not again, because it has sub-benchmarks, but arguably also because we're interested in Y. In contrast, it runs BenchmarkX2 in full, even though clearly that is not relevant to the match X/Y. We do have to run X2 once with b.N=1 to probe for having X2/Y, but we should not run it with larger b.N. Fixes #20589. Change-Id: Ib86907e844f34dcaac6cd05757f57db1019201d0 Reviewed-on: https://go-review.googlesource.com/46031 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
* testing: show in-progress tests upon SIGINTMeir Fischer2017-06-091-0/+40
| | | | | | | | | | | | | | | | | | | Because of parallel tests, which have stalled executions, the RUN output of a test can be much earlier than its completion output resulting in hard-to-read verbose output. The tests are displayed in the order in which the output shows that they began, to make it easy to line up with the "RUN" output. Similarly, the definitions of when tests begin and complete is determined by when RUN and FAIL/SKIP/PASS are output since the focus of this code is on enhancing readability. Fixes #19397 Change-Id: I4d0ca3fd268b620484e7a190117f79a33b3dc461 Reviewed-on: https://go-review.googlesource.com/44352 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* testing: print extra labels on benchmarksQuentin Smith2017-02-071-0/+6
| | | | | | | | | | | | | When running benchmarks, print "goos", "goarch", and "pkg" labels. This makes it easier to refer to benchmark logs and understand how they were generated. "pkg" is printed only for benchmarks located in GOPATH. Change-Id: I397cbdd57b9fe8cbabbb354ec7bfba59f5625c42 Reviewed-on: https://go-review.googlesource.com/36356 Run-TryBot: Quentin Smith <quentin@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
* testing: stop timeout-timer after running testsAlberto Donizetti2017-01-311-0/+10
| | | | | | | | | | Fixes #18845 Change-Id: Icdc3e2067807781e42f2ffc94d1824aed94d3713 Reviewed-on: https://go-review.googlesource.com/35956 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/go: add sync/atomic dependency when needed by test coverageRuss Cox2017-01-0412-0/+12
| | | | | | | | | | Fixes #18486. Change-Id: I359dc4169e04b4123bd41679ea939b06fa754ac2 Reviewed-on: https://go-review.googlesource.com/34830 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* cmd/go: ensure streaming test's stdout, stderr are same as cmd/go'sBrad Fitzpatrick2016-12-071-0/+39
| | | | | | | | Fixes #18153 Change-Id: Ie8a32dd6fe306f00e51cde77dd4ea353f7109940 Reviewed-on: https://go-review.googlesource.com/34010 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/go/testdata/src: gofmtJosh Bleecher Snyder2016-11-142-1/+2
| | | | | | | | | | | | | | These are functionality tests, not formatter tests. I also tested manually that 'go test cmd/go' without -short still passes. Change-Id: Id146e1dc3b65e19ea531869725cd0b97f4801b8b Reviewed-on: https://go-review.googlesource.com/33169 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* testing: mark tests and benchmarks failed if a race occurs during executionRuss Cox2016-11-031-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: $ go test -race -v -run TestRace === RUN TestRace ================== WARNING: DATA RACE Write at 0x00c420076420 by goroutine 7: _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace.func1() /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:10 +0x3b Previous write at 0x00c420076420 by goroutine 6: _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace() /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:13 +0xcc testing.tRunner() /Users/rsc/go/src/testing/testing.go:656 +0x104 Goroutine 7 (running) created at: _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace() /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:12 +0xbb testing.tRunner() /Users/rsc/go/src/testing/testing.go:656 +0x104 Goroutine 6 (running) created at: testing.(*T).Run() /Users/rsc/go/src/testing/testing.go:693 +0x536 testing.runTests.func1() /Users/rsc/go/src/testing/testing.go:877 +0xaa testing.tRunner() /Users/rsc/go/src/testing/testing.go:656 +0x104 testing.runTests() /Users/rsc/go/src/testing/testing.go:883 +0x4ac testing.(*M).Run() /Users/rsc/go/src/testing/testing.go:818 +0x1c3 main.main() _/Users/rsc/go/src/cmd/go/testdata/src/testrace/_test/_testmain.go:42 +0x20f ================== --- PASS: TestRace (0.00s) PASS Found 1 data race(s) FAIL _/Users/rsc/go/src/cmd/go/testdata/src/testrace 1.026s $ After: $ go test -race -v -run TestRace === RUN TestRace ================== WARNING: DATA RACE Write at 0x00c420076420 by goroutine 7: _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace.func1() /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:10 +0x3b Previous write at 0x00c420076420 by goroutine 6: _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace() /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:13 +0xcc testing.tRunner() /Users/rsc/go/src/testing/testing.go:656 +0x104 Goroutine 7 (running) created at: _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace() /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:12 +0xbb testing.tRunner() /Users/rsc/go/src/testing/testing.go:656 +0x104 Goroutine 6 (running) created at: testing.(*T).Run() /Users/rsc/go/src/testing/testing.go:693 +0x536 testing.runTests.func1() /Users/rsc/go/src/testing/testing.go:877 +0xaa testing.tRunner() /Users/rsc/go/src/testing/testing.go:656 +0x104 testing.runTests() /Users/rsc/go/src/testing/testing.go:883 +0x4ac testing.(*M).Run() /Users/rsc/go/src/testing/testing.go:818 +0x1c3 main.main() _/Users/rsc/go/src/cmd/go/testdata/src/testrace/_test/_testmain.go:42 +0x20f ================== --- FAIL: TestRace (0.00s) testing.go:609: race detected during execution of test FAIL FAIL _/Users/rsc/go/src/cmd/go/testdata/src/testrace 0.022s $ Fixes #15972. Change-Id: Idb15b8ab81d65637bb535c7e275595ca4a6e450e Reviewed-on: https://go-review.googlesource.com/32615 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/go: fix coverage in xtest of cgo packageRuss Cox2016-11-0310-0/+89
| | | | | | | | | | | | | | Cover-annotated cgo-rebuilt package for xtest was not linked into package graph and so not being rebuilt. Link into package graph. Fixes #13625. Change-Id: I685f7276f92bbc85fbc4b389111c83d9fe517637 Reviewed-on: https://go-review.googlesource.com/32614 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/link: fix -X importpath.name=value when import path needs escapingRuss Cox2016-10-292-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | After the final slash, dots are %-escaped when constructing a symbol name, so that in the actual symbol table, the import path githost.com/my.git becomes githost.com/my%2egit. In this case, -X githost.com/my.git.Value=foo needs to set githost.com/my%2egit.Value. This is a detail of the object format and not something users should know or depend on, so apply the escaping as needed. People who have run across this already and figured out and started using the escaped forms with -X will find those forms not working anymore. That is, -X githost.com/my%2egit.Value=foo is the Go 1.7 workaround but will stop working in Go 1.8 once this proper fix is in place. People who need to keep scripts working with older and newer versions of Go can safely pass both forms, and one will be ignored: -X githost.com/my%2egit.Value=foo -X githost.com/my.git.Value=foo Fixes #16710. Change-Id: I0e994ccdd412a4eb8349fefce9aeb3bfc9a83cd8 Reviewed-on: https://go-review.googlesource.com/31970 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/go: apply import restrictions to test code tooRuss Cox2016-10-283-0/+12
| | | | | | | | | | | | | | | | | | | | We reject import of main packages, but we missed tests. Reject in all tests except test of that main package. We reject local (relative) imports from code with a non-local import path, but again we missed tests. Reject those too. Fixes #14811. Fixes #15795. Fixes #17475. Change-Id: I535ff26889520276a891904f54f1a85b2c40207d Reviewed-on: https://go-review.googlesource.com/31821 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Quentin Smith <quentin@golang.org>
* cmd/go: report missing vendor visibility errorRuss Cox2016-10-264-0/+12
| | | | | | | | | | | | | | The logic for saving the list of packages was not always preferring to keep error messages around correctly. The missed error led to an internal consistency failure later. Fixes #17119. Change-Id: I9723b5d2518c25e2cac5249e6a7b907be95b521c Reviewed-on: https://go-review.googlesource.com/31812 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Quentin Smith <quentin@golang.org>
* cmd/go: diagnose non-canonical import paths before compilationRuss Cox2016-10-264-0/+10
| | | | | | | | | | | | | | | | | | | | | | If we leave it for compilation sometimes the error appears first in derived vendor paths, without any indication where they came from. This is better. $ go1.7 build canonical/d cmd/go/testdata/src/canonical/a/a.go:3: non-canonical import path "canonical/a//vendor/c" (should be "canonical/a/vendor/c") cmd/go/testdata/src/canonical/a/a.go:3: can't find import: "canonical/a//vendor/c" $ go build canonical/d package canonical/d imports canonical/b imports canonical/a/: non-canonical import path: "canonical/a/" should be "canonical/a" $ Fixes #16954. Change-Id: I315ccec92a00d98a08c139b3dc4e17dbc640edd0 Reviewed-on: https://go-review.googlesource.com/31668 Reviewed-by: Quentin Smith <quentin@golang.org>
* cmd/go: allow 'go generate' even if imports do not resolveRuss Cox2016-10-241-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | Maybe the go generate is generating the imports, or maybe there's some other good reason the code is incomplete. The help text already says: Note that go generate does not parse the file, so lines that look like directives in comments or multiline strings will be treated as directives. We'll still reject Go source files that don't begin with a package statement or have a syntax error in the import block, but those are I think more defensible rejections. Fixes #16307. Change-Id: I4f8496c02fdff993f038adfed2df4db7f067dc06 Reviewed-on: https://go-review.googlesource.com/31659 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* cmd/go, testing: indicate when no tests are runCaio Marcelo de Oliveira Filho2016-10-194-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | For example, testing the current directory: $ go test -run XXX testing: warning: no tests to run PASS ok testing 0.013s $ And in a summary: $ go test -run XXX testing ok testing 0.013s [no tests to run] $ These make it easy to spot when the -run regexp hasn't matched anything or there are no tests. Previously the message was printed in the "current directory" case when there were no tests at all, but not for no matches, and either way was not surfaced in the directory list summary form. Fixes #15211. Change-Id: I1c82a423d6bd429fb991c9ca964c9d26c96fd3c5 Reviewed-on: https://go-review.googlesource.com/22341 Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
* all: make copyright headers consistent with one space after periodBrad Fitzpatrick2016-03-017-7/+7
| | | | | | | | | | | | | | | | | | | | | | This is a subset of https://golang.org/cl/20022 with only the copyright header lines, so the next CL will be smaller and more reviewable. Go policy has been single space after periods in comments for some time. The copyright header template at: https://golang.org/doc/contribute.html#copyright also uses a single space. Make them all consistent. Change-Id: Icc26c6b8495c3820da6b171ca96a74701b4a01b0 Reviewed-on: https://go-review.googlesource.com/20111 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* testing: make failure in benchmark cause non-zero exit statusCaio Marcelo de Oliveira Filho2016-02-281-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | Moves the implementation of RunBenchmarks to a non-exported function that returns whether the execution was OK, and uses that to identify failure in benchmarks.The exported function is kept for compatibility. Like before, benchmarks will only be executed if tests and examples pass. The PASS message will not be printed if there was a failure in a benchmark. Example output BenchmarkThatCallsFatal-8 --- FAIL: BenchmarkThatCallsFatal-8 x_test.go:6: called by benchmark FAIL exit status 1 FAIL _/.../src/cmd/go/testdata/src/benchfatal 0.009s Fixes #14307. Change-Id: I6f3ddadc7da8a250763168cc099ae8b325a79602 Reviewed-on: https://go-review.googlesource.com/19889 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/go/testdata: fix nits in testMikio Hara2016-01-262-2/+2
| | | | | | Change-Id: I85fa5e672a476098f8711dcbb5b20ea1a3fa630d Reviewed-on: https://go-review.googlesource.com/18953 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/go: respect internal directories during 'go run'Russ Cox2016-01-144-0/+12
| | | | | | | | Fixes #12217. Change-Id: I5ee6cb18eaa66bdec1affe689aa531c05e719fc9 Reviewed-on: https://go-review.googlesource.com/18645 Reviewed-by: Andrew Gerrand <adg@golang.org>
* cmd/go, go/build: ignore vendor directories with no Go source filesRuss Cox2016-01-143-0/+4
| | | | | | | | | | | Otherwise it is impossible to vendor a/b/c without hiding the real a/b. I also updated golang.org/s/go15vendor. Fixes #13832. Change-Id: Iee3d53c11ea870721803f6e8e67845b405686e79 Reviewed-on: https://go-review.googlesource.com/18644 Reviewed-by: Andrew Gerrand <adg@golang.org>
* cmd/go: fix processing of flags for test binaries.Rob Pike2015-09-231-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The usage message says: test [-c] [-i] [build and test flags] [packages] [flags for test binary] but this was not what was implemented. Instead, after packages are named, flag processing continues, which makes it impossible, for example, to pass to the binary a flag with the same name as a test flag. This was triggered by the -v flag in glog. Consider this test: package pkg ... imports ... var v = flag.Int("v", 0, "v flag") func TestFoo(t *testing.T) { if *v != 7 { log.Fatal(*v) } } Attempting to run this test with go test pkg -v=7 would give a usage message. This change allows it. In fact it allows go test -v pkg -v=7 The solution is to implement the usage message. One compatibility issue is that flags after the package name are no longer processed as test flags, so this no longer works: go test foo -cover One must write go test -cover foo I do not think this is onerous but it must be called out in the release notes. Fixes #12177. Change-Id: Ib9267884b47a6b0c183efa888ec78333272113aa Reviewed-on: https://go-review.googlesource.com/14826 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/go: fix vendor-related index out of range panic on bad file treeRuss Cox2015-08-182-0/+4
| | | | | | | | Fixes #12156. Change-Id: I2d71163b98bcc770147eb9e78dc551a9d0b5b817 Reviewed-on: https://go-review.googlesource.com/13674 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/go: fix disallow of p/vendor/x during vendor experimentRuss Cox2015-07-314-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | The percolation of errors upward in the load process could drop errors, meaning that a build tree could, depending on the processing order, import the same directory as both "p/vendor/x" and as "x". That's not supposed to be allowed. But then, worse, the build would generate two jobs for building that directory, which would use the same work space and overwrite each other's files, leading to very strange failures. Two fixes: 1. Fix the propagation of errors upward (prefer errors over success). 2. Check explicitly for duplicated packages before starting a build. New test for #1. Since #2 can't happen, tested #2 by hand after reverting fix for #1. Fixes #11913. Change-Id: I6d2fc65f93b8fb5f3b263ace8d5f68d803a2ae5c Reviewed-on: https://go-review.googlesource.com/13022 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/go: fix missing internal import errorRuss Cox2015-07-223-0/+10
| | | | | | | | | Fixes #11331. Change-Id: I19b8172421044c301bc136fc8f7bfdadbf880e25 Reviewed-on: https://go-review.googlesource.com/12450 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
* cmd/go: fix buildRuss Cox2015-07-154-0/+10
| | | | | | | | Failures noted by dashboard. Change-Id: I22f90120c6687b64b9efff9df7a7fa8f26d24bac Reviewed-on: https://go-review.googlesource.com/12207 Reviewed-by: Russ Cox <rsc@golang.org>
* cmd/go: fix error for go run with files in different directoriesRuss Cox2015-07-152-0/+2
| | | | | | | | Fixes #9853. Change-Id: Ic4803aa499ca20215085a87bad649014984d84c8 Reviewed-on: https://go-review.googlesource.com/12149 Reviewed-by: Rob Pike <r@golang.org>
* cmd/go: diagnose trivial test import cycleRuss Cox2015-07-152-0/+7
| | | | | | | | | | Was detecting only non-trivial ones. Fixes #9690. Change-Id: I662d81dd4818ddf29592057c090805772c84287b Reviewed-on: https://go-review.googlesource.com/12147 Reviewed-by: Rob Pike <r@golang.org>
* cmd/go: do not panic on invalid import path containing "/vendor/"Daniel Theophanes2015-07-071-0/+3
| | | | | | | | Fixes #11414 Change-Id: I45a41b98554f00362d9222e9c68a441dbfc23cb8 Reviewed-on: https://go-review.googlesource.com/11700 Reviewed-by: Russ Cox <rsc@golang.org>
* cmd/go: don't fetch from insecure repositories without -insecureAndrew Gerrand2015-06-241-0/+2
| | | | | | | | | | Fixes #9637 Fixes #10120 Change-Id: I3728239089efb94d04cd4115c9f840afd7badeaf Reviewed-on: https://go-review.googlesource.com/9715 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
* cmd/go: fix buildRuss Cox2015-06-191-0/+3
| | | | | | Change-Id: Ia13d1fa450e88e278b81048b99686395ca474c99 Reviewed-on: https://go-review.googlesource.com/11259 Reviewed-by: Russ Cox <rsc@golang.org>
* cmd/go: add preliminary support for vendor directoriesRuss Cox2015-06-1913-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When GO15VENDOREXPERIMENT=1 is in the environment, this CL changes the resolution of import paths according to the Go 1.5 vendor proposal: If there is a source directory d/vendor, then, when compiling a source file within the subtree rooted at d, import "p" is interpreted as import "d/vendor/p" if that exists. When there are multiple possible resolutions, the most specific (longest) path wins. The short form must always be used: no import path can contain “/vendor/” explicitly. Import comments are ignored in vendored packages. The goal of these changes is to allow authors to vendor (copy) external packages into their source trees without any modifications to the code. This functionality has been achieved in tools like godep, nut, and gb by requiring GOPATH manipulation. This alternate directory-based approach eliminates the need for GOPATH manipulation and in keeping with the go command's use of directory layout-based configuration. The flag allows experimentation with these vendoring semantics once Go 1.5 is released, without forcing them on by default. If the experiment is deemed a success, the flag will default to true in Go 1.6 and then be removed in Go 1.7. For more details, see the original proposal by Keith Rarick at https://groups.google.com/d/msg/golang-dev/74zjMON9glU/dGhnoi2IMzsJ. Change-Id: I2c6527e777d14ac6dc43c53e4b3ff24f3279216e Reviewed-on: https://go-review.googlesource.com/10923 Reviewed-by: Andrew Gerrand <adg@golang.org>
* cmd/go: stop early in disallowInternal on erroneous packagesAndrew Gerrand2015-06-151-0/+3
| | | | | | | | Fixes #11201 Change-Id: I80d8fcfcb5c856aaf9d0e73d756d86018e2bec3b Reviewed-on: https://go-review.googlesource.com/11110 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* cmd/go: add -tags option to go vetRob Pike2015-06-051-0/+9
| | | | | | | | | | Actually add all build flags, so we also get things like -race. Fixes #10228. Change-Id: I5f77dda9d1ee3208e1833702f12f68c2731c4b22 Reviewed-on: https://go-review.googlesource.com/10697 Reviewed-by: Russ Cox <rsc@golang.org>
* cmd/go: add $GOLINE to generateRob Pike2015-04-171-1/+1
| | | | | | | | | | Also use os.Expand for variable substitution so ${x}y works. Fixes #9960. Change-Id: Ic8239b2e737d1f41910dde8ee9524ac48907cb03 Reviewed-on: https://go-review.googlesource.com/9007 Reviewed-by: Russ Cox <rsc@golang.org>
* cmd/go: implement the long-promised -run flag for go generateRob Pike2015-04-171-0/+10
| | | | | | | | | | Trivial to do, but overlooked for 1.4, which is good because I prefer the new design, which is just to match against the source code of the line rather than the command word alone. Change-Id: Idcf7c4479e97bb7cd732f0d058012321b6057628 Reviewed-on: https://go-review.googlesource.com/9005 Reviewed-by: Russ Cox <rsc@golang.org>
* cmd/go: fix 'go vet' of package with external testsRuss Cox2014-10-062-0/+8
| | | | | | | | | | | | For example, fixes 'go vet syscall', which has source files in package syscall_test. Fixes #8511. LGTM=r R=golang-codereviews, r CC=golang-codereviews, iant https://golang.org/cl/152220044
* cmd/go: always build _test.go files and link into testRuss Cox2014-09-265-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | go test's handling of _test.go files when the entire package's set of files has no Test functions has varied over the past few releases. There are a few interesting cases (all contain no Test functions): (1) x_test.go has syntax errors (2) x_test.go has type errors (3) x_test.go has runtime errors (say, a func init that panics) In Go 1.1, tests with (1) or (2) failed; (3) passed. In Go 1.2, tests with (1) or (2) failed; (3) passed. In Go 1.3, tests with (1) failed; (2) or (3) passed. After this CL, tests with (1), (2), or (3) all fail. This is clearly a corner case, but it seems to me that the behavior of the test should not change if you add or remove a line like func TestAlwaysPasses(t *testing.T) {} That implies that the _test.go files must always be built and always be imported into the test binary. Doing so means that (1), (2), and (3) must all fail. Fixes #8337. LGTM=iant R=golang-codereviews, iant CC=adg, golang-codereviews, r https://golang.org/cl/150980043
* cmd/go: prohibit C sources files unless using cgoRuss Cox2014-09-242-0/+2
| | | | | | | | | | | | | | Those C files would have been compiled with 6c. It's close to impossible to use C correctly anymore, and the C compilers are going away eventually. Make them unavailable now. go1.4.txt change in CL 145890046 LGTM=iant R=iant CC=golang-codereviews, r https://golang.org/cl/149720043
* cmd/go: add go generateRob Pike2014-08-243-0/+32
| | | | | | | | | | | | First cut. Works well enough to support yacc via https://golang.org/cl/125620044. LGTM=alex.brainman, rsc R=rsc, alex.brainman CC=golang-codereviews https://golang.org/cl/125580044
* cmd/go, go/build: implement import comment checkingRuss Cox2014-08-1210-0/+18
| | | | | | | | | | | | | | | See golang.org/s/go14customimport for design. Added case to deps_test to allow go/build to import regexp. Not a new dependency, because go/build already imports go/doc which imports regexp. Fixes #7453. LGTM=r R=r, josharian CC=golang-codereviews https://golang.org/cl/124940043
* cmd/go: implement 'internal' conventionRuss Cox2014-08-063-0/+7
| | | | | | | | | See golang.org/s/go14internal for design. LGTM=r R=r, adg CC=golang-codereviews https://golang.org/cl/120600043
* cmd/go: build non-runnable examples in xtestsAndrew Gerrand2014-06-282-0/+21
| | | | | | | | | | Include these files in the build, even though they don't get executed. LGTM=r R=golang-codereviews, r CC=golang-codereviews https://golang.org/cl/108180043
* cmd/go: fix go test againRuss Cox2014-05-132-0/+15
| | | | | | | | | Fixes subrepo builds. LGTM=iant, mikioh.mikioh R=golang-codereviews, iant, mikioh.mikioh CC=golang-codereviews https://golang.org/cl/96310043
* cmd/go: fix 'go test foo_test.go'Russ Cox2014-05-121-0/+6
| | | | | | | | Fixes race build. TBR=iant CC=golang-codereviews https://golang.org/cl/100410044
* cmd/go: detect import cycle caused by test codeRuss Cox2014-05-125-0/+35
| | | | | | | | | | | | | The runtime was detecting the cycle already, but we can give a better error without even building the binary. Fixes #7789. LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://golang.org/cl/96290043
* cmd/go: better error for install of 'test-only' packageRuss Cox2014-05-121-0/+1
| | | | | | | | | Fixes #7915. LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/96210044
* cmd/go: mark regexp as dependency of testmainRobert Hencke2014-05-091-0/+7
| | | | | | | | | Fixes #6844. LGTM=rsc R=golang-codereviews, rsc CC=golang-codereviews https://golang.org/cl/97840043