• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2licenses(["notice"])
3
4TEST_HEADERS = [
5   "test_macros.h",
6   "test_common.h",
7   "class_construction_tracker.h",
8]
9
10filegroup(
11    name = "test_headers_filegroup",
12    srcs = TEST_HEADERS,
13    visibility = ["//third_party/fruit/tests:__subpackages__"],
14)
15
16cc_library(
17    name = "test_headers",
18    srcs = ["test_common.cpp"],
19    hdrs = TEST_HEADERS,
20    visibility = ["//third_party/fruit/tests:__subpackages__"],
21    includes = ["."],
22    deps = [
23        "//third_party/fruit",
24        "@boost//:unordered",
25    ]
26)
27
28[cc_test(
29    name = filename[:-4],
30    srcs = [filename],
31    deps = [
32        ":test_headers",
33        "//third_party/fruit",
34    ]
35) for filename in glob(
36    ["*.cpp"],
37    exclude = ["include_test.cpp", "test_common.cpp"])]
38
39FRUIT_PUBLIC_HEADERS = [
40    "component",
41    "fruit",
42    "fruit_forward_decls",
43    "injector",
44    "macro",
45    "normalized_component",
46    "provider",
47]
48
49genrule(
50    name = "fruit_test_config_genrule",
51    srcs = [
52        "//third_party/fruit",
53        "//third_party/fruit:fruit_headers",
54        ":test_headers",
55        ":test_headers_filegroup",
56    ],
57    # Here we copy libfruit.so and test_headers.so to work around an issue with py_test where the outputs of a
58    # cc_library in the data attribute of a py_test are not taken into account.
59    outs = [
60        "fruit_test_config.py",
61        "libfruit.so",
62        "libtest_headers_copy.so",
63    ],
64    toolchains = [
65        # For $(CC_FLAGS)
66        "@bazel_tools//tools/cpp:cc_flags",
67        # for $(CC)
68        "@bazel_tools//tools/cpp:current_cc_toolchain",
69    ],
70    visibility = ["//third_party/fruit/tests:__subpackages__"],
71    cmd = ""
72          + "TEST_HEADERS_LOCATION=`for f in $(locations :test_headers_filegroup); do echo \"$$f\"; done | fgrep test_macros.h | sed 's|test_macros.h|./|'`;"
73          + "LIBFRUIT_LOCATION=`for f in $(locations //third_party/fruit); do echo \"$$f\"; done | fgrep libfruit.so | head -n 1 | sed 's|libfruit.so|./|'`;"
74          + "LIBTEST_HEADERS_LOCATION=`for f in $(locations //third_party/fruit/tests:test_headers); do echo \"$$f\"; done | fgrep libtest_headers.so | head -n 1 | sed 's|libtest_headers.so|./|'`;"
75          + "cp $${LIBFRUIT_LOCATION}/libfruit.so $(@D)/;"
76          + "cp $${LIBTEST_HEADERS_LOCATION}/libtest_headers.so $(@D)/libtest_headers_copy.so;"
77          + "echo -e \""
78          + "CXX='$(CC)'\n"
79          + "CXX_COMPILER_NAME='GNU'\n"
80          + "CXX_COMPILER_VERSION='5.0.0'\n"
81          + "FRUIT_COMPILE_FLAGS='$(CC_FLAGS) -std=c++0x -W -Wall -Wno-missing-braces -g -Werror'\n"
82          + "ADDITIONAL_INCLUDE_DIRS=''\n"
83          + "CMAKE_BUILD_TYPE=None\n"
84          + "PATH_TO_COMPILED_FRUIT='third_party/fruit/tests'\n"
85          + "PATH_TO_COMPILED_FRUIT_LIB='third_party/fruit/tests'\n"
86          + "PATH_TO_COMPILED_TEST_HEADERS='third_party/fruit/tests/test_headers'\n"
87          + "PATH_TO_COMPILED_TEST_HEADERS_LIB='third_party/fruit/tests/test_headers'\n"
88          + "PATH_TO_FRUIT_STATIC_HEADERS='third_party/fruit/include'\n"
89          + "PATH_TO_FRUIT_GENERATED_HEADERS='third_party/fruit/configuration/bazel'\n"
90          + "PATH_TO_FRUIT_TEST_HEADERS='$${TEST_HEADERS_LOCATION}'\n"
91          + "ADDITIONAL_LINKER_FLAGS='-lstdc++ -lm'\n"
92          + "RUN_TESTS_UNDER_VALGRIND='0'\n"
93          + "VALGRIND_FLAGS=''\n"
94          + "ENABLE_COVERAGE=False\n"
95          + "\" > $(location fruit_test_config.py)",
96)
97
98py_library(
99    name = "fruit_test_common",
100    srcs = ["fruit_test_common.py", "fruit_test_config.py"],
101    imports = ["."],
102    visibility = ["//third_party/fruit/tests:__subpackages__"],
103)
104
105load("//third_party/fruit/tests:build_defs.bzl", "fruit_py_tests")
106
107fruit_py_tests(
108    srcs = glob(["test_*.py"]),
109)
110