• 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 = [],
19    hdrs = TEST_HEADERS,
20    visibility = ["//third_party/fruit/tests:__subpackages__"],
21    includes = ["."],
22)
23
24[cc_test(
25    name = filename[:-4],
26    srcs = [filename],
27    deps = [
28        ":test_headers",
29        "//third_party/fruit",
30    ]
31) for filename in glob(
32    ["*.cpp"],
33    exclude = ["include_test.cpp"])]
34
35FRUIT_PUBLIC_HEADERS = [
36    "component",
37    "fruit",
38    "fruit_forward_decls",
39    "injector",
40    "macro",
41    "normalized_component",
42    "provider",
43]
44
45genrule(
46    name = "fruit_test_config_genrule",
47    srcs = [
48        "//third_party/fruit",
49        "//third_party/fruit:fruit_headers",
50        ":test_headers_filegroup",
51    ],
52    # Here we copy libfruit.so to work around an issue with py_test where the outputs of a cc_library in the data
53    # attribute of a py_test are not taken into account.
54    outs = [
55        "fruit_test_config.py",
56        "libfruit.so"
57    ],
58    visibility = ["//third_party/fruit/tests:__subpackages__"],
59    cmd = ""
60          + "FRUIT_HEADERS_LOCATION=`for f in $(locations //third_party/fruit:fruit_headers); do echo \"$$f\"; done | fgrep configuration/bazel/ | head -n 1 | sed 's|configuration/bazel/.*|./|'`;"
61          + "TEST_HEADERS_LOCATION=`for f in $(locations :test_headers_filegroup); do echo \"$$f\"; done | fgrep test_macros.h | sed 's|test_macros.h|./|'`;"
62          + "LIBFRUIT_LOCATION=`for f in $(locations //third_party/fruit); do echo \"$$f\"; done | fgrep libfruit.so | head -n 1 | sed 's|libfruit.so|./|'`;"
63          + "cp $${LIBFRUIT_LOCATION}/libfruit.so $(location libfruit.so);"
64          # The removal of ".*/genfiles" from the location is a bit of a hack, but that's how the path will look like in the py_tests
65          # below.
66          + "LIBFRUIT_COPY_DIR_LOCATION=`dirname $(location libfruit.so) | sed 's|.*/genfiles/|./|'`;"
67          + "LIBFRUIT_COPY_LOCATION=`echo $(location libfruit.so) | sed 's|.*/genfiles/|./|'`;"
68          + "echo -e \""
69          + "CXX='g++'\n"
70          + "CXX_COMPILER_NAME='GNU'\n"
71          + "CXX_COMPILER_VERSION='5.0.0'\n"
72          + "FRUIT_COMPILE_FLAGS='$(CC_FLAGS) -std=c++0x -W -Wall -Wno-missing-braces -g -Werror'\n"
73          + "ADDITIONAL_INCLUDE_DIRS=''\n"
74          + "CMAKE_BUILD_TYPE=None\n"
75          + "PATH_TO_COMPILED_FRUIT='$${LIBFRUIT_COPY_DIR_LOCATION}'\n"
76          + "PATH_TO_COMPILED_FRUIT_LIB='$${LIBFRUIT_COPY_LOCATION}'\n"
77          + "PATH_TO_FRUIT_STATIC_HEADERS='$${FRUIT_HEADERS_LOCATION}/include'\n"
78          + "PATH_TO_FRUIT_GENERATED_HEADERS='$${FRUIT_HEADERS_LOCATION}/configuration/bazel'\n"
79          + "PATH_TO_FRUIT_TEST_HEADERS='$${TEST_HEADERS_LOCATION}'\n"
80          + "ADDITIONAL_LINKER_FLAGS=''\n"
81          + "RUN_TESTS_UNDER_VALGRIND='0'\n"
82          + "VALGRIND_FLAGS=''\n"
83          + "ENABLE_COVERAGE=False\n"
84          + "\" > $(location fruit_test_config.py)",
85)
86
87py_library(
88    name = "fruit_test_common",
89    srcs = ["fruit_test_common.py", "fruit_test_config.py"],
90    imports = ["."],
91    visibility = ["//third_party/fruit/tests:__subpackages__"],
92)
93
94load("//third_party/fruit/tests:build_defs.bzl", "fruit_py_tests")
95
96fruit_py_tests(
97    srcs = glob(["test_*.py"]),
98)
99