Skip to content

Commit

Permalink
Fix test #3
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Jul 7, 2024
1 parent 504fd0a commit 8eb58c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 3 additions & 1 deletion go/runfiles/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package runfiles
import (
"io"
"io/fs"
"runtime"
"sort"
"strings"
"time"
Expand All @@ -29,7 +30,8 @@ import (
// apparent repo names that are visible to the current source repo
// (with --enable_bzlmod).
func (r *Runfiles) Open(name string) (fs.File, error) {
if !fs.ValidPath(name) {
// Required by testfs.TestFS.
if !fs.ValidPath(name) || (runtime.GOOS == "windows" && strings.ContainsRune(name, '\\')) {
return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrInvalid}
}
if name == "." {
Expand Down
4 changes: 1 addition & 3 deletions go/runfiles/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ func (m *manifest) open(name string) (fs.File, error) {
if err == ErrEmpty {
return emptyFile(name), nil
} else if err == nil {
// Go through os.DirFs to throw the correct error on invalid paths.
volumePrefix := filepath.VolumeName(r) + "/"
return os.DirFS(volumePrefix).Open(filepath.ToSlash(r[len(volumePrefix):]))
return os.Open(r)
}
}

Expand Down

0 comments on commit 8eb58c0

Please sign in to comment.