Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
5eb95efa
Commit
5eb95efa
authored
Jul 26, 2017
by
Thomas Van Lenten
Committed by
GitHub
Jul 26, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3420 from thomasvl/objc_proto2_conformance
Objc proto2 conformance test support
parents
8d5f2c57
3caf9fd0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
23 deletions
+26
-23
Makefile.am
conformance/Makefile.am
+11
-9
conformance_objc.m
conformance/conformance_objc.m
+14
-14
test_messages_proto3.proto
src/google/protobuf/test_messages_proto3.proto
+1
-0
No files found.
conformance/Makefile.am
View file @
5eb95efa
...
...
@@ -2,12 +2,12 @@
conformance_protoc_inputs
=
\
conformance.proto
\
$(top_srcdir)
/src/google/protobuf/test_messages_proto3.proto
# proto2 input files, should be separated with proto3, as we
# can't generate proto2 files for ruby, php and objc
$(top_srcdir)
/src/google/protobuf/test_messages_proto3.proto
# proto2 input files, should be separated with proto3, as we
# can't generate proto2 files for ruby, php and objc
conformance_proto2_protoc_inputs
=
\
$(top_srcdir)
/src/google/protobuf/test_messages_proto2.proto
$(top_srcdir)
/src/google/protobuf/test_messages_proto2.proto
well_known_type_protoc_inputs
=
\
$(top_srcdir)
/src/google/protobuf/any.proto
\
...
...
@@ -86,6 +86,8 @@ other_language_protoc_outputs = \
google/protobuf/struct.pb.h
\
google/protobuf/struct.rb
\
google/protobuf/struct_pb2.py
\
google/protobuf/TestMessagesProto2.pbobjc.h
\
google/protobuf/TestMessagesProto2.pbobjc.m
\
google/protobuf/TestMessagesProto3.pbobjc.h
\
google/protobuf/TestMessagesProto3.pbobjc.m
\
google/protobuf/test_messages_proto3.pb.cc
\
...
...
@@ -228,7 +230,7 @@ if OBJC_CONFORMANCE_TEST
bin_PROGRAMS
+=
conformance-objc
conformance_objc_SOURCES
=
conformance_objc.m ../objectivec/GPBProtocolBuffers.m
nodist_conformance_objc_SOURCES
=
Conformance.pbobjc.m google/protobuf/TestMessagesProto3.pbobjc.m
nodist_conformance_objc_SOURCES
=
Conformance.pbobjc.m google/protobuf/TestMessagesProto
2.pbobjc.m google/protobuf/TestMessagesProto
3.pbobjc.m
# On travis, the build fails without the isysroot because whatever system
# headers are being found don't include generics support for
# NSArray/NSDictionary, the only guess is their image at one time had an odd
...
...
@@ -237,7 +239,7 @@ conformance_objc_CPPFLAGS = -I$(top_srcdir)/objectivec -isysroot `xcrun --sdk ma
conformance_objc_LDFLAGS
=
-framework
Foundation
# Explicit dep beacuse BUILT_SOURCES are only done before a "make all/check"
# so a direct "make test_objc" could fail if parallel enough.
conformance_objc-conformance_objc.$(OBJEXT)
:
Conformance.pbobjc.h google/protobuf/TestMessagesProto3.pbobjc.h
conformance_objc-conformance_objc.$(OBJEXT)
:
Conformance.pbobjc.h google/protobuf/TestMessagesProto
2.pbobjc.h google/protobuf/TestMessagesProto
3.pbobjc.h
endif
...
...
@@ -253,7 +255,7 @@ if USE_EXTERNAL_PROTOC
# Some implementations include pre-generated versions of well-known types.
protoc_middleman
:
$(conformance_protoc_inputs) $(conformance_proto2_protoc_inputs) $(well_known_type_protoc_inputs) google-protobuf
$(PROTOC)
-I
$(srcdir)
-I
$(top_srcdir)
--cpp_out
=
.
--java_out
=
.
--ruby_out
=
.
--objc_out
=
.
--python_out
=
.
--php_out
=
.
--js_out
=
import_style
=
commonjs,binary:.
$(conformance_protoc_inputs)
$(PROTOC)
-I
$(srcdir)
-I
$(top_srcdir)
--cpp_out
=
.
--java_out
=
.
--python_out
=
.
--js_out
=
import_style
=
commonjs,binary:.
$(conformance_proto2_protoc_inputs)
$(PROTOC)
-I
$(srcdir)
-I
$(top_srcdir)
--cpp_out
=
.
--java_out
=
.
--
objc_out
=
.
--
python_out
=
.
--js_out
=
import_style
=
commonjs,binary:.
$(conformance_proto2_protoc_inputs)
$(PROTOC)
-I
$(srcdir)
-I
$(top_srcdir)
--cpp_out
=
.
--java_out
=
.
--ruby_out
=
.
--python_out
=
.
--php_out
=
.
--js_out
=
import_style
=
commonjs,binary:google-protobuf
$(well_known_type_protoc_inputs)
##
$(PROTOC)
-I
$(srcdir)
-I
$(top_srcdir)
--java_out
=
lite:lite
$(conformance_protoc_inputs)
$(well_known_type_protoc_inputs)
touch
protoc_middleman
...
...
@@ -265,7 +267,7 @@ else
# building out-of-tree.
protoc_middleman
:
$(top_srcdir)/src/protoc$(EXEEXT) $(conformance_protoc_inputs) $(conformance_proto2_protoc_inputs) $(well_known_type_protoc_inputs) google-protobuf
oldpwd
=
`
pwd
`
&&
(
cd
$(srcdir)
&&
$$
oldpwd/../src/protoc
$(EXEEXT)
-I
.
-I
$(top_srcdir)
/src
--cpp_out
=
$$
oldpwd
--java_out
=
$$
oldpwd
--ruby_out
=
$$
oldpwd
--objc_out
=
$$
oldpwd
--python_out
=
$$
oldpwd
--php_out
=
$$
oldpwd
--js_out
=
import_style
=
commonjs,binary:
$$
oldpwd
$(conformance_protoc_inputs)
)
oldpwd
=
`
pwd
`
&&
(
cd
$(srcdir)
&&
$$
oldpwd/../src/protoc
$(EXEEXT)
-I
.
-I
$(top_srcdir)
/src
--cpp_out
=
$$
oldpwd
--java_out
=
$$
oldpwd
--python_out
=
$$
oldpwd
--js_out
=
import_style
=
commonjs,binary:
$$
oldpwd
$(conformance_proto2_protoc_inputs)
)
oldpwd
=
`
pwd
`
&&
(
cd
$(srcdir)
&&
$$
oldpwd/../src/protoc
$(EXEEXT)
-I
.
-I
$(top_srcdir)
/src
--cpp_out
=
$$
oldpwd
--java_out
=
$$
oldpwd
--
objc_out
=
.
--
python_out
=
$$
oldpwd
--js_out
=
import_style
=
commonjs,binary:
$$
oldpwd
$(conformance_proto2_protoc_inputs)
)
oldpwd
=
`
pwd
`
&&
(
cd
$(srcdir)
&&
$$
oldpwd/../src/protoc
$(EXEEXT)
-I
.
-I
$(top_srcdir)
/src
--cpp_out
=
$$
oldpwd
--java_out
=
$$
oldpwd
--ruby_out
=
$$
oldpwd
--python_out
=
$$
oldpwd
--php_out
=
$$
oldpwd
--js_out
=
import_style
=
commonjs,binary:
$$
oldpwd/google-protobuf
$(well_known_type_protoc_inputs)
)
## @mkdir -p lite
## oldpwd=`pwd` &&
(
cd
$(srcdir)
&&
$$
oldpwd/../src/protoc
$(EXEEXT)
-I
.
-I
$(top_srcdir)
/src
--java_out
=
lite:
$$
oldpwd/lite
$(conformance_protoc_inputs)
$(well_known_type_protoc_inputs)
)
...
...
conformance/conformance_objc.m
View file @
5eb95efa
...
...
@@ -31,6 +31,7 @@
#import <Foundation/Foundation.h>
#import "Conformance.pbobjc.h"
#import "google/protobuf/TestMessagesProto2.pbobjc.h"
#import "google/protobuf/TestMessagesProto3.pbobjc.h"
static
void
Die
(
NSString
*
format
,
...)
__dead2
;
...
...
@@ -63,7 +64,7 @@ static NSData *CheckedReadDataOfLength(NSFileHandle *handle, NSUInteger numBytes
static
ConformanceResponse
*
DoTest
(
ConformanceRequest
*
request
)
{
ConformanceResponse
*
response
=
[
ConformanceResponse
message
];
TestAllTypesProto3
*
testMessage
=
nil
;
GPBMessage
*
testMessage
=
nil
;
switch
(
request
.
payloadOneOfCase
)
{
case
ConformanceRequest_Payload_OneOfCase_GPBUnsetOneOfCase
:
...
...
@@ -71,20 +72,19 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) {
break
;
case
ConformanceRequest_Payload_OneOfCase_ProtobufPayload
:
{
if
([
request
.
messageType
isEqualToString
:
@"protobuf_test_messages.proto3.TestAllTypesProto3"
])
{
NSError
*
error
=
nil
;
testMessage
=
[
TestAllTypesProto3
parseFromData
:
request
.
protobufPayload
error
:
&
error
];
if
(
!
testMessage
)
{
response
.
parseError
=
[
NSString
stringWithFormat
:
@"Parse error: %@"
,
error
];
}
}
else
if
([
request
.
messageType
isEqualToString
:
@"protobuf_test_messages.proto2.TestAllTypesProto2"
])
{
response
.
skipped
=
@"ObjC doesn't support proto2"
;
break
;
Class
msgClass
=
nil
;
if
([
request
.
messageType
isEqual
:
@"protobuf_test_messages.proto3.TestAllTypesProto3"
])
{
msgClass
=
[
Proto3TestAllTypesProto3
class
];
}
else
if
([
request
.
messageType
isEqual
:
@"protobuf_test_messages.proto2.TestAllTypesProto2"
])
{
msgClass
=
[
TestAllTypesProto2
class
];
}
else
{
Die
(
@"Protobuf request doesn't have specific payload type"
);
break
;
Die
(
@"Protobuf request had an unknown message_type: %@"
,
request
.
messageType
);
}
NSError
*
error
=
nil
;
testMessage
=
[
msgClass
parseFromData
:
request
.
protobufPayload
error
:
&
error
];
if
(
!
testMessage
)
{
response
.
parseError
=
[
NSString
stringWithFormat
:
@"Parse error: %@"
,
error
];
}
break
;
}
...
...
src/google/protobuf/test_messages_proto3.proto
View file @
5eb95efa
...
...
@@ -39,6 +39,7 @@ syntax = "proto3";
package
protobuf_test_messages
.
proto3
;
option
java_package
=
"com.google.protobuf_test_messages.proto3"
;
option
objc_class_prefix
=
"Proto3"
;
// This is the default, but we specify it here explicitly.
option
optimize_for
=
SPEED
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment