Skip to content

Commit

Permalink
Consider 'src/test' test directories
Browse files Browse the repository at this point in the history
The Maven 'Standard Directory Layout' [0] is fairly widely used, not only
in Maven but also in adjacent ecosystems like Gradle and clojure.

Longer-term this would become part of the default policy, see discussion
at ossf#1408 (comment) etc.

[0]: https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
  • Loading branch information
raboof authored and naveensrinivasan committed Mar 1, 2023
1 parent 8add330 commit 165bcd0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion checks/fileparser/listing.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ func isMatchingPath(fullpath string, matchPathTo PathMatcher) (bool, error) {
func isTestdataFile(fullpath string) bool {
// testdata/ or /some/dir/testdata/some/other
return strings.HasPrefix(fullpath, "testdata/") ||
strings.Contains(fullpath, "/testdata/")
strings.Contains(fullpath, "/testdata/") ||
strings.HasPrefix(fullpath, "src/test/") ||
strings.Contains(fullpath, "/src/test/")
}

// PathMatcher represents a query for a filepath.
Expand Down
7 changes: 7 additions & 0 deletions checks/fileparser/listing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,13 @@ func Test_isTestdataFile(t *testing.T) {
},
want: true,
},
{
name: "testdata file",
args: args{
fullpath: "archiva-modules/archiva-base/archiva-checksum/src/test/resources/examples/redback-authz-open.jar",
},
want: true,
},
}
for _, tt := range tests {
tt := tt // Re-initializing variable so it is not changed while executing the closure below
Expand Down

0 comments on commit 165bcd0

Please sign in to comment.