Documentation
¶
Overview ¶
Package pkgtest provides helpers for tests that need a loaded package. Nothing here is part of a public API.
Index ¶
- func LoadFile(t *testing.T, src string) *packages.Package
- func LoadFileAs(t *testing.T, pkgName, src string) *packages.Package
- func LoadPackage(t *testing.T, files map[string]string) *packages.Package
- func LoadPackageAs(t *testing.T, pkgName string, files map[string]string) *packages.Package
- func MustCompile(t *testing.T, pkgName string, files map[string]string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadFileAs ¶
LoadFileAs is LoadFile for a package with the given name, which doubles as its import path. Use it when the name appears in what the test asserts on, such as generated output.
func LoadPackage ¶
LoadPackage type-checks the given files and assembles the minimal packages.Package that the scan layer needs, which avoids putting a real module on disk for every test.
func LoadPackageAs ¶
LoadPackageAs is LoadPackage for a package with the given name. Files are parsed in sorted filename order so that declaration positions are deterministic.
func MustCompile ¶
MustCompile type-checks files as a single package and fails the test if they do not form valid Go. Use it to confirm that generated source compiles against the source it was generated from; the offending file is included in the failure message.
Types ¶
This section is empty.