Commit 2ad74e16 authored by Yilun Chong's avatar Yilun Chong

add support for proto2

parent 4e67590e
...@@ -77,6 +77,8 @@ message ConformanceRequest { ...@@ -77,6 +77,8 @@ message ConformanceRequest {
// Which format should the testee serialize its message to? // Which format should the testee serialize its message to?
WireFormat requested_output_format = 3; WireFormat requested_output_format = 3;
string message_type = 4;
} }
// Represents a single test case's output. // Represents a single test case's output.
......
...@@ -43,6 +43,7 @@ def do_test(request) ...@@ -43,6 +43,7 @@ def do_test(request)
begin begin
case request.payload case request.payload
when :protobuf_payload when :protobuf_payload
if request.message_type.eql?('proto3')
begin begin
test_message = ProtobufTestMessages::Proto3::TestAllTypes.decode( test_message = ProtobufTestMessages::Proto3::TestAllTypes.decode(
request.protobuf_payload) request.protobuf_payload)
...@@ -50,6 +51,12 @@ def do_test(request) ...@@ -50,6 +51,12 @@ def do_test(request)
response.parse_error = err.message.encode('utf-8') response.parse_error = err.message.encode('utf-8')
return response return response
end end
elsif request.message_type.eql?('proto2')
response.skipped = "Ruby doesn't support proto2"
return respons
else
fail "Protobuf request doesn't have specific type"
end
when :json_payload when :json_payload
begin begin
......
This diff is collapsed.
...@@ -165,7 +165,8 @@ class ConformanceTestSuite { ...@@ -165,7 +165,8 @@ class ConformanceTestSuite {
const string& input, const string& input,
conformance::WireFormat input_format, conformance::WireFormat input_format,
const string& equivalent_text_format, const string& equivalent_text_format,
conformance::WireFormat requested_output); conformance::WireFormat requested_output,
bool isProto3);
void RunValidJsonTest(const string& test_name, void RunValidJsonTest(const string& test_name,
ConformanceLevel level, ConformanceLevel level,
const string& input_json, const string& input_json,
...@@ -174,14 +175,17 @@ class ConformanceTestSuite { ...@@ -174,14 +175,17 @@ class ConformanceTestSuite {
const string& test_name, const string& test_name,
ConformanceLevel level, ConformanceLevel level,
const protobuf_test_messages::proto3::TestAllTypes& input, const protobuf_test_messages::proto3::TestAllTypes& input,
const string& equivalent_text_format); const string& equivalent_text_format,
bool isProto3);
void RunValidProtobufTest(const string& test_name, ConformanceLevel level, void RunValidProtobufTest(const string& test_name, ConformanceLevel level,
const string& input_protobuf, const string& input_protobuf,
const string& equivalent_text_format); const string& equivalent_text_format,
bool isProto3);
void RunValidProtobufTestWithMessage( void RunValidProtobufTestWithMessage(
const string& test_name, ConformanceLevel level, const string& test_name, ConformanceLevel level,
const protobuf_test_messages::proto3::TestAllTypes& input, const protobuf_test_messages::proto3::TestAllTypes& input,
const string& equivalent_text_format); const string& equivalent_text_format,
bool isProto3);
typedef std::function<bool(const Json::Value&)> Validator; typedef std::function<bool(const Json::Value&)> Validator;
void RunValidJsonTestWithValidator(const string& test_name, void RunValidJsonTestWithValidator(const string& test_name,
...@@ -196,15 +200,18 @@ class ConformanceTestSuite { ...@@ -196,15 +200,18 @@ class ConformanceTestSuite {
const string& text_format); const string& text_format);
void ExpectParseFailureForProto(const std::string& proto, void ExpectParseFailureForProto(const std::string& proto,
const std::string& test_name, const std::string& test_name,
ConformanceLevel level); ConformanceLevel level,
bool isProto3);
void ExpectHardParseFailureForProto(const std::string& proto, void ExpectHardParseFailureForProto(const std::string& proto,
const std::string& test_name, const std::string& test_name,
ConformanceLevel level); ConformanceLevel level,
bool isProto3);
void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type); void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type);
void TestIllegalTags(); void TestIllegalTags();
void TestValidDataForType( void TestValidDataForType(
google::protobuf::FieldDescriptor::Type, google::protobuf::FieldDescriptor::Type,
std::vector<std::pair<std::string, std::string>> values); std::vector<std::pair<std::string, std::string>> values,
bool isProto3);
bool CheckSetEmpty(const set<string>& set_to_check, bool CheckSetEmpty(const set<string>& set_to_check,
const std::string& write_to_file, const std::string& msg); const std::string& write_to_file, const std::string& msg);
ConformanceTestRunner* runner_; ConformanceTestRunner* runner_;
......
...@@ -50,10 +50,10 @@ option cc_enable_arenas = true; ...@@ -50,10 +50,10 @@ option cc_enable_arenas = true;
// submessages of this message. So for example, a fuzz test of TestAllTypes // submessages of this message. So for example, a fuzz test of TestAllTypes
// could trigger bugs that occur in any message type in this file. We verify // could trigger bugs that occur in any message type in this file. We verify
// this stays true in a unit test. // this stays true in a unit test.
message TestAllTypes { message TestAllTypesProto2 {
message NestedMessage { message NestedMessage {
optional int32 a = 1; optional int32 a = 1;
optional TestAllTypes corecursive = 2; optional TestAllTypesProto2 corecursive = 2;
} }
enum NestedEnum { enum NestedEnum {
...@@ -89,7 +89,7 @@ message TestAllTypes { ...@@ -89,7 +89,7 @@ message TestAllTypes {
optional string optional_string_piece = 24 [ctype=STRING_PIECE]; optional string optional_string_piece = 24 [ctype=STRING_PIECE];
optional string optional_cord = 25 [ctype=CORD]; optional string optional_cord = 25 [ctype=CORD];
optional TestAllTypes recursive_message = 27; optional TestAllTypesProto2 recursive_message = 27;
// Repeated // Repeated
repeated int32 repeated_int32 = 31; repeated int32 repeated_int32 = 31;
...@@ -191,6 +191,6 @@ enum ForeignEnum { ...@@ -191,6 +191,6 @@ enum ForeignEnum {
FOREIGN_BAZ = 2; FOREIGN_BAZ = 2;
} }
extend TestAllTypes { extend TestAllTypesProto2 {
optional int32 extension_int32 = 120; optional int32 extension_int32 = 120;
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment