Skip to content

Commit

Permalink
internal/tdtest: clean filenames before comparison
Browse files Browse the repository at this point in the history
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 <rogpeppe@gmail.com>
Change-Id: I8d23d96690d1242a45bfc19376b27aaca410753a
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1168708
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.io>
  • Loading branch information
rogpeppe committed Sep 13, 2023
1 parent bfa250d commit 28f34a2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/tdtest/tdtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ package tdtest
import (
"fmt"
"go/token"
"path/filepath"
"reflect"
"runtime"
"strings"
Expand Down Expand Up @@ -110,6 +111,10 @@ func (t *T) getCallInfo() (*info, *callInfo) {
if !ok {
t.Fatalf("could not update file for test %s", t.Name())
}
// Note: it seems that sometimes the file returned by Caller
// might not be in canonical format (under Windows, it can contain
// forward slashes), so clean it.
file = filepath.Clean(file)
info := t.info(file)
return info, info.calls[token.Position{Filename: file, Line: line}]
}
Expand Down

0 comments on commit 28f34a2

Please sign in to comment.