BUILD 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #
  5. # Trivial, single-file testing libraries. More complex libraries should get
  6. # their own directory.
  7. load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
  8. package(default_visibility = ["//visibility:public"])
  9. # This does extra initialization on top of googletest's gtest_main in order to
  10. # provide stack traces on unexpected exits, because we normally rely on LLVM
  11. # code for that.
  12. #
  13. # This replaces "@googletest//:gtest_main";
  14. # "@googletest//:gtest" should still be used directly.
  15. cc_library(
  16. name = "gtest_main",
  17. testonly = 1,
  18. srcs = ["gtest_main.cpp"],
  19. deps = [
  20. ":global_exe_path",
  21. "//common:init_llvm",
  22. "@googletest//:gtest",
  23. "@llvm-project//llvm:Support",
  24. ],
  25. )
  26. # This does extra initialization on top of Google benchmark's main in order to
  27. # provide stack traces and setup LLVM.
  28. #
  29. # This replaces `@google_benchmark//:benchmark_main`;
  30. # `@google_benchmark//:benchmark` should still be used directly.
  31. cc_library(
  32. name = "benchmark_main",
  33. testonly = 1,
  34. srcs = ["benchmark_main.cpp"],
  35. deps = [
  36. ":global_exe_path",
  37. "//common:init_llvm",
  38. "@abseil-cpp//absl/flags:parse",
  39. "@google_benchmark//:benchmark",
  40. "@llvm-project//llvm:Support",
  41. ],
  42. )
  43. cc_library(
  44. name = "source_gen_lib",
  45. testonly = 1,
  46. srcs = ["source_gen.cpp"],
  47. hdrs = ["source_gen.h"],
  48. deps = [
  49. "//common:check",
  50. "//common:map",
  51. "//common:set",
  52. "//toolchain/lex:token_kind",
  53. "@abseil-cpp//absl/random",
  54. "@llvm-project//llvm:Support",
  55. ],
  56. )
  57. cc_test(
  58. name = "source_gen_test",
  59. size = "small",
  60. srcs = ["source_gen_test.cpp"],
  61. deps = [
  62. ":global_exe_path",
  63. ":gtest_main",
  64. ":source_gen_lib",
  65. "//common:set",
  66. "//toolchain/driver",
  67. "//toolchain/install:install_paths_test_helpers",
  68. "@googletest//:gtest",
  69. "@llvm-project//llvm:Support",
  70. ],
  71. )
  72. cc_binary(
  73. name = "source_gen",
  74. testonly = 1,
  75. srcs = ["source_gen_main.cpp"],
  76. deps = [
  77. ":source_gen_lib",
  78. "//common:bazel_working_dir",
  79. "//common:command_line",
  80. "//common:init_llvm",
  81. "//common:ostream",
  82. "@llvm-project//llvm:Support",
  83. ],
  84. )
  85. cc_library(
  86. name = "test_raw_ostream",
  87. testonly = 1,
  88. hdrs = ["test_raw_ostream.h"],
  89. deps = [
  90. "//common:ostream",
  91. "@googletest//:gtest",
  92. "@llvm-project//llvm:Support",
  93. ],
  94. )
  95. cc_test(
  96. name = "test_raw_ostream_test",
  97. size = "small",
  98. srcs = ["test_raw_ostream_test.cpp"],
  99. deps = [
  100. ":test_raw_ostream",
  101. "//testing/base:gtest_main",
  102. "@googletest//:gtest",
  103. ],
  104. )
  105. cc_library(
  106. name = "global_exe_path",
  107. testonly = 1,
  108. srcs = ["global_exe_path.cpp"],
  109. hdrs = ["global_exe_path.h"],
  110. deps = [
  111. "//common:check",
  112. "//common:exe_path",
  113. "@llvm-project//llvm:Support",
  114. ],
  115. )
  116. cc_test(
  117. name = "global_exe_path_test",
  118. size = "small",
  119. srcs = ["global_exe_path_test.cpp"],
  120. deps = [
  121. ":global_exe_path",
  122. ":gtest_main",
  123. "@googletest//:gtest",
  124. "@llvm-project//llvm:Support",
  125. ],
  126. )