Skip to content

proposal: testing: deprecate all exposed internals #80701

Description

@seankhliao

Proposal Details

The testing package exposes some of its internals, because they need to be invoked be the testing entrpoint generated by go test.
But these should never be invoked by user code, and we should strongly discourage their use by poorly behaving packages especially since some of them have comments saying their behavior or signature may change.

I propose we mark the following as deprecated:

package testing

func Main(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample)
func MainStart(deps testDeps, tests []InternalTest, benchmarks []InternalBenchmark, fuzzTargets []InternalFuzzTarget, examples []InternalExample) *M

func RegisterCover(c Cover)

func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []InternalBenchmark)
func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []InternalBenchmark)
func RunExamples(matchString func(pat, str string) (bool, error), examples []InternalExample) (ok bool)
func RunTests(matchString func(pat, str string) (bool, error), tests []InternalTest) (ok bool)

type InternalBenchmark { ... }
type InternalExample struct { ... }
type InternalFuzzTarget struct { ... }
type InternalTest struct { ... }

Deprecation primarily affects tooling such as IDEs or static analysis.
In normal use, the _testmain.go that is generated by cmd/go is never seen by these tools, so simply marking them does not impact go test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions