mirror of
https://gitee.com/openharmony/third_party_benchmark
synced 2024-11-27 01:22:14 +00:00
a9beffda0b
* Add myself to CONTRIBUTORS under the corp CLA for Stripe, Inc. * Add support for building with Bazel. Limitations compared to existing CMake rules: * Defaults to using C++11 `<regex>`, with an override via Bazel flag `--define` of `google_benchmark.have_regex`. The TravisCI config sets the regex implementation to `posix` because it uses ancient compilers. * Debug vs Opt mode can't be set per test. TravisCI runs all the tests in debug mode to satisfy `diagnostics_test`, which depends on `CHECK` being live. * Set Bazel workspace name so other repos can refer to it by stable name. This is recommended by the Bazel style guide to avoid each dependent workspace defining its own name for the dependency.
48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
load("//bazel:have_regex.bzl", "have_regex_copts")
|
|
|
|
NEEDS_GTEST_MAIN = [
|
|
"statistics_test.cc",
|
|
]
|
|
|
|
TEST_COPTS = [
|
|
"-pedantic",
|
|
"-pedantic-errors",
|
|
"-std=c++11",
|
|
] + have_regex_copts()
|
|
|
|
TEST_ARGS = ["--benchmark_min_time=0.01"]
|
|
|
|
cc_library(
|
|
name = "output_test_helper",
|
|
testonly = 1,
|
|
srcs = ["output_test_helper.cc"],
|
|
hdrs = ["output_test.h"],
|
|
copts = TEST_COPTS,
|
|
deps = [
|
|
"//:benchmark",
|
|
"//:benchmark_internal_headers",
|
|
],
|
|
)
|
|
|
|
[cc_test(
|
|
name = test_src[:-len(".cc")],
|
|
size = "small",
|
|
srcs = [test_src],
|
|
args = TEST_ARGS + ({
|
|
"user_counters_tabular_test.cc": ["--benchmark_counters_tabular=true"],
|
|
}).get(test_src, []),
|
|
copts = TEST_COPTS + ({
|
|
"cxx03_test.cc": ["-std=c++03"],
|
|
# Some of the issues with DoNotOptimize only occur when optimization is enabled
|
|
"donotoptimize_test.cc": ["-O3"],
|
|
}).get(test_src, []),
|
|
deps = [
|
|
":output_test_helper",
|
|
"//:benchmark",
|
|
"//:benchmark_internal_headers",
|
|
"@com_google_googletest//:gtest",
|
|
] + (
|
|
["@com_google_googletest//:gtest_main"] if (test_src in NEEDS_GTEST_MAIN) else []
|
|
),
|
|
) for test_src in glob(["*_test.cc"])]
|