1TEST_COPTS = [ 2 "-pedantic", 3 "-pedantic-errors", 4 "-std=c++11", 5 "-Wall", 6 "-Wextra", 7 "-Wshadow", 8 # "-Wshorten-64-to-32", 9 "-Wfloat-equal", 10 "-fstrict-aliasing", 11] 12 13PER_SRC_COPTS = ({ 14 "cxx03_test.cc": ["-std=c++03"], 15 # Some of the issues with DoNotOptimize only occur when optimization is enabled 16 "donotoptimize_test.cc": ["-O3"], 17}) 18 19TEST_ARGS = ["--benchmark_min_time=0.01"] 20 21PER_SRC_TEST_ARGS = ({ 22 "user_counters_tabular_test.cc": ["--benchmark_counters_tabular=true"], 23}) 24 25load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") 26 27cc_library( 28 name = "output_test_helper", 29 testonly = 1, 30 srcs = ["output_test_helper.cc"], 31 hdrs = ["output_test.h"], 32 copts = TEST_COPTS, 33 deps = [ 34 "//:benchmark", 35 "//:benchmark_internal_headers", 36 ], 37) 38 39[ 40 cc_test( 41 name = test_src[:-len(".cc")], 42 size = "small", 43 srcs = [test_src], 44 args = TEST_ARGS + PER_SRC_TEST_ARGS.get(test_src, []), 45 copts = TEST_COPTS + PER_SRC_COPTS.get(test_src, []), 46 deps = [ 47 ":output_test_helper", 48 "//:benchmark", 49 "//:benchmark_internal_headers", 50 "@com_google_googletest//:gtest", 51 ] + ( 52 ["@com_google_googletest//:gtest_main"] if (test_src[-len("gtest.cc"):] == "gtest.cc") else [] 53 ), 54 # FIXME: Add support for assembly tests to bazel. 55 # See Issue #556 56 # https://github.com/google/benchmark/issues/556 57 ) 58 for test_src in glob( 59 ["*test.cc"], 60 exclude = [ 61 "*_assembly_test.cc", 62 "link_main_test.cc", 63 ], 64 ) 65] 66 67cc_test( 68 name = "link_main_test", 69 size = "small", 70 srcs = ["link_main_test.cc"], 71 copts = TEST_COPTS, 72 deps = ["//:benchmark_main"], 73) 74