Skip to content

Commit

Permalink
rules_proto is testonly
Browse files Browse the repository at this point in the history
  • Loading branch information
grencez committed Jun 11, 2024
1 parent 4f1cb22 commit 6424eb1
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 35 deletions.
9 changes: 7 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ module(
bazel_dep(name = "bazel_skylib", version = "1.2.0")
bazel_dep(name = "fildesh", version = "0.1.9")
bazel_dep(name = "protobuf", version = "3.19.6")
bazel_dep(name = "rules_proto", version = "4.0.0")

git_override(
module_name = "fildesh",
commit = "b8ff76bc9f8aa9b063a04891a7ad0460f3522d88",
remote = "https://github.com/grencez/fildesh.git",
commit="b8ff76bc9f8aa9b063a04891a7ad0460f3522d88",
)

bazel_dep(
name = "rules_proto",
version = "6.0.0.bcr.1",
dev_dependency = True,
)
16 changes: 13 additions & 3 deletions example/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,59 +1,69 @@
load("//sxproto:defs.bzl", "sxproto_data")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//sxproto:defs.bzl", "sxproto_data")

package(default_visibility = [
"//test:__subpackages__",
])

proto_library(
name = "intro_proto",
testonly = True,
srcs = ["intro.proto"],
)

sxproto_data(
name = "intro_1_scalar",
testonly = True,
src = "intro_1_scalar.sxpb",
proto_deps = ["intro_proto"],
proto_message = "IntroMessage",
)

sxproto_data(
name = "intro_2_message",
testonly = True,
src = "intro_2_message.sxpb",
proto_deps = ["intro_proto"],
proto_message = "IntroMessage",
)

sxproto_data(
name = "intro_3_empty_message",
testonly = True,
src = "intro_3_empty_message.sxpb",
proto_deps = ["intro_proto"],
proto_message = "IntroMessage",
)

sxproto_data(
name = "intro_5_array",
testonly = True,
src = "intro_5_array.sxpb",
proto_deps = ["intro_proto"],
proto_message = "IntroMessage",
)


proto_library(
name = "grocery_proto",
testonly = True,
srcs = ["grocery.proto"],
)

sxproto_data(
name = "popcorn_data",
testonly = True,
src = "popcorn.sxpb",
proto_deps = ["grocery_proto"],
proto_message = "GroceryListItem",
)

sxproto_data(
name = "sauces_data",
testonly = True,
src = "sauces.sxpb",
out_textproto = "sauces_data.txtpb",
out_json = "sauces_data.json",
out_json_camelcase = "sauces_data_camelcase.json",
out_textproto = "sauces_data.txtpb",
proto_deps = ["grocery_proto"],
proto_message = "GroceryList",
)
Expand Down
30 changes: 15 additions & 15 deletions test/depend/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//sxproto:defs.bzl", "sxproto_data", "protobuf_equality_test")
load("//sxproto:defs.bzl", "protobuf_equality_test", "sxproto_data")

proto_library(
name = "shopping_proto",
testonly = True,
srcs = ["shopping.proto"],
deps = ["//example:grocery_proto"],
testonly = 1,
)

cc_proto_library(
name = "shopping_cc_proto",
testonly = True,
deps = [":shopping_proto"],
testonly = 1,
)

sxproto_data(
name = "shopping_data",
testonly = True,
src = "shopping.sxpb",
out_textproto = "shopping_data.txtpb",
proto_deps = [":shopping_proto"],
proto_message = "sxproto.test.depend.ShoppingList",
testonly = 1,
)

cc_test(
name = "shopping_expect_test",
size = "small",
srcs = ["shopping_expect_test.cc"],
deps = [":shopping_cc_proto"],
data = [":shopping_data"],
args = ["$(location :shopping_data)"],
size = "small",
data = [":shopping_data"],
deps = [":shopping_cc_proto"],
)

protobuf_equality_test(
name = "shopping_textproto_equality_test",
srcs = [
"shopping_data.txtpb",
"shopping_data",
"shopping_data.txtpb",
],
proto_deps = [":shopping_proto"],
proto_message = "sxproto.test.depend.ShoppingList",
)

proto_library(
name = "task_proto",
testonly = True,
srcs = ["task.proto"],
deps = [":shopping_proto"],
testonly = 1,
)

sxproto_data(
name = "task_data",
testonly = True,
src = "task.sxpb",
out_json = "task_data.json",
proto_deps = [":task_proto"],
proto_message = "sxproto.test.depend.TaskList",
testonly = 1,
)

cc_proto_library(
name = "task_cc_proto",
testonly = True,
deps = [":task_proto"],
testonly = 1,
)

cc_test(
name = "task_expect_test",
size = "small",
srcs = ["task_expect_test.cc"],
deps = [":task_cc_proto"],
data = [":task_data"],
args = ["$(location :task_data)"],
size = "small",
data = [":task_data"],
deps = [":task_cc_proto"],
)

protobuf_equality_test(
name = "task_json_equality_test",
srcs = [
"task_data.json",
"task_data",
"task_data.json",
],
proto_deps = [":task_proto"],
proto_message = "sxproto.test.depend.TaskList",
Expand Down
6 changes: 3 additions & 3 deletions test/loneof/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load(
"//sxproto:defs.bzl",
"sxproto_data",
"protobuf_equality_test",
"sxproto_data",
)

proto_library(
name = "travel_proto",
testonly = True,
srcs = ["travel.proto"],
testonly = 1,
)

sxproto_data(
name = "travel_sxproto_data",
testonly = True,
src = "travel.sxpb",
out_json = "travel_sxproto_data.json",
out_textproto = "travel_sxproto_data.txtpb",
proto_deps = [":travel_proto"],
proto_message = "sxproto.test.loneof.Travel",
testonly = 1,
)

protobuf_equality_test(
Expand Down
27 changes: 15 additions & 12 deletions test/manyof/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,47 @@ load("@fildesh//tool/bazel:cmptxt_test.bzl", "cmptxt_test")
load("@rules_proto//proto:defs.bzl", "proto_library")
load(
"//sxproto:defs.bzl",
"sxproto_data", "data_sxproto",
"json_data", "data_json", "data_json_camelcase",
"data_textproto", "textproto_data",
"data_json",
"data_json_camelcase",
"data_sxproto",
"data_textproto",
"json_data",
"protobuf_equality_test",
"sxproto_data",
"textproto_data",
)

proto_library(
name = "boolexpr_proto",
testonly = True,
srcs = ["boolexpr.proto"],
testonly = 1,
)

sxproto_data(
name = "boolexpr_sxproto_data",
testonly = True,
src = "boolexpr.sxpb",
out_json = "boolexpr_sxproto_data.json",
out_textproto = "boolexpr_sxproto_data.txtpb",
out_yaml = "boolexpr_sxproto_data.yaml",
proto_deps = [":boolexpr_proto"],
proto_message = "sxproto.test.manyof.BooleanExpressionList",
testonly = 1,
)

textproto_data(
name = "boolexpr_textproto_data",
testonly = True,
src = "boolexpr.txtpb",
proto_deps = [":boolexpr_proto"],
proto_message = "sxproto.test.manyof.BooleanExpressionList",
testonly = 1,
)

json_data(
name = "boolexpr_json_data",
testonly = True,
src = "boolexpr.json",
proto_deps = [":boolexpr_proto"],
proto_message = "sxproto.test.manyof.BooleanExpressionList",
testonly = 1,
)

protobuf_equality_test(
Expand Down Expand Up @@ -71,29 +75,28 @@ protobuf_equality_test(
proto_message = "sxproto.test.manyof.BooleanExpressionList",
)


data_sxproto(
name = "boolexpr_data_sxproto",
testonly = True,
src = ":boolexpr_sxproto_data",
proto_deps = [":boolexpr_proto"],
proto_message = "sxproto.test.manyof.BooleanExpressionList",
testonly = 1,
)

data_textproto(
name = "boolexpr_data_textproto",
testonly = True,
src = ":boolexpr_sxproto_data",
proto_deps = [":boolexpr_proto"],
proto_message = "sxproto.test.manyof.BooleanExpressionList",
testonly = 1,
)

data_json(
name = "boolexpr_data_json",
testonly = True,
src = ":boolexpr_sxproto_data",
proto_deps = [":boolexpr_proto"],
proto_message = "sxproto.test.manyof.BooleanExpressionList",
testonly = 1,
)

protobuf_equality_test(
Expand Down Expand Up @@ -129,7 +132,7 @@ protobuf_equality_test(
cmptxt_test(
name = "boolexpr_data_yaml_equality_test",
srcs = [
":boolexpr.yaml",
"boolexpr_sxproto_data.yaml",
":boolexpr.yaml",
],
)

0 comments on commit 6424eb1

Please sign in to comment.