2019-04-18 19:51:19 +02:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
2019-11-06 05:19:17 +01:00
|
|
|
#
|
|
|
|
# defs.bzl - Definitions for Facebook-specific buck build integration
|
|
|
|
# in TARGETS
|
2019-04-18 19:51:19 +02:00
|
|
|
|
2020-03-20 18:51:48 +01:00
|
|
|
load("@fbcode_macros//build_defs:coverage.bzl", "coverage")
|
2019-02-28 20:35:30 +01:00
|
|
|
load("@fbcode_macros//build_defs:cpp_binary.bzl", "cpp_binary")
|
|
|
|
load("@fbcode_macros//build_defs:custom_unittest.bzl", "custom_unittest")
|
|
|
|
|
|
|
|
def test_binary(
|
|
|
|
test_name,
|
|
|
|
test_cc,
|
|
|
|
parallelism,
|
|
|
|
rocksdb_arch_preprocessor_flags,
|
2019-07-25 20:42:31 +02:00
|
|
|
rocksdb_os_preprocessor_flags,
|
2019-02-28 20:35:30 +01:00
|
|
|
rocksdb_compiler_flags,
|
|
|
|
rocksdb_preprocessor_flags,
|
2019-07-25 20:42:31 +02:00
|
|
|
rocksdb_external_deps,
|
2019-08-02 19:40:32 +02:00
|
|
|
rocksdb_os_deps,
|
|
|
|
extra_deps,
|
|
|
|
extra_compiler_flags):
|
2019-02-28 20:35:30 +01:00
|
|
|
TEST_RUNNER = native.package_name() + "/buckifier/rocks_test_runner.sh"
|
|
|
|
|
|
|
|
ttype = "gtest" if parallelism == "parallel" else "simple"
|
|
|
|
test_bin = test_name + "_bin"
|
|
|
|
|
|
|
|
cpp_binary(
|
|
|
|
name = test_bin,
|
|
|
|
srcs = [test_cc],
|
|
|
|
arch_preprocessor_flags = rocksdb_arch_preprocessor_flags,
|
2019-07-25 20:42:31 +02:00
|
|
|
os_preprocessor_flags = rocksdb_os_preprocessor_flags,
|
2019-08-02 19:40:32 +02:00
|
|
|
compiler_flags = rocksdb_compiler_flags + extra_compiler_flags,
|
2019-02-28 20:35:30 +01:00
|
|
|
preprocessor_flags = rocksdb_preprocessor_flags,
|
2019-08-02 19:40:32 +02:00
|
|
|
deps = [":rocksdb_test_lib"] + extra_deps,
|
2019-07-25 20:42:31 +02:00
|
|
|
os_deps = rocksdb_os_deps,
|
2019-02-28 20:35:30 +01:00
|
|
|
external_deps = rocksdb_external_deps,
|
|
|
|
)
|
|
|
|
|
2020-03-13 01:45:04 +01:00
|
|
|
binary_path = "$(location :{})".format(test_bin)
|
|
|
|
|
2020-03-20 18:51:48 +01:00
|
|
|
base_path = native.package_name()
|
|
|
|
tags = []
|
|
|
|
if coverage.is_coverage_enabled(base_path):
|
|
|
|
# This tag instructs testpilot to use
|
|
|
|
# the lower-memory coverage runner
|
|
|
|
# (e.g. it tells testpilot that the binary
|
|
|
|
# is actually instrumented with coverage info)
|
|
|
|
tags = ["coverage"]
|
|
|
|
|
2019-02-28 20:35:30 +01:00
|
|
|
custom_unittest(
|
|
|
|
name = test_name,
|
2020-03-13 01:45:04 +01:00
|
|
|
command = [TEST_RUNNER, binary_path],
|
2019-02-28 20:35:30 +01:00
|
|
|
type = ttype,
|
2020-03-13 01:45:04 +01:00
|
|
|
env = {"BUCK_BASE_BINARY": binary_path},
|
2020-03-20 18:51:48 +01:00
|
|
|
tags = tags,
|
2019-02-28 20:35:30 +01:00
|
|
|
)
|