You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.8 KiB

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