From 4979489451a4067108b07bed8a243ebd6d45c2ca Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Sat, 20 Jul 2019 12:49:03 +0200 Subject: [PATCH] Add test to verify BUILD- and cmake-files are in sync with src/Makefile.am --- BUILD | 22 ++++++++++++++++++++-- build_files_updated_unittest.sh | 21 +++++++++++++++++++++ cmake/extract_includes.bat.in | 2 +- cmake/libprotobuf-lite.cmake | 2 +- cmake/tests.cmake | 14 +++++++++++--- kokoro/linux/bazel/build.sh | 2 +- src/Makefile.am | 5 ++++- update_file_lists.sh | 3 +++ 8 files changed, 62 insertions(+), 9 deletions(-) create mode 100755 build_files_updated_unittest.sh diff --git a/BUILD b/BUILD index 11cb9d3d2d..a43dc46478 100644 --- a/BUILD +++ b/BUILD @@ -107,10 +107,10 @@ LINK_OPTS = select({ load( ":protobuf.bzl", "cc_proto_library", - "py_proto_library", "internal_copied_filegroup", "internal_gen_well_known_protos_java", "internal_protobuf_py_tests", + "py_proto_library", ) cc_library( @@ -515,6 +515,7 @@ cc_proto_library( COMMON_TEST_SRCS = [ # AUTOGEN(common_test_srcs) "src/google/protobuf/arena_test_util.cc", + "src/google/protobuf/map_test_util.inc", "src/google/protobuf/test_util.cc", "src/google/protobuf/test_util.inc", "src/google/protobuf/testing/file.cc", @@ -627,7 +628,7 @@ cc_test( "src/google/protobuf/wire_format_unittest.cc", ] + select({ "//conditions:default": [ - # Doesn't pass on Windows with MSVC + # AUTOGEN(non_msvc_test_srcs) "src/google/protobuf/compiler/command_line_interface_unittest.cc", ], ":msvc": [], @@ -1238,3 +1239,20 @@ cc_binary( ":text_format_conformance_suite", ], ) + +sh_test( + name = "build_files_updated_unittest", + srcs = [ + "build_files_updated_unittest.sh", + ], + data = [ + "BUILD", + "cmake/extract_includes.bat.in", + "cmake/libprotobuf.cmake", + "cmake/libprotobuf-lite.cmake", + "cmake/libprotoc.cmake", + "cmake/tests.cmake", + "src/Makefile.am", + "update_file_lists.sh", + ], +) diff --git a/build_files_updated_unittest.sh b/build_files_updated_unittest.sh new file mode 100755 index 0000000000..95de01f22f --- /dev/null +++ b/build_files_updated_unittest.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# This script verifies that BUILD files and cmake files are in sync with src/Makefile.am + +cp "BUILD" "BUILD.orginal" +cp "cmake/extract_includes.bat.in" "cmake/extract_includes.bat.in.orginal" +cp "cmake/libprotobuf-lite.cmake" "cmake/libprotobuf-lite.cmake.orginal" +cp "cmake/libprotobuf.cmake" "cmake/libprotobuf.cmake.orginal" +cp "cmake/libprotoc.cmake" "cmake/libprotoc.cmake.orginal" +cp "cmake/tests.cmake" "cmake/tests.cmake.orginal" + +if [ "$(uname)" == "Linux" ]; then + ./update_file_lists.sh +fi + +diff "BUILD.orginal" "BUILD" +diff "cmake/extract_includes.bat.in.orginal" "cmake/extract_includes.bat.in" +diff "cmake/libprotobuf-lite.cmake.orginal" "cmake/libprotobuf-lite.cmake" +diff "cmake/libprotobuf.cmake.orginal" "cmake/libprotobuf.cmake" +diff "cmake/libprotoc.cmake.orginal" "cmake/libprotoc.cmake" +diff "cmake/tests.cmake.orginal" "cmake/tests.cmake" diff --git a/cmake/extract_includes.bat.in b/cmake/extract_includes.bat.in index 7c97f20c4f..ae264e57e1 100644 --- a/cmake/extract_includes.bat.in +++ b/cmake/extract_includes.bat.in @@ -56,7 +56,6 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\implicit_weak_message copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\inlined_string_field.h" include\google\protobuf\inlined_string_field.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\coded_stream.h" include\google\protobuf\io\coded_stream.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\gzip_stream.h" include\google\protobuf\io\gzip_stream.h -copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\io_win32.h" include\google\protobuf\io\io_win32.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\printer.h" include\google\protobuf\io\printer.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\strtod.h" include\google\protobuf\io\strtod.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\tokenizer.h" include\google\protobuf\io\tokenizer.h @@ -92,6 +91,7 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\fastmem.h" incl copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\hash.h" include\google\protobuf\stubs\hash.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\logging.h" include\google\protobuf\stubs\logging.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\macros.h" include\google\protobuf\stubs\macros.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\map_util.h" include\google\protobuf\stubs\map_util.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\mutex.h" include\google\protobuf\stubs\mutex.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\once.h" include\google\protobuf\stubs\once.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\platform_macros.h" include\google\protobuf\stubs\platform_macros.h diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake index 39c39c1310..6bf86a2770 100644 --- a/cmake/libprotobuf-lite.cmake +++ b/cmake/libprotobuf-lite.cmake @@ -10,7 +10,7 @@ set(libprotobuf_lite_files ${protobuf_source_dir}/src/google/protobuf/io/io_win32.cc ${protobuf_source_dir}/src/google/protobuf/io/strtod.cc ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.cc - ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.cc + ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.cc ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc ${protobuf_source_dir}/src/google/protobuf/message_lite.cc ${protobuf_source_dir}/src/google/protobuf/parse_context.cc diff --git a/cmake/tests.cmake b/cmake/tests.cmake index 5c25acc68a..d4b47c54e5 100644 --- a/cmake/tests.cmake +++ b/cmake/tests.cmake @@ -132,7 +132,6 @@ set(tests_files ${protobuf_source_dir}/src/google/protobuf/arena_unittest.cc ${protobuf_source_dir}/src/google/protobuf/arenastring_unittest.cc ${protobuf_source_dir}/src/google/protobuf/compiler/annotation_test_util.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/command_line_interface_unittest.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_move_unittest.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc @@ -203,12 +202,21 @@ set(tests_files ${protobuf_source_dir}/src/google/protobuf/wire_format_unittest.cc ) +set(non_msvc_tests_files + ${protobuf_source_dir}/src/google/protobuf/compiler/command_line_interface_unittest.cc +) + +set(all_tests_files + ${tests_files} + ${non_msvc_tests_files} +) + if(protobuf_ABSOLUTE_TEST_PLUGIN_PATH) add_compile_options(-DGOOGLE_PROTOBUF_TEST_PLUGIN_PATH="$") endif() if(MINGW) - set_source_files_properties(${tests_files} PROPERTIES COMPILE_FLAGS "-Wno-narrowing") + set_source_files_properties(${all_tests_files} PROPERTIES COMPILE_FLAGS "-Wno-narrowing") # required for tests on MinGW Win64 if (CMAKE_SIZEOF_VOID_P EQUAL 8) @@ -218,7 +226,7 @@ if(MINGW) endif() -add_executable(tests ${tests_files} ${common_test_files} ${tests_proto_files} ${lite_test_proto_files}) +add_executable(tests ${all_tests_files} ${common_test_files} ${tests_proto_files} ${lite_test_proto_files}) target_link_libraries(tests libprotoc libprotobuf gmock_main) set(test_plugin_files diff --git a/kokoro/linux/bazel/build.sh b/kokoro/linux/bazel/build.sh index a49e855c4a..f6be2ac748 100755 --- a/kokoro/linux/bazel/build.sh +++ b/kokoro/linux/bazel/build.sh @@ -11,7 +11,7 @@ bazel version cd $(dirname $0)/../../.. git submodule update --init --recursive -bazel test :protobuf_test --copt=-Werror --host_copt=-Werror +bazel test :build_files_updated_unittest :protobuf_test --copt=-Werror --host_copt=-Werror cd examples bazel build :all diff --git a/src/Makefile.am b/src/Makefile.am index 0d93d95909..ed862661e4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -727,6 +727,9 @@ protobuf_test_CPPFLAGS = -I$(GOOGLETEST_SRC_DIR)/include \ # since test_util.cc takes forever to compile with optimization (with GCC). # See configure.ac for more info. protobuf_test_CXXFLAGS = $(NO_OPT_CXXFLAGS) +# Doesn't pass on Windows with MSVC +NON_MSVC_TEST_SOURCES = \ + google/protobuf/compiler/command_line_interface_unittest.cc protobuf_test_SOURCES = \ google/protobuf/stubs/bytestream_unittest.cc \ google/protobuf/stubs/common_unittest.cc \ @@ -772,7 +775,6 @@ protobuf_test_SOURCES = \ google/protobuf/io/zero_copy_stream_unittest.cc \ google/protobuf/compiler/annotation_test_util.h \ google/protobuf/compiler/annotation_test_util.cc \ - google/protobuf/compiler/command_line_interface_unittest.cc \ google/protobuf/compiler/importer_unittest.cc \ google/protobuf/compiler/mock_code_generator.cc \ google/protobuf/compiler/mock_code_generator.h \ @@ -804,6 +806,7 @@ protobuf_test_SOURCES = \ google/protobuf/util/message_differencer_unittest.cc \ google/protobuf/util/time_util_test.cc \ google/protobuf/util/type_resolver_util_test.cc \ + $(NON_MSVC_TEST_SOURCES) \ $(COMMON_TEST_SOURCES) nodist_protobuf_test_SOURCES = $(protoc_outputs) $(am_protobuf_test_OBJECTS): unittest_proto_middleman diff --git a/update_file_lists.sh b/update_file_lists.sh index 646c8ce344..e0b446f867 100755 --- a/update_file_lists.sh +++ b/update_file_lists.sh @@ -63,6 +63,7 @@ WKT_PROTOS=$(get_variable_value $MAKEFILE nobase_dist_proto_DATA) COMMON_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_TEST_SOURCES) COMMON_LITE_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_LITE_TEST_SOURCES) TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_test_SOURCES) +NON_MSVC_TEST_SOURCES=$(get_source_files $MAKEFILE NON_MSVC_TEST_SOURCES) LITE_TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_lite_test_SOURCES) LITE_ARENA_TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_lite_arena_test_SOURCES) TEST_PLUGIN_SOURCES=$(get_source_files $MAKEFILE test_plugin_SOURCES) @@ -123,6 +124,7 @@ set_cmake_value $CMAKE_DIR/tests.cmake tests_protos "" $PROTOS_BLACKLISTED set_cmake_value $CMAKE_DIR/tests.cmake common_test_files $CMAKE_PREFIX $COMMON_TEST_SOURCES set_cmake_value $CMAKE_DIR/tests.cmake common_lite_test_files $CMAKE_PREFIX $COMMON_LITE_TEST_SOURCES set_cmake_value $CMAKE_DIR/tests.cmake tests_files $CMAKE_PREFIX $TEST_SOURCES +set_cmake_value $CMAKE_DIR/tests.cmake non_msvc_tests_files $CMAKE_PREFIX $NON_MSVC_TEST_SOURCES set_cmake_value $CMAKE_DIR/tests.cmake lite_test_files $CMAKE_PREFIX $LITE_TEST_SOURCES set_cmake_value $CMAKE_DIR/tests.cmake lite_arena_test_files $CMAKE_PREFIX $LITE_ARENA_TEST_SOURCES @@ -186,6 +188,7 @@ if [ -f "$BAZEL_BUILD" ]; then set_bazel_value $BAZEL_BUILD test_protos "" $PROTOS set_bazel_value $BAZEL_BUILD common_test_srcs $BAZEL_PREFIX $COMMON_TEST_SOURCES set_bazel_value $BAZEL_BUILD test_srcs $BAZEL_PREFIX $TEST_SOURCES + set_bazel_value $BAZEL_BUILD non_msvc_test_srcs $BAZEL_PREFIX $NON_MSVC_TEST_SOURCES set_bazel_value $BAZEL_BUILD test_plugin_srcs $BAZEL_PREFIX $TEST_PLUGIN_SOURCES else echo "Skipped BUILD file update."