summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2020-04-22 10:52:29 -0700
committerGravatar Derek Mauro <dmauro@google.com>2020-04-22 18:03:15 +0000
commit902909a430e2558ad446294159af39bf019a1ef6 (patch)
tree1efe99ef701d2afad97677797e977cdac40cce50
parentcb52b05ea20e8d196f17b45a420c2d323e401324 (diff)
Export of internal Abseil changes
-- 692d3df279e7592d01c1008cb85f2a010c3d17da by Abseil Team <absl-team@google.com>: Use EXPECT_DEATH_IF_SUPPORTED instead of raw EXPECT_DEATH. PiperOrigin-RevId: 307802196 -- ebc40936b677b79cad9f87f944794c35946f9dbd by Gennadiy Rozental <rogeeff@google.com>: Eliminate SetCallback from absl::Flag<T> public interface. We also make SetCallback on FlagRegistrar to return rvalue, so that we can add more tail calls after it. PiperOrigin-RevId: 307745935 GitOrigin-RevId: 15f69a9dae9c70c884ce85ca1a4bf359a2609db0 Change-Id: Ibec13463e44e4071c48fb12389f47e716cee7a9d
-rw-r--r--absl/container/btree_test.cc2
-rw-r--r--absl/container/fixed_array_test.cc26
-rw-r--r--absl/debugging/failure_signal_handler_test.cc6
-rw-r--r--absl/flags/flag.h3
-rw-r--r--absl/flags/flag_test.cc23
-rw-r--r--absl/flags/internal/flag.h7
-rw-r--r--absl/flags/internal/usage_test.cc5
-rw-r--r--absl/flags/parse_test.cc39
-rw-r--r--absl/strings/CMakeLists.txt2
-rw-r--r--absl/types/optional_test.cc2
-rw-r--r--absl/types/variant_test.cc2
11 files changed, 59 insertions, 58 deletions
diff --git a/absl/container/btree_test.cc b/absl/container/btree_test.cc
index 7ccdf6a1..bbdb5f42 100644
--- a/absl/container/btree_test.cc
+++ b/absl/container/btree_test.cc
@@ -1543,7 +1543,7 @@ TEST(Btree, MapAt) {
#ifdef ABSL_HAVE_EXCEPTIONS
EXPECT_THROW(map.at(3), std::out_of_range);
#else
- EXPECT_DEATH(map.at(3), "absl::btree_map::at");
+ EXPECT_DEATH_IF_SUPPORTED(map.at(3), "absl::btree_map::at");
#endif
}
diff --git a/absl/container/fixed_array_test.cc b/absl/container/fixed_array_test.cc
index 90e950c7..064a88a2 100644
--- a/absl/container/fixed_array_test.cc
+++ b/absl/container/fixed_array_test.cc
@@ -773,10 +773,10 @@ TEST(FixedArrayTest, AddressSanitizerAnnotations1) {
int* raw = a.data();
raw[0] = 0;
raw[9] = 0;
- EXPECT_DEATH(raw[-2] = 0, "container-overflow");
- EXPECT_DEATH(raw[-1] = 0, "container-overflow");
- EXPECT_DEATH(raw[10] = 0, "container-overflow");
- EXPECT_DEATH(raw[31] = 0, "container-overflow");
+ EXPECT_DEATH_IF_SUPPORTED(raw[-2] = 0, "container-overflow");
+ EXPECT_DEATH_IF_SUPPORTED(raw[-1] = 0, "container-overflow");
+ EXPECT_DEATH_IF_SUPPORTED(raw[10] = 0, "container-overflow");
+ EXPECT_DEATH_IF_SUPPORTED(raw[31] = 0, "container-overflow");
}
TEST(FixedArrayTest, AddressSanitizerAnnotations2) {
@@ -784,10 +784,10 @@ TEST(FixedArrayTest, AddressSanitizerAnnotations2) {
char* raw = a.data();
raw[0] = 0;
raw[11] = 0;
- EXPECT_DEATH(raw[-7] = 0, "container-overflow");
- EXPECT_DEATH(raw[-1] = 0, "container-overflow");
- EXPECT_DEATH(raw[12] = 0, "container-overflow");
- EXPECT_DEATH(raw[17] = 0, "container-overflow");
+ EXPECT_DEATH_IF_SUPPORTED(raw[-7] = 0, "container-overflow");
+ EXPECT_DEATH_IF_SUPPORTED(raw[-1] = 0, "container-overflow");
+ EXPECT_DEATH_IF_SUPPORTED(raw[12] = 0, "container-overflow");
+ EXPECT_DEATH_IF_SUPPORTED(raw[17] = 0, "container-overflow");
}
TEST(FixedArrayTest, AddressSanitizerAnnotations3) {
@@ -795,8 +795,8 @@ TEST(FixedArrayTest, AddressSanitizerAnnotations3) {
uint64_t* raw = a.data();
raw[0] = 0;
raw[19] = 0;
- EXPECT_DEATH(raw[-1] = 0, "container-overflow");
- EXPECT_DEATH(raw[20] = 0, "container-overflow");
+ EXPECT_DEATH_IF_SUPPORTED(raw[-1] = 0, "container-overflow");
+ EXPECT_DEATH_IF_SUPPORTED(raw[20] = 0, "container-overflow");
}
TEST(FixedArrayTest, AddressSanitizerAnnotations4) {
@@ -808,11 +808,11 @@ TEST(FixedArrayTest, AddressSanitizerAnnotations4) {
// there is only a 8-byte red zone before the container range, so we only
// access the last 4 bytes of the struct to make sure it stays within the red
// zone.
- EXPECT_DEATH(raw[-1].z_ = 0, "container-overflow");
- EXPECT_DEATH(raw[10] = ThreeInts(), "container-overflow");
+ EXPECT_DEATH_IF_SUPPORTED(raw[-1].z_ = 0, "container-overflow");
+ EXPECT_DEATH_IF_SUPPORTED(raw[10] = ThreeInts(), "container-overflow");
// The actual size of storage is kDefaultBytes=256, 21*12 = 252,
// so reading raw[21] should still trigger the correct warning.
- EXPECT_DEATH(raw[21] = ThreeInts(), "container-overflow");
+ EXPECT_DEATH_IF_SUPPORTED(raw[21] = ThreeInts(), "container-overflow");
}
#endif // ADDRESS_SANITIZER
diff --git a/absl/debugging/failure_signal_handler_test.cc b/absl/debugging/failure_signal_handler_test.cc
index 863fb514..d8283b2f 100644
--- a/absl/debugging/failure_signal_handler_test.cc
+++ b/absl/debugging/failure_signal_handler_test.cc
@@ -55,7 +55,7 @@ TEST_P(FailureSignalHandlerDeathTest, AbslFailureSignal) {
exit_regex);
#else
// Windows doesn't have testing::KilledBySignal().
- EXPECT_DEATH(InstallHandlerAndRaise(signo), exit_regex);
+ EXPECT_DEATH_IF_SUPPORTED(InstallHandlerAndRaise(signo), exit_regex);
#endif
}
@@ -107,8 +107,8 @@ TEST_P(FailureSignalHandlerDeathTest, AbslFatalSignalsWithWriterFn) {
testing::KilledBySignal(signo), exit_regex);
#else
// Windows doesn't have testing::KilledBySignal().
- EXPECT_DEATH(InstallHandlerWithWriteToFileAndRaise(file.c_str(), signo),
- exit_regex);
+ EXPECT_DEATH_IF_SUPPORTED(
+ InstallHandlerWithWriteToFileAndRaise(file.c_str(), signo), exit_regex);
#endif
// Open the file in this process and check its contents.
diff --git a/absl/flags/flag.h b/absl/flags/flag.h
index 15061592..194a9d31 100644
--- a/absl/flags/flag.h
+++ b/absl/flags/flag.h
@@ -149,9 +149,6 @@ class Flag {
}
T Get() const { return GetImpl()->Get(); }
void Set(const T& v) { GetImpl()->Set(v); }
- void SetCallback(const flags_internal::FlagCallbackFunc mutation_callback) {
- GetImpl()->SetCallback(mutation_callback);
- }
void InvokeCallback() { GetImpl()->InvokeCallback(); }
// The data members are logically private, but they need to be public for
diff --git a/absl/flags/flag_test.cc b/absl/flags/flag_test.cc
index dbe94a2c..6fa178f1 100644
--- a/absl/flags/flag_test.cc
+++ b/absl/flags/flag_test.cc
@@ -583,18 +583,21 @@ using FlagDeathTest = FlagTest;
TEST_F(FlagDeathTest, TestTypeMismatchValidations) {
#if !defined(NDEBUG)
- EXPECT_DEATH(static_cast<void>(absl::GetFlag(FLAGS_mistyped_int_flag)),
- "Flag 'mistyped_int_flag' is defined as one type and declared "
- "as another");
- EXPECT_DEATH(static_cast<void>(absl::GetFlag(FLAGS_mistyped_string_flag)),
- "Flag 'mistyped_string_flag' is defined as one type and "
- "declared as another");
+ EXPECT_DEATH_IF_SUPPORTED(
+ static_cast<void>(absl::GetFlag(FLAGS_mistyped_int_flag)),
+ "Flag 'mistyped_int_flag' is defined as one type and declared "
+ "as another");
+ EXPECT_DEATH_IF_SUPPORTED(
+ static_cast<void>(absl::GetFlag(FLAGS_mistyped_string_flag)),
+ "Flag 'mistyped_string_flag' is defined as one type and "
+ "declared as another");
#endif
- EXPECT_DEATH(absl::SetFlag(&FLAGS_mistyped_int_flag, 1),
- "Flag 'mistyped_int_flag' is defined as one type and declared "
- "as another");
- EXPECT_DEATH(
+ EXPECT_DEATH_IF_SUPPORTED(
+ absl::SetFlag(&FLAGS_mistyped_int_flag, 1),
+ "Flag 'mistyped_int_flag' is defined as one type and declared "
+ "as another");
+ EXPECT_DEATH_IF_SUPPORTED(
absl::SetFlag(&FLAGS_mistyped_string_flag, std::vector<std::string>{}),
"Flag 'mistyped_string_flag' is defined as one type and declared as "
"another");
diff --git a/absl/flags/internal/flag.h b/absl/flags/internal/flag.h
index 2ae3dce3..6da25aa9 100644
--- a/absl/flags/internal/flag.h
+++ b/absl/flags/internal/flag.h
@@ -556,9 +556,6 @@ class Flag {
impl_.AssertValidType(base_internal::FastTypeId<T>(), &GenRuntimeTypeId<T>);
impl_.Write(&v);
}
- void SetCallback(const FlagCallbackFunc mutation_callback) {
- impl_.SetCallback(mutation_callback);
- }
// CommandLineFlag interface
absl::string_view Name() const { return impl_.Name(); }
@@ -651,8 +648,8 @@ class FlagRegistrar {
if (do_register) flags_internal::RegisterCommandLineFlag(&flag_->impl_);
}
- FlagRegistrar& OnUpdate(FlagCallbackFunc cb) && {
- flag_->SetCallback(cb);
+ FlagRegistrar OnUpdate(FlagCallbackFunc cb) && {
+ flag_->impl_.SetCallback(cb);
return *this;
}
diff --git a/absl/flags/internal/usage_test.cc b/absl/flags/internal/usage_test.cc
index e1e57e55..8dd3532e 100644
--- a/absl/flags/internal/usage_test.cc
+++ b/absl/flags/internal/usage_test.cc
@@ -103,8 +103,9 @@ TEST_F(UsageReportingDeathTest, TestSetProgramUsageMessage) {
#ifndef _WIN32
// TODO(rogeeff): figure out why this does not work on Windows.
- EXPECT_DEATH(absl::SetProgramUsageMessage("custom usage message"),
- ".*SetProgramUsageMessage\\(\\) called twice.*");
+ EXPECT_DEATH_IF_SUPPORTED(
+ absl::SetProgramUsageMessage("custom usage message"),
+ ".*SetProgramUsageMessage\\(\\) called twice.*");
#endif
}
diff --git a/absl/flags/parse_test.cc b/absl/flags/parse_test.cc
index 6f49377a..065f757a 100644
--- a/absl/flags/parse_test.cc
+++ b/absl/flags/parse_test.cc
@@ -481,21 +481,22 @@ TEST_F(ParseDeathTest, TestUndefinedArg) {
"testbin",
"--undefined_flag",
};
- EXPECT_DEATH(InvokeParse(in_args1),
- "Unknown command line flag 'undefined_flag'");
+ EXPECT_DEATH_IF_SUPPORTED(InvokeParse(in_args1),
+ "Unknown command line flag 'undefined_flag'");
const char* in_args2[] = {
"testbin",
"--noprefixed_flag",
};
- EXPECT_DEATH(InvokeParse(in_args2),
- "Unknown command line flag 'noprefixed_flag'");
+ EXPECT_DEATH_IF_SUPPORTED(InvokeParse(in_args2),
+ "Unknown command line flag 'noprefixed_flag'");
const char* in_args3[] = {
"testbin",
"--Int_flag=1",
};
- EXPECT_DEATH(InvokeParse(in_args3), "Unknown command line flag 'Int_flag'");
+ EXPECT_DEATH_IF_SUPPORTED(InvokeParse(in_args3),
+ "Unknown command line flag 'Int_flag'");
}
// --------------------------------------------------------------------
@@ -505,7 +506,7 @@ TEST_F(ParseDeathTest, TestInvalidBoolFlagFormat) {
"testbin",
"--bool_flag=",
};
- EXPECT_DEATH(
+ EXPECT_DEATH_IF_SUPPORTED(
InvokeParse(in_args1),
"Missing the value after assignment for the boolean flag 'bool_flag'");
@@ -513,7 +514,7 @@ TEST_F(ParseDeathTest, TestInvalidBoolFlagFormat) {
"testbin",
"--nobool_flag=true",
};
- EXPECT_DEATH(InvokeParse(in_args2),
+ EXPECT_DEATH_IF_SUPPORTED(InvokeParse(in_args2),
"Negative form with assignment is not valid for the boolean "
"flag 'bool_flag'");
}
@@ -525,14 +526,14 @@ TEST_F(ParseDeathTest, TestInvalidNonBoolFlagFormat) {
"testbin",
"--nostring_flag",
};
- EXPECT_DEATH(InvokeParse(in_args1),
+ EXPECT_DEATH_IF_SUPPORTED(InvokeParse(in_args1),
"Negative form is not valid for the flag 'string_flag'");
const char* in_args2[] = {
"testbin",
"--int_flag",
};
- EXPECT_DEATH(InvokeParse(in_args2),
+ EXPECT_DEATH_IF_SUPPORTED(InvokeParse(in_args2),
"Missing the value for the flag 'int_flag'");
}
@@ -543,7 +544,7 @@ TEST_F(ParseDeathTest, TestInvalidUDTFlagFormat) {
"testbin",
"--udt_flag=1",
};
- EXPECT_DEATH(InvokeParse(in_args1),
+ EXPECT_DEATH_IF_SUPPORTED(InvokeParse(in_args1),
"Illegal value '1' specified for flag 'udt_flag'; Use values A, "
"AAA instead");
@@ -552,7 +553,7 @@ TEST_F(ParseDeathTest, TestInvalidUDTFlagFormat) {
"--udt_flag",
"AA",
};
- EXPECT_DEATH(InvokeParse(in_args2),
+ EXPECT_DEATH_IF_SUPPORTED(InvokeParse(in_args2),
"Illegal value 'AA' specified for flag 'udt_flag'; Use values "
"A, AAA instead");
}
@@ -658,7 +659,7 @@ TEST_F(ParseDeathTest, TestInvalidFlagfiles) {
GetFlagfileFlag({{"parse_test.ff4",
absl::MakeConstSpan(ff4_data)}}, &flagfile_flag),
};
- EXPECT_DEATH(InvokeParse(in_args1),
+ EXPECT_DEATH_IF_SUPPORTED(InvokeParse(in_args1),
"Unknown command line flag 'unknown_flag'");
constexpr const char* const ff5_data[] = {
@@ -670,7 +671,7 @@ TEST_F(ParseDeathTest, TestInvalidFlagfiles) {
GetFlagfileFlag({{"parse_test.ff5",
absl::MakeConstSpan(ff5_data)}}, &flagfile_flag),
};
- EXPECT_DEATH(InvokeParse(in_args2),
+ EXPECT_DEATH_IF_SUPPORTED(InvokeParse(in_args2),
"Unknown command line flag 'int_flag 10'");
constexpr const char* const ff6_data[] = {
@@ -682,14 +683,15 @@ TEST_F(ParseDeathTest, TestInvalidFlagfiles) {
GetFlagfileFlag({{"parse_test.ff6", absl::MakeConstSpan(ff6_data)}},
&flagfile_flag),
};
- EXPECT_DEATH(InvokeParse(in_args3),
+ EXPECT_DEATH_IF_SUPPORTED(InvokeParse(in_args3),
"Flagfile can't contain position arguments or --");
const char* in_args4[] = {
"testbin",
"--flagfile=invalid_flag_file",
};
- EXPECT_DEATH(InvokeParse(in_args4), "Can't open flagfile invalid_flag_file");
+ EXPECT_DEATH_IF_SUPPORTED(InvokeParse(in_args4),
+ "Can't open flagfile invalid_flag_file");
constexpr const char* const ff7_data[] = {
"--int_flag=10",
@@ -702,7 +704,7 @@ TEST_F(ParseDeathTest, TestInvalidFlagfiles) {
GetFlagfileFlag({{"parse_test.ff7", absl::MakeConstSpan(ff7_data)}},
&flagfile_flag),
};
- EXPECT_DEATH(InvokeParse(in_args5),
+ EXPECT_DEATH_IF_SUPPORTED(InvokeParse(in_args5),
"Unexpected line in the flagfile .*: \\*bin\\*");
}
@@ -724,7 +726,7 @@ TEST_F(ParseTest, TestReadingRequiredFlagsFromEnv) {
TEST_F(ParseDeathTest, TestReadingUnsetRequiredFlagsFromEnv) {
const char* in_args1[] = {"testbin", "--fromenv=int_flag"};
- EXPECT_DEATH(InvokeParse(in_args1),
+ EXPECT_DEATH_IF_SUPPORTED(InvokeParse(in_args1),
"FLAGS_int_flag not found in environment");
}
@@ -735,7 +737,8 @@ TEST_F(ParseDeathTest, TestRecursiveFlagsFromEnv) {
ScopedSetEnv set_tryfromenv("FLAGS_tryfromenv", "int_flag");
- EXPECT_DEATH(InvokeParse(in_args1), "Infinite recursion on flag tryfromenv");
+ EXPECT_DEATH_IF_SUPPORTED(InvokeParse(in_args1),
+ "Infinite recursion on flag tryfromenv");
}
// --------------------------------------------------------------------
diff --git a/absl/strings/CMakeLists.txt b/absl/strings/CMakeLists.txt
index b6705ed0..003794f9 100644
--- a/absl/strings/CMakeLists.txt
+++ b/absl/strings/CMakeLists.txt
@@ -544,7 +544,6 @@ absl_cc_library(
COPTS
${ABSL_DEFAULT_COPTS}
DEPS
- absl::strings_internal
absl::base
absl::base_internal
absl::core_headers
@@ -555,6 +554,7 @@ absl_cc_library(
absl::optional
absl::raw_logging_internal
absl::strings
+ absl::strings_internal
absl::type_traits
PUBLIC
)
diff --git a/absl/types/optional_test.cc b/absl/types/optional_test.cc
index 874334e6..7ef142cb 100644
--- a/absl/types/optional_test.cc
+++ b/absl/types/optional_test.cc
@@ -1051,7 +1051,7 @@ TEST(optionalTest, Value) {
#ifdef ABSL_HAVE_EXCEPTIONS
EXPECT_THROW((void)empty.value(), absl::bad_optional_access);
#else
- EXPECT_DEATH((void)empty.value(), "Bad optional access");
+ EXPECT_DEATH_IF_SUPPORTED((void)empty.value(), "Bad optional access");
#endif
// test constexpr value()
diff --git a/absl/types/variant_test.cc b/absl/types/variant_test.cc
index 4639c42e..cf8f7f33 100644
--- a/absl/types/variant_test.cc
+++ b/absl/types/variant_test.cc
@@ -50,7 +50,7 @@
#else
#define ABSL_VARIANT_TEST_EXPECT_FAIL(expr, exception_t, text) \
- EXPECT_DEATH(expr, text)
+ EXPECT_DEATH_IF_SUPPORTED(expr, text)
#endif // ABSL_HAVE_EXCEPTIONS