From cba816a7c402655b2756b7c05cd30445d6988e56 Mon Sep 17 00:00:00 2001 From: Sanjay Ghemawat Date: Fri, 27 Sep 2024 16:16:15 -0700 Subject: [PATCH] Report missing file name as "", not "." (#899) --- internal/report/shortnames.go | 4 ++++ internal/report/shortnames_test.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/report/shortnames.go b/internal/report/shortnames.go index 438624e8..4663573a 100644 --- a/internal/report/shortnames.go +++ b/internal/report/shortnames.go @@ -29,6 +29,10 @@ var ( // fileNameSuffixes returns a non-empty sequence of shortened file names // (in decreasing preference) that can be used to represent name. func fileNameSuffixes(name string) []string { + if name == "" { + // Avoid returning "." when symbol info is missing + return []string{""} + } return allSuffixes(filepath.ToSlash(filepath.Clean(name)), fileSepRE) } diff --git a/internal/report/shortnames_test.go b/internal/report/shortnames_test.go index 01cbcff9..820cd4d4 100644 --- a/internal/report/shortnames_test.go +++ b/internal/report/shortnames_test.go @@ -44,7 +44,7 @@ func TestFileNameSuffixes(t *testing.T) { } for _, c := range []testCase{ - test("empty", "", "."), + test("empty", "", ""), test("simple", "foo", "foo"), test("manypaths", "a/b/c", "a/b/c", "b/c", "c"), test("leading", "/a/b", "/a/b", "a/b", "b"),