-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into exit-code
- Loading branch information
Showing
10 changed files
with
96 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package pathutil | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/reviewdog/reviewdog/proto/rdf" | ||
) | ||
|
||
func TestNormalizePathInResults(t *testing.T) { | ||
cwd := "/path/to/cwd" | ||
results := []*rdf.Diagnostic{ | ||
{ | ||
Location: &rdf.Location{ | ||
Path: cwd + "/" + "sample_1_abs.txt", | ||
}, | ||
}, | ||
{ | ||
Location: &rdf.Location{ | ||
Path: "sample_2_rel.txt", | ||
}, | ||
}, | ||
{ | ||
RelatedLocations: []*rdf.RelatedLocation{ | ||
{ | ||
Location: &rdf.Location{ | ||
Path: cwd + "/" + "sample_related_1_abs.txt", | ||
}, | ||
}, | ||
{ | ||
Location: &rdf.Location{ | ||
Path: "sample_related_2_rel.txt", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
NormalizePathInResults(results, cwd) | ||
for _, result := range results { | ||
if strings.HasPrefix(result.GetLocation().GetPath(), cwd) { | ||
t.Errorf("path unexpectedly contain prefix: %s", result.GetLocation().GetPath()) | ||
} | ||
for _, rel := range result.GetRelatedLocations() { | ||
if strings.HasPrefix(rel.GetLocation().GetPath(), cwd) { | ||
t.Errorf("related locations path unexpectedly contain prefix: %s", rel.GetLocation().GetPath()) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters