detection

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package detection provides hierarchical test framework detection.

Index

Constants

View Source
const FrameworkUnknown = "unknown"

Variables

This section is empty.

Functions

This section is empty.

Types

type Confidence

type Confidence int
const (
	ConfidenceUnknown Confidence = iota
	ConfidenceLow                // scope config (config file exists in directory tree)
	ConfidenceMedium             // import (explicit import statement)
	ConfidenceHigh               // project context (config parsed with globals mode)
)

type Detector

type Detector struct {
	// contains filtered or unexported fields
}

func NewDetector

func NewDetector(matcherRegistry *matchers.Registry, scopeResolver *config.Resolver) *Detector

func (*Detector) Detect

func (d *Detector) Detect(ctx context.Context, filePath string, content []byte) Result

Detect performs hierarchical framework detection (backward compatible).

func (*Detector) DetectWithContext added in v1.1.1

func (d *Detector) DetectWithContext(ctx context.Context, filePath string, content []byte, projectCtx *ProjectContext) Result

DetectWithContext performs hierarchical framework detection. Hierarchy: ProjectContext (globals mode) → Import → ScopeConfig → Unknown

type ProjectContext added in v1.1.1

type ProjectContext struct {
	ConfigFiles    []string
	ConfigContents map[string]*matchers.ConfigInfo
}

ProjectContext provides project-level metadata for framework detection. Enables source-agnostic detection for both local filesystem and remote sources (e.g., GitHub API).

Thread-safety:

  • Construction: Use ProjectContextBuilder for safe construction. Builder methods are NOT thread-safe; complete all builder operations in a single goroutine before calling Build().
  • After construction: ProjectContext is immutable. Concurrent reads are safe.
  • Do NOT call AddConfigFile or SetConfigContent after passing to Scan().

func NewProjectContext added in v1.1.1

func NewProjectContext() *ProjectContext

func (*ProjectContext) AddConfigFile added in v1.1.1

func (pc *ProjectContext) AddConfigFile(path string)

AddConfigFile adds a config file path. NOT thread-safe; use only during construction.

func (*ProjectContext) FindApplicableConfig added in v1.1.1

func (pc *ProjectContext) FindApplicableConfig(filePath string) *matchers.ConfigInfo

FindApplicableConfig returns the nearest config for a source file path. Traverses up directory tree; root-level configs act as fallbacks. Returns nil if no config found.

func (*ProjectContext) FindConfigPath added in v1.1.1

func (pc *ProjectContext) FindConfigPath(filePath, framework string) string

FindConfigPath returns the nearest config path for a source file with optional framework filter.

func (*ProjectContext) HasConfigFile added in v1.1.1

func (pc *ProjectContext) HasConfigFile(pattern string) bool

func (*ProjectContext) SetConfigContent added in v1.1.1

func (pc *ProjectContext) SetConfigContent(path string, info *matchers.ConfigInfo)

SetConfigContent sets parsed config info for a path. NOT thread-safe; use only during construction. Requires pc to be initialized via NewProjectContext() or NewProjectContextBuilder().

type ProjectContextBuilder added in v1.1.1

type ProjectContextBuilder struct {
	// contains filtered or unexported fields
}

ProjectContextBuilder constructs ProjectContext from file lists and config contents.

func NewProjectContextBuilder added in v1.1.1

func NewProjectContextBuilder(registry *matchers.Registry) *ProjectContextBuilder

func (*ProjectContextBuilder) AddConfigFiles added in v1.1.1

func (b *ProjectContextBuilder) AddConfigFiles(filePaths []string) *ProjectContextBuilder

AddConfigFiles filters and registers config file paths from a file list.

func (*ProjectContextBuilder) Build added in v1.1.1

func (*ProjectContextBuilder) ParseConfigContent added in v1.1.1

func (b *ProjectContextBuilder) ParseConfigContent(ctx context.Context, configPath string, content []byte) *ProjectContextBuilder

ParseConfigContent parses config content using the appropriate matcher. Matchers are sorted by priority (highest first) to ensure consistent behavior when multiple matchers could handle the same config pattern.

type Result

type Result struct {
	ConfigPath string
	Confidence Confidence
	Framework  string
	Source     Source
}

func FromImport

func FromImport(framework string) Result

func FromProjectContext added in v1.1.1

func FromProjectContext(framework, configPath string) Result

func FromScopeConfig

func FromScopeConfig(framework, configPath string) Result

func Unknown

func Unknown() Result

func (Result) IsUnknown

func (r Result) IsUnknown() bool

type Source

type Source string
const (
	SourceUnknown        Source = "unknown"
	SourceImport         Source = "import"
	SourceScopeConfig    Source = "scope_config"
	SourceProjectContext Source = "project_context"
	SourcePragma         Source = "pragma"
)

Directories

Path Synopsis
Package config provides scope-based configuration file resolution.
Package config provides scope-based configuration file resolution.
Package matchers provides framework-specific detection rules.
Package matchers provides framework-specific detection rules.

Jump to

Keyboard shortcuts

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