Skip to content

Commit

Permalink
Rewriting core tests BUILD files to use the build system.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasnoble committed Apr 18, 2017
1 parent 7c26eed commit 15cd5ce
Show file tree
Hide file tree
Showing 26 changed files with 302 additions and 245 deletions.
15 changes: 12 additions & 3 deletions bazel/grpc_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
# use to generate other platform's build system files.
#

def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [], external_deps = [], deps = [], standalone = False, language = "C++"):
def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [],
external_deps = [], deps = [], standalone = False,
language = "C++", testonly = False, visibility = None):
copts = []
if language.upper() == "C":
copts = ["-std=c99"]
Expand All @@ -43,6 +45,8 @@ def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [], external_deps
hdrs = hdrs + public_hdrs,
deps = deps + ["//external:" + dep for dep in external_deps],
copts = copts,
visibility = visibility,
testonly = testonly,
linkopts = ["-pthread"],
includes = [
"include"
Expand All @@ -69,7 +73,7 @@ def grpc_proto_library(name, srcs = [], deps = [], well_known_protos = None,
use_external = use_external,
)

def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data = []):
def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++"):
native.cc_test(
name = name,
srcs = srcs,
Expand All @@ -79,12 +83,17 @@ def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data
linkopts = ["-pthread"],
)

def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], data = []):
def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++", testonly = False):
copts = []
if language.upper() == "C":
copts = ["-std=c99"]
native.cc_binary(
name = name,
srcs = srcs,
args = args,
data = data,
testonly = testonly,
deps = deps + ["//external:" + dep for dep in external_deps],
copts = copts,
linkopts = ["-pthread"],
)
2 changes: 2 additions & 0 deletions test/core/bad_client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary")

licenses(["notice"]) # 3-clause BSD

load(":generate_tests.bzl", "grpc_bad_client_tests")
Expand Down
2 changes: 2 additions & 0 deletions test/core/bad_ssl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary")

licenses(["notice"]) # 3-clause BSD

load(":generate_tests.bzl", "grpc_bad_ssl_tests")
Expand Down
18 changes: 10 additions & 8 deletions test/core/census/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary")

licenses(["notice"]) # 3-clause BSD

