pkgtest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package pkgtest provides helpers for tests that need a loaded package. Nothing here is part of a public API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFile

func LoadFile(t *testing.T, src string) *packages.Package

LoadFile type-checks src as a single file named "test.go" in package "test".

func LoadFileAs

func LoadFileAs(t *testing.T, pkgName, src string) *packages.Package

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

func LoadPackage(t *testing.T, files map[string]string) *packages.Package

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

func LoadPackageAs(t *testing.T, pkgName string, files map[string]string) *packages.Package

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

func MustCompile(t *testing.T, pkgName string, files map[string]string)

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.

Jump to

Keyboard shortcuts

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