Skip to content

Commit

Permalink
Move new runfiles library to //go/runfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Nov 7, 2022
1 parent 6393d3e commit 1915352
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ go_library(
"manifest.go",
"runfiles.go",
],
importpath = "github.com/bazelbuild/rules_go/go/tools/bazel/runfiles",
importpath = "github.com/bazelbuild/rules_go/go/runfiles",
visibility = ["//visibility:public"],
)

Expand All @@ -35,15 +35,15 @@ go_test(
],
data = [
"test.txt",
"//go/tools/bazel/runfiles/testprog",
"//go/runfiles/testprog",
"@bazel_tools//tools/bash/runfiles",
],
deps = [":runfiles"],
)

exports_files(
["test.txt"],
visibility = ["//go/tools/bazel/runfiles/testprog:__pkg__"],
visibility = ["//go/runfiles/testprog:__pkg__"],
)

alias(
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions go/tools/bazel/runfiles/fs_test.go → go/runfiles/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"testing"
"testing/fstest"

"github.com/bazelbuild/rules_go/go/tools/bazel/runfiles"
"github.com/bazelbuild/rules_go/go/runfiles"
)

func TestFS(t *testing.T) {
Expand All @@ -43,9 +43,9 @@ func TestFS(t *testing.T) {
if runtime.GOOS == "windows" {
// Currently the result of
//
// fsys.Path("io_bazel_rules_go/go/tools/bazel/runfiles/test.txt")
// fsys.Path("io_bazel_rules_go/go/runfiles/test.txt")
// fsys.Path("bazel_tools/tools/bash/runfiles/runfiles.bash")
// fsys.Path("io_bazel_rules_go/go/tools/bazel/runfiles/testprog/testprog")
// fsys.Path("io_bazel_rules_go/go/runfiles/testprog/testprog")
//
// would be a full path like these
//
Expand All @@ -59,8 +59,8 @@ func TestFS(t *testing.T) {
return
}

expected1 := "io_bazel_rules_go/go/tools/bazel/runfiles/test.txt"
expected2 := "io_bazel_rules_go/go/tools/bazel/runfiles/testprog/testprog_/testprog"
expected1 := "io_bazel_rules_go/go/runfiles/test.txt"
expected2 := "io_bazel_rules_go/go/runfiles/testprog/testprog_/testprog"
expected3 := "bazel_tools/tools/bash/runfiles/runfiles.bash"
if err := fstest.TestFS(fsys, expected1, expected2, expected3); err != nil {
t.Error(err)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import (
"strings"
"testing"

"github.com/bazelbuild/rules_go/go/tools/bazel/runfiles"
"github.com/bazelbuild/rules_go/go/runfiles"
)

func TestPath_FileLookup(t *testing.T) {
path, err := runfiles.Path("io_bazel_rules_go/go/tools/bazel/runfiles/test.txt")
path, err := runfiles.Path("io_bazel_rules_go/go/runfiles/test.txt")
if err != nil {
t.Fatal(err)
}
Expand All @@ -49,7 +49,7 @@ func TestPath_SubprocessRunfilesLookup(t *testing.T) {
}
// The binary “testprog” is itself built with Bazel, and needs
// runfiles.
testprogRpath := "io_bazel_rules_go/go/tools/bazel/runfiles/testprog/testprog_/testprog"
testprogRpath := "io_bazel_rules_go/go/runfiles/testprog/testprog_/testprog"
if runtime.GOOS == "windows" {
testprogRpath += ".exe"
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "testprog_lib",
srcs = ["main.go"],
importpath = "github.com/bazelbuild/rules_go/go/tools/bazel/runfiles/testprog",
importpath = "github.com/bazelbuild/rules_go/go/runfiles/testprog",
visibility = ["//visibility:private"],
deps = ["//go/tools/bazel/runfiles"],
deps = ["//go/runfiles"],
)

go_binary(
name = "testprog",
data = ["//go/tools/bazel/runfiles:test.txt"],
data = ["//go/runfiles:test.txt"],
embed = [":testprog_lib"],
visibility = ["//go/tools/bazel/runfiles:__pkg__"],
visibility = ["//go/runfiles:__pkg__"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
"fmt"
"io/ioutil"

"github.com/bazelbuild/rules_go/go/tools/bazel/runfiles"
"github.com/bazelbuild/rules_go/go/runfiles"
)

func main() {
path, err := runfiles.Path("io_bazel_rules_go/go/tools/bazel/runfiles/test.txt")
path, err := runfiles.Path("io_bazel_rules_go/go/runfiles/test.txt")
if err != nil {
panic(err)
}
Expand Down
6 changes: 3 additions & 3 deletions go/tools/bazel/runfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ const (
// binaries invoked with 'bazel run'. On Windows,
// only tests invoked with 'bazel test' are supported.
//
// Deprecated: Use github.com/bazelbuild/rules_go/go/tools/bazel/runfiles
// instead for cross-platform support matching the behavior of the
// Bazel-provided runfiles libraries.
// Deprecated: Use github.com/bazelbuild/rules_go/go/runfiles instead for
// cross-platform support matching the behavior of the Bazel-provided runfiles
// libraries.
func Runfile(path string) (string, error) {
// Search in working directory
if _, err := os.Stat(path); err == nil {
Expand Down

0 comments on commit 1915352

Please sign in to comment.