Skip to content

Commit

Permalink
go_bazel_test: wrapper and test library for running Bazel from go_test (
Browse files Browse the repository at this point in the history
#2109)

go_bazel_test is a macro that wraps go_test. It will be used for
integration tests in rules_go as a replacement for bazel_test. The
macro adds dependencies on bazel_testing and runfiles from rules_go.

bazel_testing is a new test framework. Its TestMain function may be
called to construct a Bazel workspace (specified as a txtar
archive). Tests are run within this workspace. Bazel may be invoked
with the RunBazel function.

Updates #1508
Updates #1959
  • Loading branch information
Jay Conrod committed Jul 8, 2019
1 parent 1467611 commit 4e329a0
Show file tree
Hide file tree
Showing 21 changed files with 827 additions and 28 deletions.
14 changes: 14 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,17 @@ lines_sorted_test(
exports_files(["AUTHORS"])

go_info()

filegroup(
name = "all_files",
testonly = True,
srcs = [
"BUILD.bazel",
"WORKSPACE",
"//extras:all_files",
"//go:all_files",
"//proto:all_files",
"//third_party:all_files",
],
visibility = ["//visibility:public"],
)
7 changes: 7 additions & 0 deletions extras/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ filegroup(
srcs = glob(["*.bzl"]) + ["//go/private:all_rules"],
visibility = ["//visibility:public"],
)

filegroup(
name = "all_files",
testonly = True,
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)
12 changes: 12 additions & 0 deletions go/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
filegroup(
name = "all_files",
testonly = True,
srcs = glob(["**"]) + [
"//go/platform:all_files",
"//go/toolchain:all_files",
"//go/tools:all_files",
"//go/private:all_files",
],
visibility = ["//visibility:public"],
)

filegroup(
name = "all_rules",
srcs = glob(["*.bzl"]) + ["//go/private:all_rules"],
Expand Down
7 changes: 7 additions & 0 deletions go/platform/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ package(default_visibility = ["//visibility:public"])
load(":list.bzl", "declare_config_settings")

declare_config_settings()

filegroup(
name = "all_files",
testonly = True,
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)
7 changes: 7 additions & 0 deletions go/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ filegroup(
visibility = ["//visibility:public"],
)

filegroup(
name = "all_files",
testonly = True,
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)

config_setting(
name = "strip-always",
values = {"strip": "always"},
Expand Down
7 changes: 7 additions & 0 deletions go/toolchain/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ load(
package(default_visibility = ["//visibility:public"])

declare_constraints()

filegroup(
name = "all_files",
testonly = True,
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)
10 changes: 10 additions & 0 deletions go/tools/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
filegroup(
name = "all_files",
testonly = True,
srcs = [
"//go/tools/bazel:all_files",
"//go/tools/builders:all_files",
"//go/tools/coverdata:all_files",
],
visibility = ["//visibility:public"],
)
7 changes: 7 additions & 0 deletions go/tools/bazel/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ go_test(
)

# Runfiles functionality in this package is tested by //tests/core/runfiles.

filegroup(
name = "all_files",
testonly = True,
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)
12 changes: 12 additions & 0 deletions go/tools/bazel_testing/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["bazel_testing.go"],
importpath = "github.com/bazelbuild/rules_go/go/tools/bazel_testing",
visibility = ["//visibility:public"],
deps = [
"//go/tools/bazel:go_default_library",
"//go/tools/internal/txtar:go_default_library",
],
)
Loading

0 comments on commit 4e329a0

Please sign in to comment.