diff options
author | Haibo Huang <hhb@google.com> | 2020-07-15 03:32:55 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-07-15 03:32:55 +0000 |
commit | 572fac3f0241a7d0fb2e03cdcaf8d04ba427a7eb (patch) | |
tree | bf376c934810305368dd7865d16ae64b7a840fb2 | |
parent | d7ca2e859fce5f811b406faf736ed29ff22d306c (diff) | |
parent | f6e6c94bb2f3db4cf2942188df546e7f97ccea24 (diff) | |
download | google-fruit-572fac3f0241a7d0fb2e03cdcaf8d04ba427a7eb.tar.gz |
Upgrade google-fruit to faa69229324e7b0393e2196b9fb919e5056dc675 am: 59888e7910 am: 9682d513d6 am: 1b13f367e0 am: ee005fa5e8 am: f6e6c94bb2
Original change: https://android-review.googlesource.com/c/platform/external/google-fruit/+/1360892
Change-Id: Ia5bbd0164aa122c530e36878c5f43198b22e8597
-rw-r--r-- | BUILD | 4 | ||||
-rw-r--r-- | METADATA | 6 | ||||
-rw-r--r-- | extras/bazel_root/WORKSPACE | 10 | ||||
-rw-r--r-- | tests/BUILD | 20 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 5 | ||||
-rw-r--r-- | tests/build_defs.bzl | 1 | ||||
-rw-r--r-- | tests/data_structures/test_semistatic_graph.py | 20 | ||||
-rw-r--r-- | tests/fruit_test_common.py | 14 | ||||
-rw-r--r-- | tests/test_common.cpp | 36 | ||||
-rw-r--r-- | tests/test_common.h | 25 |
10 files changed, 107 insertions, 34 deletions
@@ -18,6 +18,8 @@ cc_library( "configuration/bazel/**/*.h"]), hdrs = glob(["include/fruit/*.h"]), includes = ["include", "configuration/bazel"], - deps = [], + deps = [ + "@boost//:unordered", + ], linkopts = ["-lm"], ) @@ -9,11 +9,11 @@ third_party { type: GIT value: "https://github.com/google/fruit.git" } - version: "45fa33d27da5a9b21471094f34e7f26c21e71f5b" + version: "faa69229324e7b0393e2196b9fb919e5056dc675" license_type: NOTICE last_upgrade_date { year: 2020 - month: 6 - day: 1 + month: 7 + day: 10 } } diff --git a/extras/bazel_root/WORKSPACE b/extras/bazel_root/WORKSPACE index 8622415..d74dafe 100644 --- a/extras/bazel_root/WORKSPACE +++ b/extras/bazel_root/WORKSPACE @@ -6,3 +6,13 @@ git_repository( # GTest HEAD as of August 2018. commit = "9c96f500a39df6915f8f1ab53b60be9889f1572b", ) + +git_repository( + name = "com_github_nelhage_rules_boost", + commit = "1e3a69bf2d5cd10c34b74f066054cd335d033d71", + remote = "https://github.com/nelhage/rules_boost", + shallow_since = "1591047380 -0700", +) + +load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps") +boost_deps() diff --git a/tests/BUILD b/tests/BUILD index 4fc016d..b7ff089 100644 --- a/tests/BUILD +++ b/tests/BUILD @@ -15,10 +15,14 @@ filegroup( cc_library( name = "test_headers", - srcs = [], + srcs = ["test_common.cpp"], hdrs = TEST_HEADERS, visibility = ["//third_party/fruit/tests:__subpackages__"], includes = ["."], + deps = [ + "//third_party/fruit", + "@boost//:unordered", + ] ) [cc_test( @@ -30,7 +34,7 @@ cc_library( ] ) for filename in glob( ["*.cpp"], - exclude = ["include_test.cpp"])] + exclude = ["include_test.cpp", "test_common.cpp"])] FRUIT_PUBLIC_HEADERS = [ "component", @@ -47,13 +51,15 @@ genrule( srcs = [ "//third_party/fruit", "//third_party/fruit:fruit_headers", + ":test_headers", ":test_headers_filegroup", ], - # Here we copy libfruit.so to work around an issue with py_test where the outputs of a cc_library in the data - # attribute of a py_test are not taken into account. + # Here we copy libfruit.so and test_headers.so to work around an issue with py_test where the outputs of a + # cc_library in the data attribute of a py_test are not taken into account. outs = [ "fruit_test_config.py", - "libfruit.so" + "libfruit.so", + "libtest_headers_copy.so", ], toolchains = [ # For $(CC_FLAGS) @@ -66,7 +72,9 @@ genrule( + "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/.*|./|'`;" + "TEST_HEADERS_LOCATION=`for f in $(locations :test_headers_filegroup); do echo \"$$f\"; done | fgrep test_macros.h | sed 's|test_macros.h|./|'`;" + "LIBFRUIT_LOCATION=`for f in $(locations //third_party/fruit); do echo \"$$f\"; done | fgrep libfruit.so | head -n 1 | sed 's|libfruit.so|./|'`;" + + "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|./|'`;" + "cp $${LIBFRUIT_LOCATION}/libfruit.so $(@D)/;" + + "cp $${LIBTEST_HEADERS_LOCATION}/libtest_headers.so $(@D)/libtest_headers_copy.so;" + "echo -e \"" + "CXX='$(CC)'\n" + "CXX_COMPILER_NAME='GNU'\n" @@ -76,6 +84,8 @@ genrule( + "CMAKE_BUILD_TYPE=None\n" + "PATH_TO_COMPILED_FRUIT='third_party/fruit/tests'\n" + "PATH_TO_COMPILED_FRUIT_LIB='third_party/fruit/tests'\n" + + "PATH_TO_COMPILED_TEST_HEADERS='third_party/fruit/tests/test_headers'\n" + + "PATH_TO_COMPILED_TEST_HEADERS_LIB='third_party/fruit/tests/test_headers'\n" + "PATH_TO_FRUIT_STATIC_HEADERS='$${FRUIT_HEADERS_LOCATION}/include'\n" + "PATH_TO_FRUIT_GENERATED_HEADERS='$${FRUIT_HEADERS_LOCATION}/configuration/bazel'\n" + "PATH_TO_FRUIT_TEST_HEADERS='$${TEST_HEADERS_LOCATION}'\n" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bf78890..479b8aa 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -81,6 +81,9 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(MSVC)$") set(FRUIT_TESTONLY_CXXFLAGS "${FRUIT_TESTONLY_CXXFLAGS} /wd4702 /wd4503") endif() +add_library(test_headers_copy SHARED test_common.cpp) +target_link_libraries(test_headers_copy fruit) + # Escape the backslash which is a Windows path separator. string(REPLACE "\\" "\\\\" ADDITIONAL_INCLUDE_DIRS "${Boost_INCLUDE_DIRS}") @@ -98,6 +101,8 @@ CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}' PATH_TO_COMPILED_FRUIT='$<TARGET_FILE_DIR:fruit>' PATH_TO_COMPILED_FRUIT_LIB='$<TARGET_FILE:fruit>' +PATH_TO_COMPILED_TEST_HEADERS='$<TARGET_FILE_DIR:test_headers_copy>' +PATH_TO_COMPILED_TEST_HEADERS_LIB='$<TARGET_FILE:test_headers_copy>' PATH_TO_FRUIT_STATIC_HEADERS='${CMAKE_CURRENT_SOURCE_DIR}/../include' PATH_TO_FRUIT_GENERATED_HEADERS='${CMAKE_CURRENT_BINARY_DIR}/../include' PATH_TO_FRUIT_TEST_HEADERS='${CMAKE_CURRENT_SOURCE_DIR}' diff --git a/tests/build_defs.bzl b/tests/build_defs.bzl index 13d3005..05bd13c 100644 --- a/tests/build_defs.bzl +++ b/tests/build_defs.bzl @@ -12,6 +12,7 @@ def fruit_py_tests(srcs, data=[]): data = data + [ "//third_party/fruit:fruit_headers", "//third_party/fruit/tests:libfruit.so", + "//third_party/fruit/tests:libtest_headers_copy.so", "//third_party/fruit/tests:test_headers_filegroup", ], shard_count = 32, diff --git a/tests/data_structures/test_semistatic_graph.py b/tests/data_structures/test_semistatic_graph.py index e0510da..95629e7 100644 --- a/tests/data_structures/test_semistatic_graph.py +++ b/tests/data_structures/test_semistatic_graph.py @@ -19,30 +19,10 @@ from fruit_test_common import * COMMON_DEFINITIONS = ''' #include "test_common.h" - #define IN_FRUIT_CPP_FILE 1 - #include <fruit/impl/data_structures/semistatic_graph.templates.h> - using namespace std; using namespace fruit::impl; - using Graph = SemistaticGraph<int, const char*>; - using node_iterator = Graph::node_iterator; - using edge_iterator = Graph::edge_iterator; - vector<int> no_neighbors{}; - - struct SimpleNode { - int id; - const char* value; - const vector<int>* neighbors; - bool is_terminal; - - int getId() { return id; } - const char* getValue() { return value; } - bool isTerminal() { return is_terminal; } - vector<int>::const_iterator getEdgesBegin() { return neighbors->begin(); } - vector<int>::const_iterator getEdgesEnd() { return neighbors->end(); } - }; ''' class TestSemistaticGraph(parameterized.TestCase): diff --git a/tests/fruit_test_common.py b/tests/fruit_test_common.py index 064dc82..36e5b20 100644 --- a/tests/fruit_test_common.py +++ b/tests/fruit_test_common.py @@ -200,14 +200,21 @@ if CXX_COMPILER_NAME == 'MSVC': path_to_fruit_lib = PATH_TO_COMPILED_FRUIT_LIB[:-4] + '.lib' else: path_to_fruit_lib = PATH_TO_COMPILED_FRUIT_LIB - fruit_tests_linker_flags = [path_to_fruit_lib] + if PATH_TO_COMPILED_TEST_HEADERS_LIB.endswith('.dll'): + path_to_test_headers_lib = PATH_TO_COMPILED_TEST_HEADERS_LIB[:-4] + '.lib' + else: + path_to_test_headers_lib = PATH_TO_COMPILED_TEST_HEADERS_LIB + fruit_tests_linker_flags = [path_to_fruit_lib, path_to_test_headers_lib] fruit_error_message_extraction_regex = 'error C2338: (.*)' else: compiler = PosixCompiler() fruit_tests_linker_flags = [ '-lfruit', + '-ltest_headers_copy', '-L' + PATH_TO_COMPILED_FRUIT, '-Wl,-rpath,' + PATH_TO_COMPILED_FRUIT, + '-L' + PATH_TO_COMPILED_TEST_HEADERS, + '-Wl,-rpath,' + PATH_TO_COMPILED_TEST_HEADERS, ] fruit_error_message_extraction_regex = 'static.assert(.*)' @@ -222,9 +229,12 @@ _assert_helper = unittest.TestCase() def modify_env_for_compiled_executables(env): env = env.copy() path_to_fruit_lib_dir = os.path.dirname(PATH_TO_COMPILED_FRUIT_LIB) + path_to_fruit_test_headers_dir = os.path.dirname(PATH_TO_COMPILED_TEST_HEADERS_LIB) print('PATH_TO_COMPILED_FRUIT_LIB:', PATH_TO_COMPILED_FRUIT_LIB) + print('PATH_TO_COMPILED_TEST_HEADERS_LIB:', PATH_TO_COMPILED_TEST_HEADERS_LIB) print('Adding directory to PATH:', path_to_fruit_lib_dir) - env["PATH"] += os.pathsep + path_to_fruit_lib_dir + print('Adding directory to PATH:', path_to_fruit_test_headers_dir) + env["PATH"] += os.pathsep + path_to_fruit_lib_dir + os.pathsep + path_to_fruit_test_headers_dir return env def _create_temporary_file(file_content, file_name_suffix=''): diff --git a/tests/test_common.cpp b/tests/test_common.cpp new file mode 100644 index 0000000..868827f --- /dev/null +++ b/tests/test_common.cpp @@ -0,0 +1,36 @@ +/* + * Copyright 2014 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define IN_FRUIT_CPP_FILE 1 + +#include "test_common.h" + +#include <fruit/impl/data_structures/semistatic_graph.templates.h> + +// Clang requires the following instantiation to be in its namespace. +namespace fruit { +namespace impl { + +template class SemistaticGraph<int, const char*>; +template SemistaticGraph<int, char const*>::SemistaticGraph(std::vector<SimpleNode>::iterator first, std::vector<SimpleNode>::iterator last, MemoryPool& memory_pool); +template SemistaticGraph<int, char const*>::SemistaticGraph(const fruit::impl::SemistaticGraph<int, char const*>& graph, std::vector<SimpleNode>::iterator first, std::vector<SimpleNode>::iterator last, MemoryPool& memory_pool); +template class SemistaticMap<int, SemistaticGraphInternalNodeId>; + +} // namespace impl +} // namespace fruit + + + diff --git a/tests/test_common.h b/tests/test_common.h index d48f110..56e2b13 100644 --- a/tests/test_common.h +++ b/tests/test_common.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef FRUIT_TEST_COMMON_H -#define FRUIT_TEST_COMMON_H +#ifndef FRUIT_COMMON_H +#define FRUIT_COMMON_H // This file includes headers used in various tests. // This allows to improve compilation speed (and therefore test time) by pre-compiling this header. @@ -27,4 +27,23 @@ #include <map> #include <vector> -#endif // FRUIT_TEST_COMMON_H +// These are here because including Boost in test code would require depending on its headers but those files don't have +// public visibility in the bazel repo. +#include <fruit/impl/data_structures/semistatic_graph.h> +using Graph = fruit::impl::SemistaticGraph<int, const char*>; +using node_iterator = Graph::node_iterator; +using edge_iterator = Graph::edge_iterator; +struct SimpleNode { + int id; + const char* value; + const std::vector<int>* neighbors; + bool is_terminal; + + int getId() { return id; } + const char* getValue() { return value; } + bool isTerminal() { return is_terminal; } + std::vector<int>::const_iterator getEdgesBegin() { return neighbors->begin(); } + std::vector<int>::const_iterator getEdgesEnd() { return neighbors->end(); } +}; + +#endif // FRUIT_COMMON_H |