@ -1217,7 +1217,8 @@ TEST_F(CommandLineInterfaceTest, InsertWithAnnotationFixup) {
" --plug_out=insert_endlines=test_generator,test_plugin:$tmpdir "
" --plug_out=insert_endlines=test_generator,test_plugin:$tmpdir "
" --proto_path=$tmpdir foo.proto " ) ;
" --proto_path=$tmpdir foo.proto " ) ;
ExpectNoErrors ( ) ;
ExpectWarningSubstring (
" foo.proto:2:36: warning: Message name should be in UpperCamelCase. " ) ;
CheckGeneratedAnnotations ( " test_generator " , " foo.proto " ) ;
CheckGeneratedAnnotations ( " test_generator " , " foo.proto " ) ;
CheckGeneratedAnnotations ( " test_plugin " , " foo.proto " ) ;
CheckGeneratedAnnotations ( " test_plugin " , " foo.proto " ) ;
}
}
@ -2371,6 +2372,21 @@ TEST_F(CommandLineInterfaceTest, Warnings) {
ExpectErrorSubstring ( " foo.proto:2:1: warning: Import bar.proto is unused. " ) ;
ExpectErrorSubstring ( " foo.proto:2:1: warning: Import bar.proto is unused. " ) ;
}
}
TEST_F ( CommandLineInterfaceTest , ParserWarnings ) {
// Test that parser warnings are propagated. See #9343.
CreateTempFile ( " foo.proto " ,
" syntax = \" proto2 \" ; \n "
" message bad_to_the_bone {}; \n " ) ;
Run ( " protocol_compiler --test_out=$tmpdir "
" --proto_path=$tmpdir foo.proto " ) ;
ExpectCapturedStderrSubstringWithZeroReturnCode (
" foo.proto:2:25: warning: Message name should be in UpperCamelCase. "
" Found: bad_to_the_bone. "
" See https://developers.google.com/protocol-buffers/docs/style " ) ;
}
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// Flag parsing tests
// Flag parsing tests
@ -2691,7 +2707,6 @@ TEST_P(EncodeDecodeTest, Encode) {
EXPECT_TRUE ( Run ( args + " --encode=protobuf_unittest.TestAllTypes " ) ) ;
EXPECT_TRUE ( Run ( args + " --encode=protobuf_unittest.TestAllTypes " ) ) ;
ExpectStdoutMatchesBinaryFile ( TestUtil : : GetTestDataPath (
ExpectStdoutMatchesBinaryFile ( TestUtil : : GetTestDataPath (
" net/proto2/internal/testdata/golden_message_oneof_implemented " ) ) ;
" net/proto2/internal/testdata/golden_message_oneof_implemented " ) ) ;
ExpectStderrMatchesText ( " " ) ;
}
}
TEST_P ( EncodeDecodeTest , Decode ) {
TEST_P ( EncodeDecodeTest , Decode ) {
@ -2703,7 +2718,6 @@ TEST_P(EncodeDecodeTest, Decode) {
ExpectStdoutMatchesTextFile ( TestUtil : : GetTestDataPath (
ExpectStdoutMatchesTextFile ( TestUtil : : GetTestDataPath (
" net/proto2/internal/ "
" net/proto2/internal/ "
" testdata/text_format_unittest_data_oneof_implemented.txt " ) ) ;
" testdata/text_format_unittest_data_oneof_implemented.txt " ) ) ;
ExpectStderrMatchesText ( " " ) ;
}
}
TEST_P ( EncodeDecodeTest , Partial ) {
TEST_P ( EncodeDecodeTest , Partial ) {
@ -2712,7 +2726,7 @@ TEST_P(EncodeDecodeTest, Partial) {
Run ( TestUtil : : MaybeTranslatePath ( " net/proto2/internal/unittest.proto " ) +
Run ( TestUtil : : MaybeTranslatePath ( " net/proto2/internal/unittest.proto " ) +
" --encode=protobuf_unittest.TestRequired " ) ) ;
" --encode=protobuf_unittest.TestRequired " ) ) ;
ExpectStdoutMatchesText ( " " ) ;
ExpectStdoutMatchesText ( " " ) ;
ExpectStderrMatche sText (
ExpectStderrContain sText (
" warning: Input message is missing required fields: a, b, c \n " ) ;
" warning: Input message is missing required fields: a, b, c \n " ) ;
}
}
@ -2736,7 +2750,7 @@ TEST_P(EncodeDecodeTest, UnknownType) {
Run ( TestUtil : : MaybeTranslatePath ( " net/proto2/internal/unittest.proto " ) +
Run ( TestUtil : : MaybeTranslatePath ( " net/proto2/internal/unittest.proto " ) +
" --encode=NoSuchType " ) ) ;
" --encode=NoSuchType " ) ) ;
ExpectStdoutMatchesText ( " " ) ;
ExpectStdoutMatchesText ( " " ) ;
ExpectStderrMatche sText ( " Type not defined: NoSuchType \n " ) ;
ExpectStderrContain sText ( " Type not defined: NoSuchType \n " ) ;
}
}
TEST_P ( EncodeDecodeTest , ProtoParseError ) {
TEST_P ( EncodeDecodeTest , ProtoParseError ) {
@ -2761,7 +2775,6 @@ TEST_P(EncodeDecodeTest, EncodeDeterministicOutput) {
args + " --encode=protobuf_unittest.TestAllTypes --deterministic_output " ) ) ;
args + " --encode=protobuf_unittest.TestAllTypes --deterministic_output " ) ) ;
ExpectStdoutMatchesBinaryFile ( TestUtil : : GetTestDataPath (
ExpectStdoutMatchesBinaryFile ( TestUtil : : GetTestDataPath (
" net/proto2/internal/testdata/golden_message_oneof_implemented " ) ) ;
" net/proto2/internal/testdata/golden_message_oneof_implemented " ) ) ;
ExpectStderrMatchesText ( " " ) ;
}
}
TEST_P ( EncodeDecodeTest , DecodeDeterministicOutput ) {
TEST_P ( EncodeDecodeTest , DecodeDeterministicOutput ) {