mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 15:51:43 +00:00
codeintel-qa: more descriptive failure message (#25806)
This commit is contained in:
parent
70abe56b2f
commit
a993190368
@ -18,20 +18,20 @@ func buildQueries() <-chan queryFunc {
|
||||
|
||||
for _, testCase := range testCases {
|
||||
// Definition returns defintion
|
||||
fns <- makeTestFunc(queryDefinitions, testCase.Definition, []Location{testCase.Definition})
|
||||
fns <- makeTestFunc("def -> def", queryDefinitions, testCase.Definition, []Location{testCase.Definition})
|
||||
|
||||
// References return definition
|
||||
for _, reference := range testCase.References {
|
||||
fns <- makeTestFunc(queryDefinitions, reference, []Location{testCase.Definition})
|
||||
fns <- makeTestFunc("refs -> def", queryDefinitions, reference, []Location{testCase.Definition})
|
||||
}
|
||||
|
||||
// Definition returns references
|
||||
fns <- makeTestFunc(queryReferences, testCase.Definition, testCase.References)
|
||||
fns <- makeTestFunc("def -> refs", queryReferences, testCase.Definition, testCase.References)
|
||||
|
||||
// References return references
|
||||
if queryReferencesOfReferences {
|
||||
for _, reference := range testCase.References {
|
||||
fns <- makeTestFunc(queryReferences, reference, testCase.References)
|
||||
fns <- makeTestFunc("refs -> refs", queryReferences, reference, testCase.References)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -46,7 +46,7 @@ type testFunc func(ctx context.Context, location Location) ([]Location, error)
|
||||
// source, then compares the result against the set of expected locations. This function
|
||||
// depends on the flags provided by the user to alter the behavior of the testing
|
||||
// functions.
|
||||
func makeTestFunc(f testFunc, source Location, expectedLocations []Location) func(ctx context.Context) error {
|
||||
func makeTestFunc(name string, f testFunc, source Location, expectedLocations []Location) func(ctx context.Context) error {
|
||||
return func(ctx context.Context) error {
|
||||
locations, err := f(ctx, source)
|
||||
if err != nil {
|
||||
@ -57,7 +57,7 @@ func makeTestFunc(f testFunc, source Location, expectedLocations []Location) fun
|
||||
sortLocations(locations)
|
||||
|
||||
if diff := cmp.Diff(expectedLocations, locations); diff != "" {
|
||||
return errors.Errorf("unexpected locations (-want +got):\n%s", diff)
|
||||
return errors.Errorf("%s: starting at location\n\n %+v\n\ngot unexpected locations (-want +got):\n%s", name, source, diff)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user