testconfig

package
v1.2.5 Latest Latest
Warning

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

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

Documentation

Overview

Package testconfig parses and validates project test.config.json shared by xgo test-explorer and consumers such as doctest.

Index

Constants

View Source
const DefaultFileName = "test.config.json"

DefaultFileName is the conventional project-root config file name.

Variables

This section is empty.

Functions

func CompareGoVersion

func CompareGoVersion(a, b *goinfo.GoVersion, ignorePatch bool) int

CompareGoVersion compares major/minor (and patch unless ignorePatch). Returns a-b style: negative if a < b, zero if equal, positive if a > b.

func ValidateGoConstraint

func ValidateGoConstraint(goCfg *GoConfig, goBinary string) error

ValidateGoConstraint checks a go.min/go.max block against goBinary version.

func ValidateGoVersion

func ValidateGoVersion(cfg *Config, goBinary string) error

ValidateGoVersion checks cfg.Go min/max against the host Go toolchain. goBinary defaults to "go" when empty. No-op when cfg or constraints are empty. Invalid min/max tokens are ignored (same as historical xgo explorer behavior).

Types

type Config

type Config struct {
	Go      *GoConfig              `json:"go"`
	GoCmd   string                 `json:"go_cmd"`
	Exclude []string               `json:"exclude"`
	Env     map[string]interface{} `json:"env"`

	// Flags are passed to go/xgo test (e.g. -p=12, --trap-stdlib=false).
	Flags []string `json:"flags"`
	// Args are test-binary program args (after -args).
	Args []string `json:"args"`

	BypassGoFlags bool `json:"bypass_go_flags"`

	// MockRules are re-marshaled JSON objects for --mock-rule.
	MockRules []string        `json:"mock_rules"`
	Xgo       *XgoConfig      `json:"xgo,omitempty"`
	Coverage  *CoverageConfig `json:"coverage,omitempty"`
}

Config is the shared subset of test.config.json fields. Product-specific keys (e.g. doctest pre_test) may appear in the file and are ignored by Parse.

func Load

func Load(path string) (*Config, error)

Load reads path. Missing file returns (nil, nil). Empty file returns empty Config.

func Parse

func Parse(data []byte) (*Config, error)

Parse unmarshals test.config.json bytes into Config. Unknown top-level keys (e.g. pre_test) are ignored.

func (*Config) CmdEnv

func (c *Config) CmdEnv() []string

CmdEnv is an alias for EnvPairs (historical xgo test-explorer name).

func (*Config) EnvPairs

func (c *Config) EnvPairs() []string

EnvPairs returns KEY=value strings for child processes (stable key order not guaranteed).

func (*Config) GetGoCmd

func (c *Config) GetGoCmd() string

GetGoCmd returns configured go_cmd or "go".

type CoverageConfig

type CoverageConfig struct {
	Disabled bool     `json:"disabled"`
	DiffWith string   `json:"diff_with"`
	Profile  string   `json:"profile"`
	Include  []string `json:"include"`
	Exclude  []string `json:"exclude"`
}

CoverageConfig controls coverage integration (enabled by default when present).

type GoConfig

type GoConfig struct {
	Min string `json:"min"`
	Max string `json:"max"`
}

GoConfig is the go.min / go.max constraint block.

type XgoConfig

type XgoConfig struct {
	AutoUpdate bool `json:"auto_update"`
}

XgoConfig holds xgo-specific options from test.config.json.

Jump to

Keyboard shortcuts

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