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.

521 lines
13 KiB

  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. load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test")
  35. load("@rules_python//python:defs.bzl", "py_library", "py_test")
  36. licenses(["notice"])
  37. #on windows exclude gtest-tuple.h
  38. cc_test(
  39. name = "gtest_all_test",
  40. size = "small",
  41. srcs = glob(
  42. include = [
  43. "gtest-*.cc",
  44. "googletest-*.cc",
  45. "*.h",
  46. "googletest/include/gtest/**/*.h",
  47. ],
  48. exclude = [
  49. "gtest-unittest-api_test.cc",
  50. "googletest/src/gtest-all.cc",
  51. "gtest_all_test.cc",
  52. "gtest-death-test_ex_test.cc",
  53. "gtest-listener_test.cc",
  54. "gtest-unittest-api_test.cc",
  55. "googletest-param-test-test.cc",
  56. "googletest-catch-exceptions-test_.cc",
  57. "googletest-color-test_.cc",
  58. "googletest-env-var-test_.cc",
  59. "googletest-filter-unittest_.cc",
  60. "googletest-break-on-failure-unittest_.cc",
  61. "googletest-listener-test.cc",
  62. "googletest-output-test_.cc",
  63. "googletest-list-tests-unittest_.cc",
  64. "googletest-shuffle-test_.cc",
  65. "googletest-uninitialized-test_.cc",
  66. "googletest-death-test_ex_test.cc",
  67. "googletest-param-test-test",
  68. "googletest-throw-on-failure-test_.cc",
  69. "googletest-param-test-invalid-name1-test_.cc",
  70. "googletest-param-test-invalid-name2-test_.cc",
  71. ],
  72. ) + select({
  73. "//:windows": [],
  74. "//conditions:default": [],
  75. }),
  76. copts = select({
  77. "//:windows": ["-DGTEST_USE_OWN_TR1_TUPLE=0"],
  78. "//conditions:default": ["-DGTEST_USE_OWN_TR1_TUPLE=1"],
  79. }),
  80. includes = [
  81. "googletest",
  82. "googletest/include",
  83. "googletest/include/internal",
  84. "googletest/test",
  85. ],
  86. linkopts = select({
  87. "//:windows": [],
  88. "//conditions:default": ["-pthread"],
  89. }),
  90. deps = ["//:gtest_main"],
  91. )
  92. # Tests death tests.
  93. cc_test(
  94. name = "googletest-death-test-test",
  95. size = "medium",
  96. srcs = ["googletest-death-test-test.cc"],
  97. deps = ["//:gtest_main"],
  98. )
  99. cc_test(
  100. name = "gtest_test_macro_stack_footprint_test",
  101. size = "small",
  102. srcs = ["gtest_test_macro_stack_footprint_test.cc"],
  103. deps = ["//:gtest"],
  104. )
  105. #These googletest tests have their own main()
  106. cc_test(
  107. name = "googletest-listener-test",
  108. size = "small",
  109. srcs = ["googletest-listener-test.cc"],
  110. deps = ["//:gtest_main"],
  111. )
  112. cc_test(
  113. name = "gtest-unittest-api_test",
  114. size = "small",
  115. srcs = [
  116. "gtest-unittest-api_test.cc",
  117. ],
  118. deps = [
  119. "//:gtest",
  120. ],
  121. )
  122. cc_test(
  123. name = "googletest-param-test-test",
  124. size = "small",
  125. srcs = [
  126. "googletest-param-test-test.cc",
  127. "googletest-param-test-test.h",
  128. "googletest-param-test2-test.cc",
  129. ],
  130. deps = ["//:gtest"],
  131. )
  132. cc_test(
  133. name = "gtest_unittest",
  134. size = "small",
  135. srcs = ["gtest_unittest.cc"],
  136. args = ["--heap_check=strict"],
  137. shard_count = 2,
  138. deps = ["//:gtest_main"],
  139. )
  140. # Py tests
  141. py_library(
  142. name = "gtest_test_utils",
  143. testonly = 1,
  144. srcs = ["gtest_test_utils.py"],
  145. )
  146. cc_binary(
  147. name = "gtest_help_test_",
  148. testonly = 1,
  149. srcs = ["gtest_help_test_.cc"],
  150. deps = ["//:gtest_main"],
  151. )
  152. py_test(
  153. name = "gtest_help_test",
  154. size = "small",
  155. srcs = ["gtest_help_test.py"],
  156. data = [":gtest_help_test_"],
  157. deps = [":gtest_test_utils"],
  158. )
  159. cc_binary(
  160. name = "googletest-output-test_",
  161. testonly = 1,
  162. srcs = ["googletest-output-test_.cc"],
  163. deps = ["//:gtest"],
  164. )
  165. py_test(
  166. name = "googletest-output-test",
  167. size = "small",
  168. srcs = ["googletest-output-test.py"],
  169. args = select({
  170. "//:has_absl": [],
  171. "//conditions:default": ["--no_stacktrace_support"],
  172. }),
  173. data = [
  174. "googletest-output-test-golden-lin.txt",
  175. ":googletest-output-test_",
  176. ],
  177. deps = [":gtest_test_utils"],
  178. )
  179. cc_binary(
  180. name = "googletest-color-test_",
  181. testonly = 1,
  182. srcs = ["googletest-color-test_.cc"],
  183. deps = ["//:gtest"],
  184. )
  185. py_test(
  186. name = "googletest-color-test",
  187. size = "small",
  188. srcs = ["googletest-color-test.py"],
  189. data = [":googletest-color-test_"],
  190. deps = [":gtest_test_utils"],
  191. )
  192. cc_binary(
  193. name = "googletest-env-var-test_",
  194. testonly = 1,
  195. srcs = ["googletest-env-var-test_.cc"],
  196. deps = ["//:gtest"],
  197. )
  198. py_test(
  199. name = "googletest-env-var-test",
  200. size = "medium",
  201. srcs = ["googletest-env-var-test.py"],
  202. data = [":googletest-env-var-test_"],
  203. deps = [":gtest_test_utils"],
  204. )
  205. cc_binary(
  206. name = "googletest-filter-unittest_",
  207. testonly = 1,
  208. srcs = ["googletest-filter-unittest_.cc"],
  209. deps = ["//:gtest"],
  210. )
  211. py_test(
  212. name = "googletest-filter-unittest",
  213. size = "medium",
  214. srcs = ["googletest-filter-unittest.py"],
  215. data = [":googletest-filter-unittest_"],
  216. deps = [":gtest_test_utils"],
  217. )
  218. cc_binary(
  219. name = "googletest-break-on-failure-unittest_",
  220. testonly = 1,
  221. srcs = ["googletest-break-on-failure-unittest_.cc"],
  222. deps = ["//:gtest"],
  223. )
  224. py_test(
  225. name = "googletest-break-on-failure-unittest",
  226. size = "small",
  227. srcs = ["googletest-break-on-failure-unittest.py"],
  228. data = [":googletest-break-on-failure-unittest_"],
  229. deps = [":gtest_test_utils"],
  230. )
  231. cc_test(
  232. name = "gtest_assert_by_exception_test",
  233. size = "small",
  234. srcs = ["gtest_assert_by_exception_test.cc"],
  235. deps = ["//:gtest"],
  236. )
  237. cc_binary(
  238. name = "googletest-throw-on-failure-test_",
  239. testonly = 1,
  240. srcs = ["googletest-throw-on-failure-test_.cc"],
  241. deps = ["//:gtest"],
  242. )
  243. py_test(
  244. name = "googletest-throw-on-failure-test",
  245. size = "small",
  246. srcs = ["googletest-throw-on-failure-test.py"],
  247. data = [":googletest-throw-on-failure-test_"],
  248. deps = [":gtest_test_utils"],
  249. )
  250. cc_binary(
  251. name = "googletest-list-tests-unittest_",
  252. testonly = 1,
  253. srcs = ["googletest-list-tests-unittest_.cc"],
  254. deps = ["//:gtest"],
  255. )
  256. cc_test(
  257. name = "gtest_skip_test",
  258. size = "small",
  259. srcs = ["gtest_skip_test.cc"],
  260. deps = ["//:gtest_main"],
  261. )
  262. cc_test(
  263. name = "gtest_skip_in_environment_setup_test",
  264. size = "small",
  265. srcs = ["gtest_skip_in_environment_setup_test.cc"],
  266. deps = ["//:gtest_main"],
  267. )
  268. py_test(
  269. name = "gtest_skip_environment_check_output_test",
  270. size = "small",
  271. srcs = ["gtest_skip_environment_check_output_test.py"],
  272. data = [
  273. ":gtest_skip_in_environment_setup_test",
  274. ],
  275. deps = [":gtest_test_utils"],
  276. )
  277. py_test(
  278. name = "googletest-list-tests-unittest",
  279. size = "small",
  280. srcs = ["googletest-list-tests-unittest.py"],
  281. data = [":googletest-list-tests-unittest_"],
  282. deps = [":gtest_test_utils"],
  283. )
  284. cc_binary(
  285. name = "googletest-shuffle-test_",
  286. srcs = ["googletest-shuffle-test_.cc"],
  287. deps = ["//:gtest"],
  288. )
  289. py_test(
  290. name = "googletest-shuffle-test",
  291. size = "small",
  292. srcs = ["googletest-shuffle-test.py"],
  293. data = [":googletest-shuffle-test_"],
  294. deps = [":gtest_test_utils"],
  295. )
  296. cc_binary(
  297. name = "googletest-catch-exceptions-no-ex-test_",
  298. testonly = 1,
  299. srcs = ["googletest-catch-exceptions-test_.cc"],
  300. deps = ["//:gtest_main"],
  301. )
  302. cc_binary(
  303. name = "googletest-catch-exceptions-ex-test_",
  304. testonly = 1,
  305. srcs = ["googletest-catch-exceptions-test_.cc"],
  306. copts = ["-fexceptions"],
  307. deps = ["//:gtest_main"],
  308. )
  309. py_test(
  310. name = "googletest-catch-exceptions-test",
  311. size = "small",
  312. srcs = ["googletest-catch-exceptions-test.py"],
  313. data = [
  314. ":googletest-catch-exceptions-ex-test_",
  315. ":googletest-catch-exceptions-no-ex-test_",
  316. ],
  317. deps = [":gtest_test_utils"],
  318. )
  319. cc_binary(
  320. name = "gtest_xml_output_unittest_",
  321. testonly = 1,
  322. srcs = ["gtest_xml_output_unittest_.cc"],
  323. deps = ["//:gtest"],
  324. )
  325. cc_test(
  326. name = "gtest_no_test_unittest",
  327. size = "small",
  328. srcs = ["gtest_no_test_unittest.cc"],
  329. deps = ["//:gtest"],
  330. )
  331. py_test(
  332. name = "gtest_xml_output_unittest",
  333. size = "small",
  334. srcs = [
  335. "gtest_xml_output_unittest.py",
  336. "gtest_xml_test_utils.py",
  337. ],
  338. args = select({
  339. "//:has_absl": [],
  340. "//conditions:default": ["--no_stacktrace_support"],
  341. }),
  342. data = [
  343. # We invoke gtest_no_test_unittest to verify the XML output
  344. # when the test program contains no test definition.
  345. ":gtest_no_test_unittest",
  346. ":gtest_xml_output_unittest_",
  347. ],
  348. deps = [":gtest_test_utils"],
  349. )
  350. cc_binary(
  351. name = "gtest_xml_outfile1_test_",
  352. testonly = 1,
  353. srcs = ["gtest_xml_outfile1_test_.cc"],
  354. deps = ["//:gtest_main"],
  355. )
  356. cc_binary(
  357. name = "gtest_xml_outfile2_test_",
  358. testonly = 1,
  359. srcs = ["gtest_xml_outfile2_test_.cc"],
  360. deps = ["//:gtest_main"],
  361. )
  362. py_test(
  363. name = "gtest_xml_outfiles_test",
  364. size = "small",
  365. srcs = [
  366. "gtest_xml_outfiles_test.py",
  367. "gtest_xml_test_utils.py",
  368. ],
  369. data = [
  370. ":gtest_xml_outfile1_test_",
  371. ":gtest_xml_outfile2_test_",
  372. ],
  373. deps = [":gtest_test_utils"],
  374. )
  375. cc_binary(
  376. name = "googletest-uninitialized-test_",
  377. testonly = 1,
  378. srcs = ["googletest-uninitialized-test_.cc"],
  379. deps = ["//:gtest"],
  380. )
  381. py_test(
  382. name = "googletest-uninitialized-test",
  383. size = "medium",
  384. srcs = ["googletest-uninitialized-test.py"],
  385. data = ["googletest-uninitialized-test_"],
  386. deps = [":gtest_test_utils"],
  387. )
  388. cc_binary(
  389. name = "gtest_testbridge_test_",
  390. testonly = 1,
  391. srcs = ["gtest_testbridge_test_.cc"],
  392. deps = ["//:gtest_main"],
  393. )
  394. # Tests that filtering via testbridge works
  395. py_test(
  396. name = "gtest_testbridge_test",
  397. size = "small",
  398. srcs = ["gtest_testbridge_test.py"],
  399. data = [":gtest_testbridge_test_"],
  400. deps = [":gtest_test_utils"],
  401. )
  402. py_test(
  403. name = "googletest-json-outfiles-test",
  404. size = "small",
  405. srcs = [
  406. "googletest-json-outfiles-test.py",
  407. "gtest_json_test_utils.py",
  408. ],
  409. data = [
  410. ":gtest_xml_outfile1_test_",
  411. ":gtest_xml_outfile2_test_",
  412. ],
  413. deps = [":gtest_test_utils"],
  414. )
  415. py_test(
  416. name = "googletest-json-output-unittest",
  417. size = "medium",
  418. srcs = [
  419. "googletest-json-output-unittest.py",
  420. "gtest_json_test_utils.py",
  421. ],
  422. args = select({
  423. "//:has_absl": [],
  424. "//conditions:default": ["--no_stacktrace_support"],
  425. }),
  426. data = [
  427. # We invoke gtest_no_test_unittest to verify the JSON output
  428. # when the test program contains no test definition.
  429. ":gtest_no_test_unittest",
  430. ":gtest_xml_output_unittest_",
  431. ],
  432. deps = [":gtest_test_utils"],
  433. )
  434. # Verifies interaction of death tests and exceptions.
  435. cc_test(
  436. name = "googletest-death-test_ex_catch_test",
  437. size = "medium",
  438. srcs = ["googletest-death-test_ex_test.cc"],
  439. copts = ["-fexceptions"],
  440. defines = ["GTEST_ENABLE_CATCH_EXCEPTIONS_=1"],
  441. deps = ["//:gtest"],
  442. )
  443. cc_binary(
  444. name = "googletest-param-test-invalid-name1-test_",
  445. testonly = 1,
  446. srcs = ["googletest-param-test-invalid-name1-test_.cc"],
  447. deps = ["//:gtest"],
  448. )
  449. cc_binary(
  450. name = "googletest-param-test-invalid-name2-test_",
  451. testonly = 1,
  452. srcs = ["googletest-param-test-invalid-name2-test_.cc"],
  453. deps = ["//:gtest"],
  454. )
  455. py_test(
  456. name = "googletest-param-test-invalid-name1-test",
  457. size = "small",
  458. srcs = ["googletest-param-test-invalid-name1-test.py"],
  459. data = [":googletest-param-test-invalid-name1-test_"],
  460. deps = [":gtest_test_utils"],
  461. )
  462. py_test(
  463. name = "googletest-param-test-invalid-name2-test",
  464. size = "small",
  465. srcs = ["googletest-param-test-invalid-name2-test.py"],
  466. data = [":googletest-param-test-invalid-name2-test_"],
  467. deps = [":gtest_test_utils"],
  468. )