BUILD.bazel 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. # Copyright 2017 Google Inc.
  2. # All Rights Reserved.
  3. #
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions are
  7. # met:
  8. #
  9. # * Redistributions of source code must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. # * Redistributions in binary form must reproduce the above
  12. # copyright notice, this list of conditions and the following disclaimer
  13. # in the documentation and/or other materials provided with the
  14. # distribution.
  15. # * Neither the name of Google Inc. nor the names of its
  16. # contributors may be used to endorse or promote products derived from
  17. # this software without specific prior written permission.
  18. #
  19. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. #
  31. # Author: misterg@google.com (Gennadiy Civil)
  32. #
  33. # Bazel BUILD for The Google C++ Testing Framework (Google Test)
  34. licenses(["notice"])
  35. config_setting(
  36. name = "windows",
  37. values = {"cpu": "x64_windows"},
  38. )
  39. config_setting(
  40. name = "windows_msvc",
  41. values = {"cpu": "x64_windows_msvc"},
  42. )
  43. config_setting(
  44. name = "has_absl",
  45. values = {"define": "absl=1"},
  46. )
  47. #on windows exclude gtest-tuple.h and googletest-tuple-test.cc
  48. cc_test(
  49. name = "gtest_all_test",
  50. size = "small",
  51. srcs = glob(
  52. include = [
  53. "gtest-*.cc",
  54. "googletest-*.cc",
  55. "*.h",
  56. "googletest/include/gtest/**/*.h",
  57. ],
  58. exclude = [
  59. "gtest-unittest-api_test.cc",
  60. "googletest-tuple-test.cc",
  61. "googletest/src/gtest-all.cc",
  62. "gtest_all_test.cc",
  63. "gtest-death-test_ex_test.cc",
  64. "gtest-listener_test.cc",
  65. "gtest-unittest-api_test.cc",
  66. "googletest-param-test-test.cc",
  67. "googletest-catch-exceptions-test_.cc",
  68. "googletest-color-test_.cc",
  69. "googletest-env-var-test_.cc",
  70. "googletest-filter-unittest_.cc",
  71. "googletest-break-on-failure-unittest_.cc",
  72. "googletest-listener-test.cc",
  73. "googletest-output-test_.cc",
  74. "googletest-list-tests-unittest_.cc",
  75. "googletest-shuffle-test_.cc",
  76. "googletest-uninitialized-test_.cc",
  77. "googletest-death-test_ex_test.cc",
  78. "googletest-param-test-test",
  79. "googletest-throw-on-failure-test_.cc",
  80. "googletest-param-test-invalid-name1-test_.cc",
  81. "googletest-param-test-invalid-name2-test_.cc",
  82. ],
  83. ) + select({
  84. "//:windows": [],
  85. "//:windows_msvc": [],
  86. "//conditions:default": [
  87. "googletest-tuple-test.cc",
  88. ],
  89. }),
  90. copts = select({
  91. "//:windows": ["-DGTEST_USE_OWN_TR1_TUPLE=0"],
  92. "//:windows_msvc": ["-DGTEST_USE_OWN_TR1_TUPLE=0"],
  93. "//conditions:default": ["-DGTEST_USE_OWN_TR1_TUPLE=1"],
  94. }),
  95. includes = [
  96. "googletest",
  97. "googletest/include",
  98. "googletest/include/internal",
  99. "googletest/test",
  100. ],
  101. linkopts = select({
  102. "//:windows": [],
  103. "//:windows_msvc": [],
  104. "//conditions:default": [
  105. "-pthread",
  106. ],
  107. }),
  108. deps = ["//:gtest_main"],
  109. )
  110. # Tests death tests.
  111. cc_test(
  112. name = "googletest-death-test-test",
  113. size = "medium",
  114. srcs = ["googletest-death-test-test.cc"],
  115. deps = ["//:gtest_main"],
  116. )
  117. cc_test(
  118. name = "gtest_test_macro_stack_footprint_test",
  119. size = "small",
  120. srcs = ["gtest_test_macro_stack_footprint_test.cc"],
  121. deps = ["//:gtest"],
  122. )
  123. #These googletest tests have their own main()
  124. cc_test(
  125. name = "googletest-listener-test",
  126. size = "small",
  127. srcs = ["googletest-listener-test.cc"],
  128. deps = ["//:gtest_main"],
  129. )
  130. cc_test(
  131. name = "gtest-unittest-api_test",
  132. size = "small",
  133. srcs = [
  134. "gtest-unittest-api_test.cc",
  135. ],
  136. deps = [
  137. "//:gtest",
  138. ],
  139. )
  140. cc_test(
  141. name = "googletest-param-test-test",
  142. size = "small",
  143. srcs = [
  144. "googletest-param-test-test.cc",
  145. "googletest-param-test-test.h",
  146. "googletest-param-test2-test.cc",
  147. ],
  148. deps = ["//:gtest"],
  149. )
  150. cc_test(
  151. name = "gtest_unittest",
  152. size = "small",
  153. srcs = ["gtest_unittest.cc"],
  154. args = ["--heap_check=strict"],
  155. shard_count = 2,
  156. deps = ["//:gtest_main"],
  157. )
  158. # Py tests
  159. py_library(
  160. name = "gtest_test_utils",
  161. testonly = 1,
  162. srcs = ["gtest_test_utils.py"],
  163. )
  164. cc_binary(
  165. name = "gtest_help_test_",
  166. testonly = 1,
  167. srcs = ["gtest_help_test_.cc"],
  168. deps = ["//:gtest_main"],
  169. )
  170. py_test(
  171. name = "gtest_help_test",
  172. size = "small",
  173. srcs = ["gtest_help_test.py"],
  174. data = [":gtest_help_test_"],
  175. deps = [":gtest_test_utils"],
  176. )
  177. cc_binary(
  178. name = "googletest-output-test_",
  179. testonly = 1,
  180. srcs = ["googletest-output-test_.cc"],
  181. deps = ["//:gtest"],
  182. )
  183. py_test(
  184. name = "googletest-output-test",
  185. size = "small",
  186. srcs = ["googletest-output-test.py"],
  187. args = select({
  188. ":has_absl": [],
  189. "//conditions:default": ["--no_stacktrace_support"],
  190. }),
  191. data = [
  192. "googletest-output-test-golden-lin.txt",
  193. ":googletest-output-test_",
  194. ],
  195. deps = [":gtest_test_utils"],
  196. )
  197. cc_binary(
  198. name = "googletest-color-test_",
  199. testonly = 1,
  200. srcs = ["googletest-color-test_.cc"],
  201. deps = ["//:gtest"],
  202. )
  203. py_test(
  204. name = "googletest-color-test",
  205. size = "small",
  206. srcs = ["googletest-color-test.py"],
  207. data = [":googletest-color-test_"],
  208. deps = [":gtest_test_utils"],
  209. )
  210. cc_binary(
  211. name = "googletest-env-var-test_",
  212. testonly = 1,
  213. srcs = ["googletest-env-var-test_.cc"],
  214. deps = ["//:gtest"],
  215. )
  216. py_test(
  217. name = "googletest-env-var-test",
  218. size = "medium",
  219. srcs = ["googletest-env-var-test.py"],
  220. data = [":googletest-env-var-test_"],
  221. deps = [":gtest_test_utils"],
  222. )
  223. cc_binary(
  224. name = "googletest-filter-unittest_",
  225. testonly = 1,
  226. srcs = ["googletest-filter-unittest_.cc"],
  227. deps = ["//:gtest"],
  228. )
  229. py_test(
  230. name = "googletest-filter-unittest",
  231. size = "medium",
  232. srcs = ["googletest-filter-unittest.py"],
  233. data = [":googletest-filter-unittest_"],
  234. deps = [":gtest_test_utils"],
  235. )
  236. cc_binary(
  237. name = "googletest-break-on-failure-unittest_",
  238. testonly = 1,
  239. srcs = ["googletest-break-on-failure-unittest_.cc"],
  240. deps = ["//:gtest"],
  241. )
  242. py_test(
  243. name = "googletest-break-on-failure-unittest",
  244. size = "small",
  245. srcs = ["googletest-break-on-failure-unittest.py"],
  246. data = [":googletest-break-on-failure-unittest_"],
  247. deps = [":gtest_test_utils"],
  248. )
  249. cc_test(
  250. name = "gtest_assert_by_exception_test",
  251. size = "small",
  252. srcs = ["gtest_assert_by_exception_test.cc"],
  253. deps = ["//:gtest"],
  254. )
  255. cc_binary(
  256. name = "googletest-throw-on-failure-test_",
  257. testonly = 1,
  258. srcs = ["googletest-throw-on-failure-test_.cc"],
  259. deps = ["//:gtest"],
  260. )
  261. py_test(
  262. name = "googletest-throw-on-failure-test",
  263. size = "small",
  264. srcs = ["googletest-throw-on-failure-test.py"],
  265. data = [":googletest-throw-on-failure-test_"],
  266. deps = [":gtest_test_utils"],
  267. )
  268. cc_binary(
  269. name = "googletest-list-tests-unittest_",
  270. testonly = 1,
  271. srcs = ["googletest-list-tests-unittest_.cc"],
  272. deps = ["//:gtest"],
  273. )
  274. py_test(
  275. name = "googletest-list-tests-unittest",
  276. size = "small",
  277. srcs = ["googletest-list-tests-unittest.py"],
  278. data = [":googletest-list-tests-unittest_"],
  279. deps = [":gtest_test_utils"],
  280. )
  281. cc_binary(
  282. name = "googletest-shuffle-test_",
  283. srcs = ["googletest-shuffle-test_.cc"],
  284. deps = ["//:gtest"],
  285. )
  286. py_test(
  287. name = "googletest-shuffle-test",
  288. size = "small",
  289. srcs = ["googletest-shuffle-test.py"],
  290. data = [":googletest-shuffle-test_"],
  291. deps = [":gtest_test_utils"],
  292. )
  293. cc_binary(
  294. name = "googletest-catch-exceptions-no-ex-test_",
  295. testonly = 1,
  296. srcs = ["googletest-catch-exceptions-test_.cc"],
  297. deps = ["//:gtest_main"],
  298. )
  299. cc_binary(
  300. name = "googletest-catch-exceptions-ex-test_",
  301. testonly = 1,
  302. srcs = ["googletest-catch-exceptions-test_.cc"],
  303. copts = ["-fexceptions"],
  304. deps = ["//:gtest_main"],
  305. )
  306. py_test(
  307. name = "googletest-catch-exceptions-test",
  308. size = "small",
  309. srcs = ["googletest-catch-exceptions-test.py"],
  310. data = [
  311. ":googletest-catch-exceptions-ex-test_",
  312. ":googletest-catch-exceptions-no-ex-test_",
  313. ],
  314. deps = [":gtest_test_utils"],
  315. )
  316. cc_binary(
  317. name = "gtest_xml_output_unittest_",
  318. testonly = 1,
  319. srcs = ["gtest_xml_output_unittest_.cc"],
  320. deps = ["//:gtest"],
  321. )
  322. cc_test(
  323. name = "gtest_no_test_unittest",
  324. size = "small",
  325. srcs = ["gtest_no_test_unittest.cc"],
  326. deps = ["//:gtest"],
  327. )
  328. py_test(
  329. name = "gtest_xml_output_unittest",
  330. size = "small",
  331. srcs = [
  332. "gtest_xml_output_unittest.py",
  333. "gtest_xml_test_utils.py",
  334. ],
  335. args = select({
  336. ":has_absl": [],
  337. "//conditions:default": ["--no_stacktrace_support"],
  338. }),
  339. data = [
  340. # We invoke gtest_no_test_unittest to verify the XML output
  341. # when the test program contains no test definition.
  342. ":gtest_no_test_unittest",
  343. ":gtest_xml_output_unittest_",
  344. ],
  345. deps = [":gtest_test_utils"],
  346. )
  347. cc_binary(
  348. name = "gtest_xml_outfile1_test_",
  349. testonly = 1,
  350. srcs = ["gtest_xml_outfile1_test_.cc"],
  351. deps = ["//:gtest_main"],
  352. )
  353. cc_binary(
  354. name = "gtest_xml_outfile2_test_",
  355. testonly = 1,
  356. srcs = ["gtest_xml_outfile2_test_.cc"],
  357. deps = ["//:gtest_main"],
  358. )
  359. py_test(
  360. name = "gtest_xml_outfiles_test",
  361. size = "small",
  362. srcs = [
  363. "gtest_xml_outfiles_test.py",
  364. "gtest_xml_test_utils.py",
  365. ],
  366. data = [
  367. ":gtest_xml_outfile1_test_",
  368. ":gtest_xml_outfile2_test_",
  369. ],
  370. deps = [":gtest_test_utils"],
  371. )
  372. cc_binary(
  373. name = "googletest-uninitialized-test_",
  374. testonly = 1,
  375. srcs = ["googletest-uninitialized-test_.cc"],
  376. deps = ["//:gtest"],
  377. )
  378. py_test(
  379. name = "googletest-uninitialized-test",
  380. size = "medium",
  381. srcs = ["googletest-uninitialized-test.py"],
  382. data = ["googletest-uninitialized-test_"],
  383. deps = [":gtest_test_utils"],
  384. )
  385. cc_binary(
  386. name = "gtest_testbridge_test_",
  387. testonly = 1,
  388. srcs = ["gtest_testbridge_test_.cc"],
  389. deps = ["//:gtest_main"],
  390. )
  391. # Tests that filtering via testbridge works
  392. py_test(
  393. name = "gtest_testbridge_test",
  394. size = "small",
  395. srcs = ["gtest_testbridge_test.py"],
  396. data = [":gtest_testbridge_test_"],
  397. deps = [":gtest_test_utils"],
  398. )
  399. py_test(
  400. name = "googletest-json-outfiles-test",
  401. size = "small",
  402. srcs = [
  403. "googletest-json-outfiles-test.py",
  404. "gtest_json_test_utils.py",
  405. ],
  406. data = [
  407. ":gtest_xml_outfile1_test_",
  408. ":gtest_xml_outfile2_test_",
  409. ],
  410. deps = [":gtest_test_utils"],
  411. )
  412. py_test(
  413. name = "googletest-json-output-unittest",
  414. size = "medium",
  415. srcs = [
  416. "googletest-json-output-unittest.py",
  417. "gtest_json_test_utils.py",
  418. ],
  419. data = [
  420. # We invoke gtest_no_test_unittest to verify the JSON output
  421. # when the test program contains no test definition.
  422. ":gtest_no_test_unittest",
  423. ":gtest_xml_output_unittest_",
  424. ],
  425. args = select({
  426. ":has_absl": [],
  427. "//conditions:default": ["--no_stacktrace_support"],
  428. }),
  429. deps = [":gtest_test_utils"],
  430. )
  431. # Verifies interaction of death tests and exceptions.
  432. cc_test(
  433. name = "googletest-death-test_ex_catch_test",
  434. size = "medium",
  435. srcs = ["googletest-death-test_ex_test.cc"],
  436. copts = ["-fexceptions"],
  437. defines = ["GTEST_ENABLE_CATCH_EXCEPTIONS_=1"],
  438. deps = ["//:gtest"],
  439. )
  440. cc_binary(
  441. name = "googletest-param-test-invalid-name1-test_",
  442. testonly = 1,
  443. srcs = ["googletest-param-test-invalid-name1-test_.cc"],
  444. deps = ["//:gtest"],
  445. )
  446. cc_binary(
  447. name = "googletest-param-test-invalid-name2-test_",
  448. testonly = 1,
  449. srcs = ["googletest-param-test-invalid-name2-test_.cc"],
  450. deps = ["//:gtest"],
  451. )
  452. py_test(
  453. name = "googletest-param-test-invalid-name1-test",
  454. size = "small",
  455. srcs = ["googletest-param-test-invalid-name1-test.py"],
  456. data = [":googletest-param-test-invalid-name1-test_"],
  457. deps = [":gtest_test_utils"],
  458. )
  459. py_test(
  460. name = "googletest-param-test-invalid-name2-test",
  461. size = "small",
  462. srcs = ["googletest-param-test-invalid-name2-test.py"],
  463. data = [":googletest-param-test-invalid-name2-test_"],
  464. deps = [":gtest_test_utils"],
  465. )