cc_test(
grpc_cc_test(
name = "context_test",
srcs = ["context_test.c"],
copts = ["-std=c99"],
language = "C",
deps = [
"//:gpr",
"//:grpc",
Expand All @@ -41,10 +43,10 @@ cc_test(
],
)

cc_test(
grpc_cc_test(
name = "mlog_test",
srcs = ["mlog_test.c"],
copts = ["-std=c99"],
language = "C",
deps = [
"//:gpr",
"//:grpc",
Expand All @@ -53,10 +55,10 @@ cc_test(
],
)

cc_test(
grpc_cc_test(
name = "resource_test",
srcs = ["resource_test.c"],
copts = ["-std=c99"],
language = "C",
data = [
":data/resource_empty_name.pb",
":data/resource_full.pb",
Expand All @@ -73,10 +75,10 @@ cc_test(
],
)

cc_test(
grpc_cc_test(
name = "trace_context_test",
srcs = ["trace_context_test.c"],
copts = ["-std=c99"],
language = "C",
data = [
":data/context_empty.pb",
":data/context_full.pb",
Expand Down
10 changes: 6 additions & 4 deletions test/core/channel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary")

licenses(["notice"]) # 3-clause BSD

cc_test(
grpc_cc_test(
name = "channel_args_test",
srcs = ["channel_args_test.c"],
copts = ["-std=c99"],
language = "C",
deps = [
"//:gpr",
"//:grpc",
Expand All @@ -41,10 +43,10 @@ cc_test(
],
)

cc_test(
grpc_cc_test(
name = "channel_stack_test",
srcs = ["channel_stack_test.c"],
copts = ["-std=c99"],
language = "C",
deps = [
"//:gpr",
"//:grpc",
Expand Down
8 changes: 5 additions & 3 deletions test/core/client_channel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary")

licenses(["notice"]) # 3-clause BSD

load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")

grpc_fuzzer(
name = "uri_fuzzer_test",
srcs = ["uri_fuzzer_test.c"],
copts = ["-std=c99"],
language = "C",
corpus = "uri_corpus",
deps = [
"//:gpr",
Expand All @@ -43,10 +45,10 @@ grpc_fuzzer(
],
)

cc_test(
grpc_cc_test(
name = "lb_policies_test",
srcs = ["lb_policies_test.c"],
copts = ["-std=c99"],
language = "C",
deps = [
"//:gpr",
"//:grpc",
Expand Down
14 changes: 8 additions & 6 deletions test/core/client_channel/resolvers/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary")

licenses(["notice"]) # 3-clause BSD

cc_test(
grpc_cc_test(
name = "dns_resolver_connectivity_test",
srcs = ["dns_resolver_connectivity_test.c"],
copts = ["-std=c99"],
language = "C",
deps = [
"//:gpr",
"//:grpc",
Expand All @@ -41,10 +43,10 @@ cc_test(
],
)

cc_test(
grpc_cc_test(
name = "dns_resolver_test",
srcs = ["dns_resolver_test.c"],
copts = ["-std=c99"],
language = "C",
deps = [
"//:gpr",
"//:grpc",
Expand All @@ -53,10 +55,10 @@ cc_test(
],
)

cc_test(
grpc_cc_test(
name = "sockaddr_resolver_test",
srcs = ["sockaddr_resolver_test.c"],
copts = ["-std=c99"],
language = "C",
deps = [
"//:gpr",
"//:grpc",
Expand Down
14 changes: 8 additions & 6 deletions test/core/compression/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary")

licenses(["notice"]) # 3-clause BSD

cc_test(
grpc_cc_test(
name = "algorithm_test",
srcs = ["algorithm_test.c"],
copts = ["-std=c99"],
language = "C",
deps = [
"//:gpr",
"//:grpc",
Expand All @@ -41,10 +43,10 @@ cc_test(
],
)

cc_test(
grpc_cc_test(
name = "compression_test",
srcs = ["compression_test.c"],
copts = ["-std=c99"],
language = "C",
deps = [
"//:gpr",
"//:grpc",
Expand All @@ -53,10 +55,10 @@ cc_test(
],
)

cc_test(
grpc_cc_test(
name = "message_compress_test",
srcs = ["message_compress_test.c"],
copts = ["-std=c99"],
language = "C",
deps = [
"//:gpr",
"//:grpc",
Expand Down
22 changes: 12 additions & 10 deletions test/core/end2end/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary")

licenses(["notice"]) # 3-clause BSD

load(":generate_tests.bzl", "grpc_end2end_tests")

cc_library(
grpc_cc_library(
name = "cq_verifier",
srcs = ["cq_verifier.c"],
hdrs = ["cq_verifier.h"],
copts = ["-std=c99"],
language = "C",
visibility = ["//test:__subpackages__"],
deps = [
"//:gpr",
Expand All @@ -44,7 +46,7 @@ cc_library(
],
)

cc_library(
grpc_cc_library(
name = "ssl_test_data",
srcs = [
"data/client_certs.c",
Expand All @@ -53,39 +55,39 @@ cc_library(
"data/test_root_cert.c",
],
hdrs = ["data/ssl_test_data.h"],
copts = ["-std=c99"],
language = "C",
visibility = ["//test:__subpackages__"],
)

cc_library(
grpc_cc_library(
name = "fake_resolver",
srcs = ["fake_resolver.c"],
hdrs = ["fake_resolver.h"],
copts = ["-std=c99"],
language = "C",
deps = [
"//:gpr",
"//:grpc",
"//test/core/util:grpc_test_util",
],
)

cc_library(
grpc_cc_library(
name = "http_proxy",
srcs = ["fixtures/http_proxy_fixture.c"],
hdrs = ["fixtures/http_proxy_fixture.h"],
copts = ["-std=c99"],
language = "C",
deps = [
"//:gpr",
"//:grpc",
"//test/core/util:grpc_test_util",
],
)

cc_library(
grpc_cc_library(
name = "proxy",
srcs = ["fixtures/proxy.c"],
hdrs = ["fixtures/proxy.h"],
copts = ["-std=c99"],
language = "C",
deps = [
"//:gpr",
"//:grpc",
Expand Down
8 changes: 5 additions & 3 deletions test/core/end2end/fuzzers/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary")

licenses(["notice"]) # 3-clause BSD

load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")

grpc_fuzzer(
name = "api_fuzzer",
srcs = ["api_fuzzer.c"],
copts = ["-std=c99"],
language = "C",
corpus = "api_fuzzer_corpus",
deps = [
"//:gpr",
Expand All @@ -47,7 +49,7 @@ grpc_fuzzer(
grpc_fuzzer(
name = "client_fuzzer",
srcs = ["client_fuzzer.c"],
copts = ["-std=c99"],
language = "C",
corpus = "client_fuzzer_corpus",
deps = [
"//:gpr",
Expand All @@ -59,7 +61,7 @@ grpc_fuzzer(
grpc_fuzzer(
name = "server_fuzzer",
srcs = ["server_fuzzer.c"],
copts = ["-std=c99"],
language = "C",
corpus = "server_fuzzer_corpus",
deps = [
"//:gpr",
Expand Down
Loading

0 comments on commit 15cd5ce

Please sign in to comment.