]> Cypherpunks repositories - gostls13.git/commit
testing: introduce testing/internal/testdeps for holding testmain dependencies
authorRuss Cox <rsc@golang.org>
Mon, 31 Oct 2016 23:27:26 +0000 (19:27 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 2 Nov 2016 19:14:39 +0000 (19:14 +0000)
commitc56cc9b3b5727647c2afb3d57f5793151558a0a7
tree87dd9dfe223d74db55bc83b8560767bd83b8362b
parent5ad3bd99b5f997c55fa7c3d01eeeddc835631ba0
testing: introduce testing/internal/testdeps for holding testmain dependencies

Currently, we don't have package testing to import package regexp directly,
because then regexp can't have internal tests (or at least they become more
difficult to write), for fear of an import cycle. The solution we've been using
is for the generated test main package (pseudo-import path "testmain", package main)
to import regexp and pass in a matchString function for use by testing when
implementing the -run flags. This lets testing use regexp but without depending
on regexp and creating unnecessary cycles.

We want to add a few dependencies to runtime/pprof, notably regexp
but also compress/gzip, without causing those packages to have to work
hard to write internal tests.

Restructure the (dare I say it) dependency injection of regexp.MatchString
to be more general, and use it for the runtime/pprof functionality in addition
to the regexp functionality. The new package testing/internal/testdeps is
the root for the testing dependencies handled this way.

Code using testing.MainStart will have to change from passing in a matchString
implementation to passing in testdeps.TestDeps{}. Users of 'go test' don't do this,
but other build systems that have recreated 'go test' (for example, Blaze/Bazel)
may need to be updated. The new testdeps setup should make future updates
unnecessary, but even so we keep the comment about MainStart not being
subject to Go 1 compatibility.

Change-Id: Iec821d2afde10c79f95f3b23de5e71b219f47b92
Reviewed-on: https://go-review.googlesource.com/32455
Reviewed-by: Ian Lance Taylor <iant@golang.org>
api/except.txt
src/cmd/go/pkg.go
src/cmd/go/test.go
src/go/build/deps_test.go
src/testing/internal/testdeps/deps.go [new file with mode: 0644]
src/testing/testing.go