runner

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IssueUnexpected = iota
	IssueNotRaised
)

Variables

This section is empty.

Functions

func Run

func Run(printer IssuePrinter, files []string, autofixDir string) (bool, error)

Types

type AutofixBackup

type AutofixBackup struct {
	CopiedFiles []string
	TmpDir      string
	AutofixDir  string
	InPlace     bool
	// contains filtered or unexported fields
}

func NewAutofixBackup

func NewAutofixBackup(
	config *Config,
	includedFiles map[string]bool,
	autofixDir string,
) (*AutofixBackup, error)

NewAutofixBackup backs up the files provided in the FilesGlob pattern to before performing Autofix testing. The backup respects the root `.gitignore`.

func (*AutofixBackup) RestoreAndDestroy

func (a *AutofixBackup) RestoreAndDestroy() (err error)

RestoreAndDestroy restores the Autofix backup and then deletes the backup directory. It should only be called once per backup.

type Config

type Config struct {
	FilesGlob     string           `toml:"files"`
	CommentPrefix []string         `toml:"comment_prefix"`
	CodePath      string           `toml:"code_path"`
	Checks        TestRunnerConfig `toml:"checks"`
	Autofix       TestRunnerConfig `toml:"autofix"`
	Processor     ProcessorConfig  `toml:"processor"`
	TestChecks    bool             `toml:"test_checks"`
	TestAutofix   bool             `toml:"test_autofix"`
}

func ReadConfig

func ReadConfig(filePath string) (*Config, error)

type DefaultIssuePrinter

type DefaultIssuePrinter struct{}

func (DefaultIssuePrinter) PrintHeader

func (DefaultIssuePrinter) PrintHeader(header string)

func (DefaultIssuePrinter) PrintIssue

func (DefaultIssuePrinter) PrintIssue(file string, line, column, failureType int, issue *Issue)

func (DefaultIssuePrinter) PrintStatus

func (DefaultIssuePrinter) PrintStatus(_ bool)

func (DefaultIssuePrinter) PrintUnifiedDiff

func (DefaultIssuePrinter) PrintUnifiedDiff(file string, diff gotextdiff.Unified)

func (DefaultIssuePrinter) PrintWarning added in v0.2.0

func (DefaultIssuePrinter) PrintWarning(warning string)

type Issue

type Issue struct {
	Code     string        `json:"code"`
	Title    string        `json:"title"`
	Position IssuePosition `json:"position"`
}

type IssuePosition

type IssuePosition struct {
	File  string    `json:"file"`
	Start Location  `json:"start"`
	End   *Location `json:"end"` // end location is a pointer as it may be nil
	// contains filtered or unexported fields
}

type IssuePrinter

type IssuePrinter interface {
	PrintHeader(header string)
	PrintIssue(file string, line, column, failureType int, issue *Issue)
	PrintUnifiedDiff(file string, diff gotextdiff.Unified)
	PrintStatus(passed bool)
	PrintWarning(warning string)
}

type Location

type Location struct {
	Line   int `json:"line"`
	Column int `json:"column"`
}

type PrettyIssuePrinter

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

func NewPrettyIssuePrinter

func NewPrettyIssuePrinter() *PrettyIssuePrinter

func (*PrettyIssuePrinter) PrintHeader

func (*PrettyIssuePrinter) PrintHeader(header string)

func (*PrettyIssuePrinter) PrintIssue

func (p *PrettyIssuePrinter) PrintIssue(
	file string, line, column,
	failureType int, issue *Issue,
)

func (*PrettyIssuePrinter) PrintStatus

func (*PrettyIssuePrinter) PrintStatus(passed bool)

func (*PrettyIssuePrinter) PrintUnifiedDiff

func (p *PrettyIssuePrinter) PrintUnifiedDiff(file string, diff gotextdiff.Unified)

func (*PrettyIssuePrinter) PrintWarning added in v0.2.0

func (p *PrettyIssuePrinter) PrintWarning(warning string)

type ProcessorConfig

type ProcessorConfig struct {
	Interpreter    string `toml:"interpreter"`
	Script         string `toml:"script"`
	SkipProcessing bool   `toml:"skip_processing"`
}

type Result

type Result struct {
	Issues []*Issue `json:"issues"`
}

type TestRunnerConfig

type TestRunnerConfig struct {
	Interpreter string   `toml:"interpreter"`
	Script      string   `toml:"script"`
	OutputFile  string   `toml:"output_file"`
	Interactive bool     `toml:"interactive"`
	Args        []string `toml:"args"`
}

Jump to

Keyboard shortcuts

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