Enable warnings as errors during tests (#10482)

* Enable warnings as errors by default for test builds

* Fixing C++ warnings

* Adding host flags, and enabling warnings as error for non-C++ too

* Switch to BUILD copts instead of bazelrc to treat Windows as a snowflake

* Disable warnings as errors on Windows, since it doesn't like the c++14 flag
pull/10221/head
Mike Kruskal 2 years ago committed by GitHub
parent 683349c2e3
commit d220b43c6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .bazelrc
  2. 1
      BUILD.bazel
  3. 1
      build_defs/cpp_opts.bzl
  4. 2
      conformance/conformance_cpp.cc
  5. 16
      src/google/protobuf/compiler/cpp/helpers.cc
  6. 4
      src/google/protobuf/compiler/importer.cc
  7. 15
      src/google/protobuf/io/BUILD.bazel
  8. 4
      src/google/protobuf/util/internal/expecting_objectwriter.h

@ -1 +1 @@
build --cxxopt=-std=c++14
build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14

@ -160,6 +160,7 @@ internal_ruby_proto_library(
cc_binary(
name = "protoc",
copts = COPTS,
linkopts = LINK_OPTS + PROTOC_LINK_OPTS,
visibility = ["//visibility:public"],
deps = ["//src/google/protobuf/compiler:protoc_lib"],

@ -19,6 +19,7 @@ COPTS = select({
"-DHAVE_ZLIB",
"-Woverloaded-virtual",
"-Wno-sign-compare",
"-Werror",
],
})

@ -87,7 +87,7 @@ absl::Status ReadFd(int fd, char* buf, size_t len) {
}
absl::Status WriteFd(int fd, const void* buf, size_t len) {
if (write(fd, buf, len) != len) {
if (static_cast<size_t>(write(fd, buf, len)) != len) {
return absl::ErrnoToStatus(errno, "error reading to test runner");
}
return absl::OkStatus();

@ -210,22 +210,6 @@ bool AllocExpected(const Descriptor* descriptor) {
return false;
}
// Describes different approaches to detect non-canonical int32 encoding. Only
// kNever or kAlways is eligible for *simple* verification methods.
enum class VerifyInt32Type {
kCustom, // Only check if field number matches.
kNever, // Do not check.
kAlways, // Always check.
};
inline VerifySimpleType VerifyInt32TypeToVerifyCustom(VerifyInt32Type t) {
static VerifySimpleType kCustomTypes[] = {
VerifySimpleType::kCustom, VerifySimpleType::kCustomInt32Never,
VerifySimpleType::kCustomInt32Always};
return kCustomTypes[static_cast<int32_t>(t) -
static_cast<int32_t>(VerifyInt32Type::kCustom)];
}
} // namespace
bool IsLazy(const FieldDescriptor* field, const Options& options,

@ -256,10 +256,6 @@ DiskSourceTree::DiskSourceTree() {}
DiskSourceTree::~DiskSourceTree() {}
static inline char LastChar(const std::string& str) {
return str[str.size() - 1];
}
// Given a path, returns an equivalent path with these changes:
// - On Windows, any backslashes are replaced with forward slashes.
// - Any instances of the directory "." are removed.

@ -60,10 +60,7 @@ cc_library(
name = "printer",
srcs = ["printer.cc"],
hdrs = ["printer.h"],
copts = COPTS + select({
"//build_defs:config_msvc": [],
"//conditions:default": ["-Wno-maybe-uninitialized"],
}),
copts = COPTS,
include_prefix = "google/protobuf/io",
deps = [
":io",
@ -93,10 +90,7 @@ cc_library(
name = "gzip_stream",
srcs = ["gzip_stream.cc"],
hdrs = ["gzip_stream.h"],
copts = COPTS + select({
"//build_defs:config_msvc": [],
"//conditions:default": ["-Wno-maybe-uninitialized"],
}),
copts = COPTS,
include_prefix = "google/protobuf/io",
deps = [
":io",
@ -128,10 +122,7 @@ cc_test(
"tokenizer_unittest.cc",
"zero_copy_stream_unittest.cc",
],
copts = COPTS + select({
"//build_defs:config_msvc": [],
"//conditions:default": ["-Wno-maybe-uninitialized"],
}),
copts = COPTS,
data = [
"//src/google/protobuf:testdata",
],

@ -218,8 +218,8 @@ class ExpectingObjectWriter : public ObjectWriter {
.RetiresOnSaturation();
return this;
}
virtual ObjectWriter* RenderBytes(absl::string_view name,
absl::string_view value) {
ObjectWriter* RenderBytes(absl::string_view name,
absl::string_view value) override {
(name.empty() ? EXPECT_CALL(*mock_, RenderBytes(IsEmpty(),
TypedEq<absl::string_view>(
std::string(value))))

Loading…
Cancel
Save