Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions check/checktest/checktest.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,13 @@ func compile(
moduleName descriptor.ModuleName,
) ([]descriptor.FileDescriptor, error) {
dirPaths = fromSlashPaths(dirPaths)
filePaths = fromSlashPaths(filePaths)
// The compiler names each file by the path it is given, and .proto file
// names use forward slashes even on Windows.
toSlashFilePaths := make([]string, len(filePaths))
toSlashFilePathMap := make(map[string]struct{}, len(filePaths))
for _, filePath := range filePaths {
toSlashFilePathMap[filepath.ToSlash(filePath)] = struct{}{}
for i, filePath := range fromSlashPaths(filePaths) {
toSlashFilePaths[i] = filepath.ToSlash(filePath)
toSlashFilePathMap[toSlashFilePaths[i]] = struct{}{}
}

var warningErrorsWithPos []reporter.ErrorWithPos
Expand All @@ -360,7 +363,7 @@ func compile(
// This is what buf uses.
SourceInfoMode: protocompile.SourceInfoExtraOptionLocations,
}
files, err := compiler.Compile(ctx, filePaths...)
files, err := compiler.Compile(ctx, toSlashFilePaths...)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,25 @@ func TestSimpleFailure(t *testing.T) {
},
}.Run(t)
}

func TestSubdirectoryFailure(t *testing.T) {
t.Parallel()

checktest.CheckTest{
Request: &checktest.RequestSpec{
Files: &checktest.ProtoFileSpec{
DirPaths: []string{"testdata/subdirectory_failure"},
FilePaths: []string{"sub/simple.proto"},
},
},
Spec: spec,
ExpectedAnnotations: []checktest.ExpectedAnnotation{
{
RuleID: syntaxSpecifiedRuleID,
FileLocation: &checktest.ExpectedFileLocation{
FileName: "sub/simple.proto",
},
},
},
}.Run(t)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package simple;
Loading