Documentation ¶
Overview ¶
Package linttest provides linter testing utilities.
Index ¶
- func FindPHPFiles(root string) ([]string, error)
- func InitEmbeddedRules(config *linter.Config) error
- func ParseTestFile(t testing.TB, l *linter.Linter, filename, content string) linter.ParseResult
- func PrepareGoldenTestSuite(s *GoldenTestSuite, t *testing.T, l *linter.Linter, ...)
- func RunFilterMatch(test *Suite, names ...string)
- func RunInlineTest(t *testing.T, dir string)
- func SimpleNegativeTest(t *testing.T, contents string)
- type CommandE2ETestSuite
- type GoldenE2ETestSuite
- func (s *GoldenE2ETestSuite) BuildNoVerify()
- func (s *GoldenE2ETestSuite) RegisterCommandTest(suite *CommandE2ETestSuite)
- func (s *GoldenE2ETestSuite) RegisterTest(test *GoldenTestSuite)
- func (s *GoldenE2ETestSuite) RemoveNoVerify()
- func (s *GoldenE2ETestSuite) RemoveTestsFiles()
- func (s *GoldenE2ETestSuite) Run()
- func (s *GoldenE2ETestSuite) RunCommandsTest()
- func (s *GoldenE2ETestSuite) RunOnlyTests()
- type GoldenTestSuite
- type RunResult
- type Suite
- func (s *Suite) AddFile(contents string)
- func (s *Suite) AddNamedFile(name, contents string)
- func (s *Suite) AddNolintFile(contents string)
- func (s *Suite) Config() *linter.Config
- func (s *Suite) IgnoreUndeclaredChecks()
- func (s *Suite) Linter() *linter.Linter
- func (s *Suite) Match(reports []*linter.Report)
- func (s *Suite) ReadAndAddFiles(files []string)
- func (s *Suite) RunAndMatch()
- func (s *Suite) RunFilterLinter(filters []string) []*linter.Report
- func (s *Suite) RunLinter() RunResult
- func (s *Suite) RunRulesTest()
- func (s *Suite) UseConfig(config *linter.Config)
- func (s *Suite) UseLinter(lint *linter.Linter)
- type TestFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindPHPFiles ¶ added in v0.3.0
func InitEmbeddedRules ¶ added in v0.3.0
InitEmbeddedRules initializes embedded rules for testing.
func ParseTestFile ¶
func PrepareGoldenTestSuite ¶ added in v0.3.0
func PrepareGoldenTestSuite(s *GoldenTestSuite, t *testing.T, l *linter.Linter, baseDir, goldenFileName string)
PrepareGoldenTestSuite configures fields and standard stubs.
Used if the structure was created directly.
func RunFilterMatch ¶ added in v0.3.0
RunFilterMatch calls Match with the filtered results of RunLinter.
func RunInlineTest ¶ added in v0.4.0
func SimpleNegativeTest ¶
SimpleNegativeTest runs linter over a single file out of given content and expects there to be no warnings.
For positive testing, use Suite type directly.
Types ¶
type CommandE2ETestSuite ¶ added in v0.4.0
type GoldenE2ETestSuite ¶ added in v0.3.0
type GoldenE2ETestSuite struct {
// contains filtered or unexported fields
}
func NewGoldenE2ETestSuite ¶ added in v0.3.0
func NewGoldenE2ETestSuite(t *testing.T) *GoldenE2ETestSuite
func (*GoldenE2ETestSuite) BuildNoVerify ¶ added in v0.3.0
func (s *GoldenE2ETestSuite) BuildNoVerify()
func (*GoldenE2ETestSuite) RegisterCommandTest ¶ added in v0.4.0
func (s *GoldenE2ETestSuite) RegisterCommandTest(suite *CommandE2ETestSuite)
func (*GoldenE2ETestSuite) RegisterTest ¶ added in v0.4.0
func (s *GoldenE2ETestSuite) RegisterTest(test *GoldenTestSuite)
func (*GoldenE2ETestSuite) RemoveNoVerify ¶ added in v0.3.0
func (s *GoldenE2ETestSuite) RemoveNoVerify()
func (*GoldenE2ETestSuite) RemoveTestsFiles ¶ added in v0.3.0
func (s *GoldenE2ETestSuite) RemoveTestsFiles()
func (*GoldenE2ETestSuite) Run ¶ added in v0.3.0
func (s *GoldenE2ETestSuite) Run()
func (*GoldenE2ETestSuite) RunCommandsTest ¶ added in v0.4.0
func (s *GoldenE2ETestSuite) RunCommandsTest()
func (*GoldenE2ETestSuite) RunOnlyTests ¶ added in v0.3.0
func (s *GoldenE2ETestSuite) RunOnlyTests()
type GoldenTestSuite ¶ added in v0.3.0
type GoldenTestSuite struct { Name string Deps []string Disable []string OnlyE2E bool Gitignore bool Baseline bool SrcDir string BaseDir string GoldenFileName string // contains filtered or unexported fields }
func NewGoldenTestSuite ¶ added in v0.3.0
func NewGoldenTestSuite(t *testing.T, name, baseDir, goldenFileName string) *GoldenTestSuite
NewGoldenTestSuite returns a new golden test suite for t.
func (*GoldenTestSuite) AddDeps ¶ added in v0.3.0
func (s *GoldenTestSuite) AddDeps(deps []string)
func (*GoldenTestSuite) AddDisabled ¶ added in v0.3.0
func (s *GoldenTestSuite) AddDisabled(disabled []string)
func (*GoldenTestSuite) Run ¶ added in v0.3.0
func (s *GoldenTestSuite) Run()
type Suite ¶
type Suite struct { Files []TestFile Expect []string RuleFile string AllowDisable *regexp.Regexp MisspellList string LoadStubs []string // contains filtered or unexported fields }
Suite is a configurable test runner for linter.
Use NewSuite to create usable instance.
func NewPHP7Suite ¶ added in v0.4.0
NewPHP7Suite returns a new linter test suite for t with PHP 7.4.
func (*Suite) AddFile ¶
AddFile adds a file to a suite file list. File gets an auto-generated name. If custom name is important, use AddNamedFile.
func (*Suite) AddNamedFile ¶ added in v0.3.0
AddNamedFile adds a file with a specific name to a suite file list.
func (*Suite) AddNolintFile ¶
AddNolintFile adds a file to a suite file list that will be parsed, but not linted. File gets an auto-generated name. If custom name is important, append a properly initialized TestFile to a s Files slice directly.
func (*Suite) IgnoreUndeclaredChecks ¶ added in v0.3.0
func (s *Suite) IgnoreUndeclaredChecks()
func (*Suite) Match ¶
Match tries to match every report against Expect list of s.
If expect slice is nil or empty, only nil (or empty) reports slice would match it.
func (*Suite) ReadAndAddFiles ¶ added in v0.3.0
ReadAndAddFiles read and adds a files to a suite file list.
func (*Suite) RunAndMatch ¶
func (s *Suite) RunAndMatch()
RunAndMatch calls Match with the results of RunLinter.
This is a recommended way to use the Suite, but if reports slice is needed, one can use RunLinter directly.
func (*Suite) RunFilterLinter ¶ added in v0.3.0
RunFilterLinter calls RunLinter with the filter.
func (*Suite) RunLinter ¶
RunLinter executes linter over s Files and returns all issue reports that were produced during that.
func (*Suite) RunRulesTest ¶ added in v0.4.0
func (s *Suite) RunRulesTest()
RunRulesTest starts testing using a file with the rules specified in RuleFile.