I updated our Bazel CI jobs to cover `//pkg/...` and thereby exercise this new test. That made me realize that `//pkg/...` was not fully buildable because there was a reference to the non-existent target `@utf8_range//:dist_files`, so I also fixed that. PiperOrigin-RevId: 498437497pull/11426/head
parent
b7d54ace5e
commit
dea15165c6
7 changed files with 137 additions and 2 deletions
@ -0,0 +1,40 @@ |
||||
# Tests for CMake file list generation |
||||
|
||||
load("//pkg:build_systems.bzl", "gen_file_lists") |
||||
load("//pkg:cc_dist_library.bzl", "cc_dist_library") |
||||
|
||||
cc_library( |
||||
name = "test_lib", |
||||
testonly = True, |
||||
srcs = ["test_lib.cc"], |
||||
hdrs = ["test_lib.h"], |
||||
) |
||||
|
||||
cc_dist_library( |
||||
name = "test_lib_dist", |
||||
testonly = True, |
||||
deps = [":test_lib"], |
||||
) |
||||
|
||||
gen_file_lists( |
||||
name = "gen_file_lists", |
||||
testonly = True, |
||||
out_stem = "file_lists", |
||||
src_libs = { |
||||
":test_lib_dist": "libtest", |
||||
}, |
||||
) |
||||
|
||||
# This test checks the output from gen_file_lists() against a golden file. |
||||
sh_test( |
||||
name = "gen_file_lists_golden_test", |
||||
srcs = ["gen_file_lists_golden_test.sh"], |
||||
args = [ |
||||
"$(location file_lists.cmake.golden)", |
||||
"$(location :gen_file_lists)", |
||||
], |
||||
data = [ |
||||
"file_lists.cmake.golden", |
||||
":gen_file_lists", |
||||
], |
||||
) |
@ -0,0 +1,20 @@ |
||||
# Auto-generated by @//pkg/test:gen_file_lists_cmake |
||||
# |
||||
# This file contains lists of sources based on Bazel rules. It should |
||||
# be included from a hand-written CMake file that defines targets. |
||||
# |
||||
# Changes to this file will be overwritten based on Bazel definitions. |
||||
|
||||
if(${CMAKE_VERSION} VERSION_GREATER 3.10 OR ${CMAKE_VERSION} VERSION_EQUAL 3.10) |
||||
include_guard() |
||||
endif() |
||||
|
||||
# @//pkg/test:test_lib_dist |
||||
set(libtest_srcs |
||||
${protobuf_SOURCE_DIR}/pkg/test/test_lib.cc |
||||
) |
||||
|
||||
# @//pkg/test:test_lib_dist |
||||
set(libtest_hdrs |
||||
${protobuf_SOURCE_DIR}/pkg/test/test_lib.h |
||||
) |
@ -0,0 +1,14 @@ |
||||
#!/bin/bash |
||||
|
||||
set -ex |
||||
|
||||
if cmp "$1" "$2"; then |
||||
# Files are identical, as expected. |
||||
exit 0; |
||||
else |
||||
echo "Golden file $1 does not match generated output $2:" |
||||
echo "--------------------------------------------------" |
||||
diff -u "$1" "$2" |
||||
echo "--------------------------------------------------" |
||||
exit 1 |
||||
fi |
@ -0,0 +1,31 @@ |
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Placeholder file for testing
|
@ -0,0 +1,31 @@ |
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Placeholder file for testing
|
Loading…
Reference in new issue