merge(3p/absl): subtree merge of Abseil up to e19260f
... notably, this includes Abseil's own StatusOr type, which conflicted with our implementation (that was taken from TensorFlow). Change-Id: Ie7d6764b64055caaeb8dc7b6b9d066291e6b538f
This commit is contained in:
parent
cc27324d02
commit
082c006c04
854 changed files with 11260 additions and 5296 deletions
|
|
@ -87,6 +87,11 @@ class UsageReportingTest : public testing::Test {
|
|||
default_config.normalize_filename = &NormalizeFileName;
|
||||
absl::SetFlagsUsageConfig(default_config);
|
||||
}
|
||||
~UsageReportingTest() override {
|
||||
flags::SetFlagsHelpMode(flags::HelpMode::kNone);
|
||||
flags::SetFlagsHelpMatchSubstr("");
|
||||
flags::SetFlagsHelpFormat(flags::HelpFormat::kHumanReadable);
|
||||
}
|
||||
|
||||
private:
|
||||
absl::FlagSaver flag_saver_;
|
||||
|
|
@ -191,6 +196,10 @@ TEST_F(UsageReportingTest, TestFlagsHelpHRF) {
|
|||
Some more help.
|
||||
Even more long long long long long long long long long long long long help
|
||||
message.); default: "";
|
||||
|
||||
Try --helpfull to get a list of all flags or --help=substring shows help for
|
||||
flags which include specified substring in either in the name, or description or
|
||||
path.
|
||||
)";
|
||||
|
||||
std::stringstream test_buf_01;
|
||||
|
|
@ -214,7 +223,11 @@ TEST_F(UsageReportingTest, TestFlagsHelpHRF) {
|
|||
EXPECT_EQ(test_buf_04.str(),
|
||||
R"(usage_test: Custom usage message
|
||||
|
||||
No modules matched: use -helpfull
|
||||
No flags matched.
|
||||
|
||||
Try --helpfull to get a list of all flags or --help=substring shows help for
|
||||
flags which include specified substring in either in the name, or description or
|
||||
path.
|
||||
)");
|
||||
|
||||
std::stringstream test_buf_05;
|
||||
|
|
@ -226,12 +239,8 @@ TEST_F(UsageReportingTest, TestFlagsHelpHRF) {
|
|||
absl::StartsWith(test_out_str, "usage_test: Custom usage message"));
|
||||
EXPECT_TRUE(absl::StrContains(
|
||||
test_out_str, "Flags from absl/flags/internal/usage_test.cc:"));
|
||||
EXPECT_TRUE(absl::StrContains(test_out_str,
|
||||
"Flags from absl/flags/internal/usage.cc:"));
|
||||
EXPECT_TRUE(
|
||||
absl::StrContains(test_out_str, "-usage_reporting_test_flag_01 "));
|
||||
EXPECT_TRUE(absl::StrContains(test_out_str, "-help (show help"))
|
||||
<< test_out_str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
|
@ -244,7 +253,7 @@ TEST_F(UsageReportingTest, TestNoUsageFlags) {
|
|||
// --------------------------------------------------------------------
|
||||
|
||||
TEST_F(UsageReportingTest, TestUsageFlag_helpshort) {
|
||||
absl::SetFlag(&FLAGS_helpshort, true);
|
||||
flags::SetFlagsHelpMode(flags::HelpMode::kShort);
|
||||
|
||||
std::stringstream test_buf;
|
||||
EXPECT_EQ(flags::HandleUsageFlags(test_buf, kTestUsageMessage), 1);
|
||||
|
|
@ -267,13 +276,17 @@ TEST_F(UsageReportingTest, TestUsageFlag_helpshort) {
|
|||
Some more help.
|
||||
Even more long long long long long long long long long long long long help
|
||||
message.); default: "";
|
||||
|
||||
Try --helpfull to get a list of all flags or --help=substring shows help for
|
||||
flags which include specified substring in either in the name, or description or
|
||||
path.
|
||||
)");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
TEST_F(UsageReportingTest, TestUsageFlag_help) {
|
||||
absl::SetFlag(&FLAGS_help, true);
|
||||
TEST_F(UsageReportingTest, TestUsageFlag_help_simple) {
|
||||
flags::SetFlagsHelpMode(flags::HelpMode::kImportant);
|
||||
|
||||
std::stringstream test_buf;
|
||||
EXPECT_EQ(flags::HandleUsageFlags(test_buf, kTestUsageMessage), 1);
|
||||
|
|
@ -297,14 +310,74 @@ TEST_F(UsageReportingTest, TestUsageFlag_help) {
|
|||
Even more long long long long long long long long long long long long help
|
||||
message.); default: "";
|
||||
|
||||
Try --helpfull to get a list of all flags.
|
||||
Try --helpfull to get a list of all flags or --help=substring shows help for
|
||||
flags which include specified substring in either in the name, or description or
|
||||
path.
|
||||
)");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
TEST_F(UsageReportingTest, TestUsageFlag_help_one_flag) {
|
||||
flags::SetFlagsHelpMode(flags::HelpMode::kMatch);
|
||||
flags::SetFlagsHelpMatchSubstr("usage_reporting_test_flag_06");
|
||||
|
||||
std::stringstream test_buf;
|
||||
EXPECT_EQ(flags::HandleUsageFlags(test_buf, kTestUsageMessage), 1);
|
||||
EXPECT_EQ(test_buf.str(),
|
||||
R"(usage_test: Custom usage message
|
||||
|
||||
Flags from absl/flags/internal/usage_test.cc:
|
||||
--usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message.
|
||||
|
||||
Some more help.
|
||||
Even more long long long long long long long long long long long long help
|
||||
message.); default: "";
|
||||
|
||||
Try --helpfull to get a list of all flags or --help=substring shows help for
|
||||
flags which include specified substring in either in the name, or description or
|
||||
path.
|
||||
)");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
TEST_F(UsageReportingTest, TestUsageFlag_help_multiple_flag) {
|
||||
flags::SetFlagsHelpMode(flags::HelpMode::kMatch);
|
||||
flags::SetFlagsHelpMatchSubstr("test_flag");
|
||||
|
||||
std::stringstream test_buf;
|
||||
EXPECT_EQ(flags::HandleUsageFlags(test_buf, kTestUsageMessage), 1);
|
||||
EXPECT_EQ(test_buf.str(),
|
||||
R"(usage_test: Custom usage message
|
||||
|
||||
Flags from absl/flags/internal/usage_test.cc:
|
||||
--usage_reporting_test_flag_01 (usage_reporting_test_flag_01 help message);
|
||||
default: 101;
|
||||
--usage_reporting_test_flag_02 (usage_reporting_test_flag_02 help message);
|
||||
default: false;
|
||||
--usage_reporting_test_flag_03 (usage_reporting_test_flag_03 help message);
|
||||
default: 1.03;
|
||||
--usage_reporting_test_flag_04 (usage_reporting_test_flag_04 help message);
|
||||
default: 1000000000000004;
|
||||
--usage_reporting_test_flag_05 (usage_reporting_test_flag_05 help message);
|
||||
default: UDT{};
|
||||
--usage_reporting_test_flag_06 (usage_reporting_test_flag_06 help message.
|
||||
|
||||
Some more help.
|
||||
Even more long long long long long long long long long long long long help
|
||||
message.); default: "";
|
||||
|
||||
Try --helpfull to get a list of all flags or --help=substring shows help for
|
||||
flags which include specified substring in either in the name, or description or
|
||||
path.
|
||||
)");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
TEST_F(UsageReportingTest, TestUsageFlag_helppackage) {
|
||||
absl::SetFlag(&FLAGS_helppackage, true);
|
||||
flags::SetFlagsHelpMode(flags::HelpMode::kPackage);
|
||||
|
||||
std::stringstream test_buf;
|
||||
EXPECT_EQ(flags::HandleUsageFlags(test_buf, kTestUsageMessage), 1);
|
||||
|
|
@ -328,14 +401,16 @@ TEST_F(UsageReportingTest, TestUsageFlag_helppackage) {
|
|||
Even more long long long long long long long long long long long long help
|
||||
message.); default: "";
|
||||
|
||||
Try --helpfull to get a list of all flags.
|
||||
Try --helpfull to get a list of all flags or --help=substring shows help for
|
||||
flags which include specified substring in either in the name, or description or
|
||||
path.
|
||||
)");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
TEST_F(UsageReportingTest, TestUsageFlag_version) {
|
||||
absl::SetFlag(&FLAGS_version, true);
|
||||
flags::SetFlagsHelpMode(flags::HelpMode::kVersion);
|
||||
|
||||
std::stringstream test_buf;
|
||||
EXPECT_EQ(flags::HandleUsageFlags(test_buf, kTestUsageMessage), 0);
|
||||
|
|
@ -349,7 +424,7 @@ TEST_F(UsageReportingTest, TestUsageFlag_version) {
|
|||
// --------------------------------------------------------------------
|
||||
|
||||
TEST_F(UsageReportingTest, TestUsageFlag_only_check_args) {
|
||||
absl::SetFlag(&FLAGS_only_check_args, true);
|
||||
flags::SetFlagsHelpMode(flags::HelpMode::kOnlyCheckArgs);
|
||||
|
||||
std::stringstream test_buf;
|
||||
EXPECT_EQ(flags::HandleUsageFlags(test_buf, kTestUsageMessage), 0);
|
||||
|
|
@ -359,17 +434,22 @@ TEST_F(UsageReportingTest, TestUsageFlag_only_check_args) {
|
|||
// --------------------------------------------------------------------
|
||||
|
||||
TEST_F(UsageReportingTest, TestUsageFlag_helpon) {
|
||||
absl::SetFlag(&FLAGS_helpon, "bla-bla");
|
||||
flags::SetFlagsHelpMode(flags::HelpMode::kMatch);
|
||||
flags::SetFlagsHelpMatchSubstr("/bla-bla.");
|
||||
|
||||
std::stringstream test_buf_01;
|
||||
EXPECT_EQ(flags::HandleUsageFlags(test_buf_01, kTestUsageMessage), 1);
|
||||
EXPECT_EQ(test_buf_01.str(),
|
||||
R"(usage_test: Custom usage message
|
||||
|
||||
No modules matched: use -helpfull
|
||||
No flags matched.
|
||||
|
||||
Try --helpfull to get a list of all flags or --help=substring shows help for
|
||||
flags which include specified substring in either in the name, or description or
|
||||
path.
|
||||
)");
|
||||
|
||||
absl::SetFlag(&FLAGS_helpon, "usage_test");
|
||||
flags::SetFlagsHelpMatchSubstr("/usage_test.");
|
||||
|
||||
std::stringstream test_buf_02;
|
||||
EXPECT_EQ(flags::HandleUsageFlags(test_buf_02, kTestUsageMessage), 1);
|
||||
|
|
@ -392,6 +472,10 @@ TEST_F(UsageReportingTest, TestUsageFlag_helpon) {
|
|||
Some more help.
|
||||
Even more long long long long long long long long long long long long help
|
||||
message.); default: "";
|
||||
|
||||
Try --helpfull to get a list of all flags or --help=substring shows help for
|
||||
flags which include specified substring in either in the name, or description or
|
||||
path.
|
||||
)");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue