|
|
|
@ -52,6 +52,13 @@ class TestGenerator : public CodeGenerator { |
|
|
|
|
io::Printer printer(output.get(), '$'); |
|
|
|
|
printer.Print("// inserted $name$\n", "name", insertion_point); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint64_t GetSupportedFeatures() const override { |
|
|
|
|
return CodeGenerator::Feature::FEATURE_SUPPORTS_EDITIONS; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Edition GetMinimumEdition() const override { return Edition::EDITION_PROTO2; } |
|
|
|
|
Edition GetMaximumEdition() const override { return Edition::EDITION_2023; } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// This test verifies that all the expected insertion points exist. It does
|
|
|
|
@ -60,14 +67,17 @@ class TestGenerator : public CodeGenerator { |
|
|
|
|
TEST(JavaPluginTest, PluginTest) { |
|
|
|
|
ABSL_CHECK_OK( |
|
|
|
|
File::SetContents(absl::StrCat(TestTempDir(), "/test.proto"), |
|
|
|
|
"syntax = \"proto2\";\n" |
|
|
|
|
"edition = \"2023\";\n" |
|
|
|
|
"package foo;\n" |
|
|
|
|
"option java_package = \"\";\n" |
|
|
|
|
"option java_outer_classname = \"Test\";\n" |
|
|
|
|
"message Bar {\n" |
|
|
|
|
" message Baz {}\n" |
|
|
|
|
"}\n" |
|
|
|
|
"enum Qux { BLAH = 1; }\n", |
|
|
|
|
"enum Qux {\n" |
|
|
|
|
" option features.enum_type = CLOSED;\n" |
|
|
|
|
" BLAH = 1;\n" |
|
|
|
|
"}\n", |
|
|
|
|
true)); |
|
|
|
|
|
|
|
|
|
CommandLineInterface cli; |
|
|
|
@ -82,10 +92,11 @@ TEST(JavaPluginTest, PluginTest) { |
|
|
|
|
std::string java_out = absl::StrCat("--java_out=", TestTempDir()); |
|
|
|
|
std::string test_out = absl::StrCat("--test_out=", TestTempDir()); |
|
|
|
|
|
|
|
|
|
const char* argv[] = {"protoc", proto_path.c_str(), java_out.c_str(), |
|
|
|
|
test_out.c_str(), "test.proto"}; |
|
|
|
|
const char* argv[] = { |
|
|
|
|
"protoc", proto_path.c_str(), java_out.c_str(), |
|
|
|
|
test_out.c_str(), "--experimental_editions", "test.proto"}; |
|
|
|
|
|
|
|
|
|
EXPECT_EQ(0, cli.Run(5, argv)); |
|
|
|
|
EXPECT_EQ(0, cli.Run(6, argv)); |
|
|
|
|
|
|
|
|
|
// Loop over the lines of the generated code and verify that we find what we
|
|
|
|
|
// expect
|
|
|
|
|