Documentation ¶
Overview ¶
Package analysis handles analysing a Corpus and filing its subjects into categorised sub-corpora.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Analysis ¶
type Analysis struct { // Plan points to the plan that created this analyser. Plan *plan.Plan // ByStatus maps each status to the corpus of subjects that fall into it. ByStatus map[status.Status]corpus.Corpus // Compilers maps each compiler ID (or full-ID, depending on configuration) to an analysis of that compiler. Compilers map[id.ID]Compiler // Flags aggregates all flags found during the analysis. Flags status.Flag // Mutation, if non-nil, contains information about mutation testing done over this plan. Mutation mutation.Analysis }
Analysis represents an analysis of a plan.
func (*Analysis) HasBadOutcomes ¶
HasBadOutcomes tests whether an analysis has any bad (flagged, failed, or timed-out) cases.
Example ¶
ExampleAnalysis_HasBadOutcomes is a runnable example for Analysis.HasBadOutcomes.
package main import ( "fmt" "github.com/c4-project/c4t/internal/plan/analysis" "github.com/c4-project/c4t/internal/subject/status" ) func main() { var empty analysis.Analysis fmt.Println("empty:", empty.HasBadOutcomes()) cfails := analysis.Analysis{Flags: status.FlagCompileFail} fmt.Println("compiler failures:", cfails.HasBadOutcomes()) rfails := analysis.Analysis{Flags: status.FlagRunFail} fmt.Println("run failures:", rfails.HasBadOutcomes()) ctos := analysis.Analysis{Flags: status.FlagCompileTimeout} fmt.Println("compiler timeouts:", ctos.HasBadOutcomes()) rtos := analysis.Analysis{Flags: status.FlagRunTimeout} fmt.Println("run timeouts:", rtos.HasBadOutcomes()) flags := analysis.Analysis{Flags: status.FlagFlagged} fmt.Println("flagged:", flags.HasBadOutcomes()) filts := analysis.Analysis{Flags: status.FlagFiltered} fmt.Println("filtered:", filts.HasBadOutcomes()) }
Output: empty: false compiler failures: true run failures: true compiler timeouts: true run timeouts: true flagged: true filtered: false
func (*Analysis) HasFailures ¶
HasFailures tests whether an analysis has failure cases.
Example ¶
ExampleAnalysis_HasFailures is a runnable example for Analysis.HasFailures.
package main import ( "fmt" "github.com/c4-project/c4t/internal/plan/analysis" "github.com/c4-project/c4t/internal/subject/status" ) func main() { var empty analysis.Analysis fmt.Println("empty:", empty.HasFailures()) cfails := analysis.Analysis{Flags: status.FlagCompileFail} fmt.Println("compiler failures:", cfails.HasFailures()) rfails := analysis.Analysis{Flags: status.FlagRunFail} fmt.Println("run failures:", rfails.HasFailures()) ctos := analysis.Analysis{Flags: status.FlagCompileTimeout} fmt.Println("compiler timeouts:", ctos.HasFailures()) rtos := analysis.Analysis{Flags: status.FlagRunTimeout} fmt.Println("run timeouts:", rtos.HasFailures()) flags := analysis.Analysis{Flags: status.FlagFlagged} fmt.Println("flagged:", flags.HasFailures()) filts := analysis.Analysis{Flags: status.FlagFiltered} fmt.Println("filtered:", filts.HasFailures()) }
Output: empty: false compiler failures: true run failures: true compiler timeouts: false run timeouts: false flagged: false filtered: false
func (*Analysis) HasFlagged ¶
HasFlagged tests whether an analysis has flagged cases.
Example ¶
ExampleAnalysis_HasFlagged is a runnable example for Analysis.HasFlagged.
package main import ( "fmt" "github.com/c4-project/c4t/internal/plan/analysis" "github.com/c4-project/c4t/internal/subject/status" "github.com/c4-project/c4t/internal/subject/corpus" ) func main() { var empty analysis.Analysis fmt.Println("empty:", empty.HasFlagged()) flagged := analysis.Analysis{ ByStatus: map[status.Status]corpus.Corpus{ status.Flagged: corpus.New("foo", "bar", "baz"), }, Flags: status.FlagFlagged, } fmt.Println("flagged:", flagged.HasFlagged()) }
Output: empty: false flagged: true
func (*Analysis) String ¶
String summarises this collation as a string.
Example ¶
ExampleAnalysis_String is a runnable example for String.
package main import ( "fmt" "github.com/c4-project/c4t/internal/plan/analysis" "github.com/c4-project/c4t/internal/subject/status" "github.com/c4-project/c4t/internal/subject/corpus" ) func main() { c := analysis.Analysis{ ByStatus: map[status.Status]corpus.Corpus{ status.Ok: corpus.New("a", "b", "c", "ch"), status.Filtered: corpus.New("a", "i", "u", "e", "o"), status.Flagged: corpus.New("barbaz"), status.CompileFail: corpus.New("foo", "bar", "baz"), status.CompileTimeout: corpus.New(), status.RunFail: corpus.New("foobaz", "barbaz"), status.RunTimeout: corpus.New(), }, } fmt.Println(&c) }
Output: 4 Ok, 5 Filtered, 1 Flagged, 3 CompileFail, 2 RunFail
type Compiler ¶
type Compiler struct { // Info contains the compiler's plan record. Info compiler.Instance // Counts maps each status to the number of times it was observed across the corpus. Counts map[status.Status]int // Logs maps each subject name to its compiler log. Logs map[string]string // Time gathers statistics about how long, on average, this compiler took to compile corpus subjects. // It doesn't contain information about failed compilations. Time *TimeSet // RunTime gathers statistics about how long, on average, this compiler's compiled subjects took to run. // It doesn't contain information about failed compilations or runs (flagged runs are counted). RunTime *TimeSet }
Compiler represents information about a compiler in a corpus analysis.
type Filter ¶
type Filter struct { // Style is a glob identifier that selects a particular compiler style. Style id.ID `yaml:"style"` // MajorVersionBelow is a lower bound on the major version of the compiler, if set to a positive number. MajorVersionBelow int `yaml:"major_version_below,omitempty"` // ErrorPattern is an uncompiled regexp that selects a particular phrase in a compiler error. ErrorPattern string `yaml:"error_pattern,omitempty"` // contains filtered or unexported fields }
Filter is the type of filters.
A filter, when triggered during analysis of a compilation, sets the 'filtered' flag on that compilation. This suppresses any non-OK status, replacing it with the 'filtered' status.
type FilterSet ¶
type FilterSet []Filter
FilterSet is the type of sets of filter.
func LoadFilterSet ¶
LoadFilterSet loads a filter set from the filepath fpath.
func ReadFilterSet ¶
ReadFilterSet loads and compiles a filter set from the reader r.
type Option ¶
type Option func(*analyser) error
Option is the type of options to Analyse.
func WithFilters ¶
WithFilters appends the filters in fs to the filter set.
func WithFiltersFromFile ¶
WithFiltersFromFile appends the filters in the filter file at path to the filter set. If the path is empty, we don't add any filters.
func WithWorkerCount ¶
WithWorkerCount sets the worker count of the analyser to nworkers.
type TimeSet ¶
type TimeSet struct { // Min contains the minimum time reported across the corpus. Min time.Duration // Sum contains the total time reported across the corpus. Sum time.Duration // Max contains the maximum time reported across the corpus. Max time.Duration // Count contains the number of samples taken for this time set. Count int }
TimeSet contains aggregate statistics about timing (of compilers, runs, etc).
func NewTimeSet ¶
NewTimeSet produces a timeset from the given raw times.
Example ¶
ExampleNewTimeSet is a runnable example for NewTimeSet.
package main import ( "fmt" "time" "github.com/c4-project/c4t/internal/plan/analysis" ) func main() { ts := analysis.NewTimeSet(1*time.Second, 1*time.Second, 2*time.Second, 4*time.Second) fmt.Println("min", ts.Min) fmt.Println("avg", ts.Mean()) fmt.Println("max", ts.Max) fmt.Println("sum", ts.Sum) fmt.Println("count", ts.Count) }
Output: min 1s avg 2s max 4s sum 8s count 4