Skip to content

Commit 28f34a2

Browse files
committed
internal/tdtest: clean filenames before comparison
On the evidence of a Windows CI test failure, it appears that runtime.Caller does not always return filenames in OS-canonical format, so Clean them before they can be compared against the files in the Go build. Signed-off-by: Roger Peppe <[email protected]> Change-Id: I8d23d96690d1242a45bfc19376b27aaca410753a Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1168708 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Paul Jolly <[email protected]>
1 parent bfa250d commit 28f34a2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

internal/tdtest/tdtest.go

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ package tdtest
2525
import (
2626
"fmt"
2727
"go/token"
28+
"path/filepath"
2829
"reflect"
2930
"runtime"
3031
"strings"
@@ -110,6 +111,10 @@ func (t *T) getCallInfo() (*info, *callInfo) {
110111
if !ok {
111112
t.Fatalf("could not update file for test %s", t.Name())
112113
}
114+
// Note: it seems that sometimes the file returned by Caller
115+
// might not be in canonical format (under Windows, it can contain
116+
// forward slashes), so clean it.
117+
file = filepath.Clean(file)
113118
info := t.info(file)
114119
return info, info.calls[token.Position{Filename: file, Line: line}]
115120
}

0 commit comments

Comments
 (0)