Documentation
¶
Overview ¶
Package detection provides hierarchical test framework detection.
Index ¶
- Constants
- type Confidence
- type Detector
- type ProjectContext
- func (pc *ProjectContext) AddConfigFile(path string)
- func (pc *ProjectContext) FindApplicableConfig(filePath string) *matchers.ConfigInfo
- func (pc *ProjectContext) FindConfigPath(filePath, framework string) string
- func (pc *ProjectContext) HasConfigFile(pattern string) bool
- func (pc *ProjectContext) SetConfigContent(path string, info *matchers.ConfigInfo)
- type ProjectContextBuilder
- type Result
- type Source
Constants ¶
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 (*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 (b *ProjectContextBuilder) Build() *ProjectContext
func (*ProjectContextBuilder) ParseConfigContent ¶ added in v1.1.1
func (b *ProjectContextBuilder) ParseConfigContent(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 FromProjectContext ¶ added in v1.1.1
func FromScopeConfig ¶
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. |