testfile

package module
v0.2.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 12 Imported by: 0

README

Documentation

Overview

Package testfile provides a go/analysis analyzer enforcing the gomatic Go testing standard that unit-test files are 1:1 with their source files: <name>_test.go tests <name>.go. A _test.go file without a matching source file is allowed only when it is not a unit test — it carries a build constraint (an explicit //go:build or legacy // +build line, or a filename-implied _GOOS/_GOARCH suffix) or declares no Test functions (examples, benchmarks, fuzz targets).

Each pass judges only the _test.go files it delivers, so a file is reported exactly once — by the pass that contains it — anchored at its own package clause. Files the go tool ignores (a leading _ or dot, including a file named exactly _test.go) are never judged. Unreadable or unparseable test files are deliberately exempt: the analyzer fails open rather than report a file it could not inspect, and that contract is pinned by tests.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "testfile",
	Doc:  "reports _test.go unit-test files without a matching source file",
	Run:  run,
}

Analyzer reports unit-test files that are not 1:1 with a source file.

View Source
var Registration = goyze.Registration{
	Name:       "testfile",
	Categories: []goyze.Category{"testing"},
	URL:        "https://docs.gomatic.dev/yze/testfile",
	Analyzer:   Analyzer,
}

Registration declares this analyzer to the yze framework.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
yze-go-testfile command
Command yze-go-testfile runs the testfile analyzer as a standalone go/analysis checker (text and -json output, and as a `go vet -vettool`).
Command yze-go-testfile runs the testfile analyzer as a standalone go/analysis checker (text and -json output, and as a `go vet -vettool`).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL