Documentation ¶
Index ¶
- func ChangeIntoTestDir(testDir string) (string, error)
- func CheckFailureContainsContent(expected []*rpcpb.AnalysisFailure, actual []*rpcpb.AnalysisFailure) (bool, string)
- func CheckNoteContainsContent(expected []*notepb.Note, actual []*notepb.Note) (bool, string)
- func CreateContext(testDir string, filepaths []string) (*ctxpb.ShipshapeContext, error)
- func CreateLocation(path string) *notepb.Location
- func CreatekRPCTestServer(dispatcher interface{}, name string) (string, func(), error)
- func Match(expect *notepb.Note, actual *notepb.Note) bool
- func MatchFailure(expect *rpcpb.AnalysisFailure, actual *rpcpb.AnalysisFailure) bool
- func RunAnalyzer(ctx *ctxpb.ShipshapeContext, a Analyzer, t *testing.T) ([]*notepb.Note, error)
- type Analyzer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChangeIntoTestDir ¶
ChangeIntoTestDir changes into test directory and returns the original. Note: make sure to call defer os.Chdir(original) after using this!
func CheckFailureContainsContent ¶
func CheckFailureContainsContent(expected []*rpcpb.AnalysisFailure, actual []*rpcpb.AnalysisFailure) (bool, string)
CheckFailureContainsContent checks that there is a 1:1 mapping from expected failures to actual faulres. The description in the execpted failure needs only to be a substring of the actual failure. Returns whether such a 1:1 mapping exists, and if not, a message to print to the tests of the unmatched results
func CheckNoteContainsContent ¶
CheckNoteContainsContent checks that there is a 1:1 mapping from expected notes to actual notes. The description in the execpted note needs only to be a substring of the actual note. Returns whether such a 1:1 mapping exists, and if not, a message to print to the tests of the unmatched results
func CreateContext ¶
func CreateContext(testDir string, filepaths []string) (*ctxpb.ShipshapeContext, error)
CreateContext returns a new Shipshape test context
func CreateLocation ¶
func CreatekRPCTestServer ¶
func Match ¶
Match determines whether the actual note matches our expected note. It requires that the category, subcategory, and location.path be the same, and it requires that the actual description contain the expected description (to make tests easier to write, the actual description is allowed to have more text. Other fields are not checked.
func MatchFailure ¶
func MatchFailure(expect *rpcpb.AnalysisFailure, actual *rpcpb.AnalysisFailure) bool
MatchFailure determines whether the actual failure matches our expected failure. It requires that the category be the same, and it requires that the actual description contain the expected description (to make tests easier to write, the actual description is allowed to have more text.
func RunAnalyzer ¶
RunAnalyzer does any preparation for running the analyzer, and runs it. Errors from setup/teardown will cause the test t to stop. Errors from the analysis will be returned, along with the notes