Documentation
¶
Index ¶
- Variables
- func CountUniqueCoverage(data []*CoverageBlockUnfolded) (count int)
- func Files(logger *log.Logger, language Language, repositoryPath string) (filePaths []string, err error)
- func Register(language Language)
- func RepositoriesForLanguage(language Language, testdataPath string) (relativeRepositoryPaths []string, err error)
- func UniqueCoverageCountFromFile(logger *log.Logger, coverageFilePath string) (uniqueCoverageCount uint64, err error)
- type CoverageBlockUnfolded
- type Language
- type TestResult
Constants ¶
This section is empty.
Variables ¶
var DefaultExecutionTimeout = 5 * time.Minute
DefaultExecutionTimeout defines the timeout for an execution. WORKAROUND For now we define the timeout as a global variable but it should eventually be moved to the "symflower test" command.
var ( // ErrCannotParseTestSummary indicates that the test summary cannot be parsed. ErrCannotParseTestSummary = errors.New("cannot parse test summary") )
var ( // ErrNoTestFound indicates that no tests could be found. ErrNoTestFound = errors.New("no tests could be found") )
Common errors over all languages.
var FileRangeMatch = regexp.MustCompile(`^(.+):(\d+):(\d+)-(.+):(\d+):(\d+)$`)
FileRangeMatch match a textual file range with lines and columns.
var LanguageByFileExtension = map[string]Language{}
LanguageByFileExtension holds the language for a default file extension.
var Languages = map[string]Language{}
Languages holds a register of all languages.
Functions ¶
func CountUniqueCoverage ¶ added in v1.1.0
func CountUniqueCoverage(data []*CoverageBlockUnfolded) (count int)
CountUniqueCoverage counts the unique coverage.
func Files ¶ added in v0.6.1
func Files(logger *log.Logger, language Language, repositoryPath string) (filePaths []string, err error)
Files returns a list of relative file paths of the repository that should be evaluated.
func Register ¶
func Register(language Language)
Register adds a language to the common language list.
Types ¶
type CoverageBlockUnfolded ¶ added in v0.5.0
type CoverageBlockUnfolded struct {
// FileRangeRaw holds the file range string.
FileRangeRaw string `json:"FileRange"`
// FilePath holds the file path.
FilePath string `json:",omitempty"`
// LineStart holds the start line.
LineStart int `json:",omitempty"`
// LineEnd holds the end line.
LineEnd int `json:",omitempty"`
// CoverageType holds the covered coverage type.
CoverageType string
// Count holds the execution count.
Count uint
}
CoverageBlockUnfolded is an unfolded representation of a coverage data block.
func ParseCoverage ¶ added in v1.1.0
func ParseCoverage(logger *log.Logger, coverageFilePath string) (coverageData []*CoverageBlockUnfolded, err error)
ParseCoverage parses the given coverage file and returns its coverage.
type Language ¶
type Language interface {
// ID returns the unique ID of this language.
ID() (id string)
// Name is the prose name of this language.
Name() (id string)
// Files returns a list of relative file paths of the repository that should be evaluated.
Files(logger *log.Logger, repositoryPath string) (filePaths []string, err error)
// ImportPath returns the import path of the given source file.
ImportPath(projectRootPath string, filePath string) (importPath string)
// TestFilePath returns the file path of a test file given the corresponding file path of the test's source file.
TestFilePath(projectRootPath string, filePath string) (testFilePath string)
// TestFramework returns the human-readable name of the test framework that should be used.
TestFramework() (testFramework string)
// DefaultFileExtension returns the default file extension of the implemented language.
DefaultFileExtension() string
// DefaultTestFileSuffix returns the default test file suffix of the implemented language.
DefaultTestFileSuffix() string
// ExecuteTests invokes the language specific testing on the given repository.
ExecuteTests(logger *log.Logger, repositoryPath string) (testResult *TestResult, problems []error, err error)
// Mistakes builds a repository and returns the list of mistakes found.
Mistakes(logger *log.Logger, repositoryPath string) (mistakes []string, err error)
// SupportsFix reports if the language is supported by "symflower fix".
SupportsFix() bool
// SupportsTemplate reports if the language is supported by "symflower unit-test-skeleton".
SupportsTemplate() bool
}
Language defines a language to evaluate a repository.
type TestResult ¶ added in v0.6.0
TestResult holds the result of running tests.
func (*TestResult) PassingTestsPercentage ¶ added in v0.6.0
func (tr *TestResult) PassingTestsPercentage() (percentage uint)
PassingTestsPercentage returns the percentage of passing tests.