Merge "Improve error message for missing path + local dir"

This commit is contained in:
Treehugger Robot
2022-01-05 16:37:25 +00:00
committed by Gerrit Code Review
2 changed files with 7 additions and 4 deletions

View File

@@ -1484,7 +1484,7 @@ func rewriteLicenseProperties(mod *parser.Module, patchList *parser.PatchList, f
ok := hasFile(relativePath+"/Android.mk", fs) ok := hasFile(relativePath+"/Android.mk", fs)
// some modules in the existing test cases in the androidmk_test.go do not have a valid path // some modules in the existing test cases in the androidmk_test.go do not have a valid path
if !ok && len(relativePath) > 0 { if !ok && len(relativePath) > 0 {
return fmt.Errorf("Cannot find an Android.mk file at path %s", relativePath) return fmt.Errorf("Cannot find an Android.mk file at path %q", relativePath)
} }
licenseKindsPropertyName := "android_license_kinds" licenseKindsPropertyName := "android_license_kinds"
@@ -1661,9 +1661,12 @@ func getDirFromProperty(mod *parser.Module, property string, fs pathtools.FileSy
// if empty // if empty
return "", fmt.Errorf("Cannot find the value of the %s.%s property", mod.Type, property) return "", fmt.Errorf("Cannot find the value of the %s.%s property", mod.Type, property)
} }
if relativePath == "" {
relativePath = "."
}
_, isDir, _ := fs.Exists(relativePath) _, isDir, _ := fs.Exists(relativePath)
if !isDir { if !isDir {
return "", fmt.Errorf("Cannot find the path %s", relativePath) return "", fmt.Errorf("Cannot find the path %q", relativePath)
} }
path := relativePath path := relativePath
for { for {
@@ -1675,7 +1678,7 @@ func getDirFromProperty(mod *parser.Module, property string, fs pathtools.FileSy
} }
_, isDir, _ = fs.Exists(path) _, isDir, _ = fs.Exists(path)
if !isDir { if !isDir {
return "", fmt.Errorf("Cannot find the path %s", path) return "", fmt.Errorf("Cannot find the path %q", path)
} }
return path, nil return path, nil
} }

View File

@@ -1936,7 +1936,7 @@ func TestRewriteLicenseProperty(t *testing.T) {
fs: mockFs, fs: mockFs,
path: relativePathErr, path: relativePathErr,
expectedErr: ` expectedErr: `
Cannot find an Android.mk file at path a/b/c Cannot find an Android.mk file at path "a/b/c"
`, `,
}, },
} }