Merge pull request #6922 from y-zeng/ios-test

Enable treating warnings as errors in objc tests
pull/6888/head^2
Jan Tattermusch 9 years ago committed by GitHub
commit b309bc94bf
  1. 4
      src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h
  2. 3
      src/objective-c/ProtoRPC/ProtoMethod.h
  3. 3
      src/objective-c/ProtoRPC/ProtoRPC.h
  4. 3
      src/objective-c/ProtoRPC/ProtoService.h
  5. 2
      src/objective-c/ProtoRPC/ProtoService.m
  6. 16
      src/objective-c/tests/GRPCClientTests.m
  7. 10
      src/objective-c/tests/InteropTests.m
  8. 20
      src/objective-c/tests/Podfile
  9. 4
      src/objective-c/tests/Tests.xcodeproj/project.pbxproj

@ -41,7 +41,7 @@
*/ */
+ (BOOL)setTLSPEMRootCerts:(nullable NSString *)pemRootCert + (BOOL)setTLSPEMRootCerts:(nullable NSString *)pemRootCert
forHost:(nonnull NSString *)host forHost:(nonnull NSString *)host
error:(NSError **)errorPtr; error:(NSError * _Nullable * _Nullable)errorPtr;
/** /**
* Configures @c host with TLS/SSL Client Credentials and optionally trusted root Certificate * Configures @c host with TLS/SSL Client Credentials and optionally trusted root Certificate
* Authorities. If @c pemRootCerts is nil, the default CA Certificates bundled with gRPC will be * Authorities. If @c pemRootCerts is nil, the default CA Certificates bundled with gRPC will be
@ -51,6 +51,6 @@
withPrivateKey:(nullable NSString *)pemPrivateKey withPrivateKey:(nullable NSString *)pemPrivateKey
withCertChain:(nullable NSString *)pemCertChain withCertChain:(nullable NSString *)pemCertChain
forHost:(nonnull NSString *)host forHost:(nonnull NSString *)host
error:(NSError **)errorPtr; error:(NSError * _Nullable * _Nullable)errorPtr;
@end @end

@ -54,6 +54,9 @@ __attribute__((deprecated("Please use GRPCProtoMethod.")))
* This subclass is empty now. Eventually we'll remove ProtoMethod class * This subclass is empty now. Eventually we'll remove ProtoMethod class
* to avoid potential naming conflict * to avoid potential naming conflict
*/ */
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@interface GRPCProtoMethod : ProtoMethod @interface GRPCProtoMethod : ProtoMethod
#pragma clang diagnostic pop
@end @end

@ -56,6 +56,9 @@ __attribute__((deprecated("Please use GRPCProtoCall.")))
* This subclass is empty now. Eventually we'll remove ProtoRPC class * This subclass is empty now. Eventually we'll remove ProtoRPC class
* to avoid potential naming conflict * to avoid potential naming conflict
*/ */
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@interface GRPCProtoCall : ProtoRPC @interface GRPCProtoCall : ProtoRPC
#pragma clang diagnostic pop
@end @end

@ -55,6 +55,9 @@ __attribute__((deprecated("Please use GRPCProtoService.")))
* This subclass is empty now. Eventually we'll remove ProtoService class * This subclass is empty now. Eventually we'll remove ProtoService class
* to avoid potential naming conflict * to avoid potential naming conflict
*/ */
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@interface GRPCProtoService : ProtoService @interface GRPCProtoService : ProtoService
#pragma clang diagnostic pop
@end @end

@ -69,7 +69,7 @@
requestsWriter:(GRXWriter *)requestsWriter requestsWriter:(GRXWriter *)requestsWriter
responseClass:(Class)responseClass responseClass:(Class)responseClass
responsesWriteable:(id<GRXWriteable>)responsesWriteable { responsesWriteable:(id<GRXWriteable>)responsesWriteable {
ProtoMethod *methodName = [[ProtoMethod alloc] initWithPackage:_packageName GRPCProtoMethod *methodName = [[GRPCProtoMethod alloc] initWithPackage:_packageName
service:_serviceName service:_serviceName
method:method]; method:method];
return [[ProtoRPC alloc] initWithHost:_host return [[ProtoRPC alloc] initWithHost:_host

@ -48,9 +48,9 @@ static NSString * const kPackage = @"grpc.testing";
static NSString * const kService = @"TestService"; static NSString * const kService = @"TestService";
static NSString * const kRemoteSSLHost = @"grpc-test.sandbox.googleapis.com"; static NSString * const kRemoteSSLHost = @"grpc-test.sandbox.googleapis.com";
static ProtoMethod *kInexistentMethod; static GRPCProtoMethod *kInexistentMethod;
static ProtoMethod *kEmptyCallMethod; static GRPCProtoMethod *kEmptyCallMethod;
static ProtoMethod *kUnaryCallMethod; static GRPCProtoMethod *kUnaryCallMethod;
/** Observer class for testing that responseMetadata is KVO-compliant */ /** Observer class for testing that responseMetadata is KVO-compliant */
@interface PassthroughObserver : NSObject @interface PassthroughObserver : NSObject
@ -109,13 +109,13 @@ static ProtoMethod *kUnaryCallMethod;
[GRPCCall useInsecureConnectionsForHost:kHostAddress]; [GRPCCall useInsecureConnectionsForHost:kHostAddress];
// This method isn't implemented by the remote server. // This method isn't implemented by the remote server.
kInexistentMethod = [[ProtoMethod alloc] initWithPackage:kPackage kInexistentMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage
service:kService service:kService
method:@"Inexistent"]; method:@"Inexistent"];
kEmptyCallMethod = [[ProtoMethod alloc] initWithPackage:kPackage kEmptyCallMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage
service:kService service:kService
method:@"EmptyCall"]; method:@"EmptyCall"];
kUnaryCallMethod = [[ProtoMethod alloc] initWithPackage:kPackage kUnaryCallMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage
service:kService service:kService
method:@"UnaryCall"]; method:@"UnaryCall"];
} }
@ -303,7 +303,7 @@ static ProtoMethod *kUnaryCallMethod;
// Try to set parameters to nil for GRPCCall. This should cause an exception // Try to set parameters to nil for GRPCCall. This should cause an exception
@try { @try {
GRPCCall *call = [[GRPCCall alloc] initWithHost:nil (void)[[GRPCCall alloc] initWithHost:nil
path:nil path:nil
requestsWriter:nil]; requestsWriter:nil];
XCTFail(@"Did not receive an exception when parameters are nil"); XCTFail(@"Did not receive an exception when parameters are nil");
@ -316,7 +316,7 @@ static ProtoMethod *kUnaryCallMethod;
GRXWriter *requestsWriter = [GRXWriter emptyWriter]; GRXWriter *requestsWriter = [GRXWriter emptyWriter];
[requestsWriter finishWithError:nil]; [requestsWriter finishWithError:nil];
@try { @try {
GRPCCall *call = [[GRPCCall alloc] initWithHost:kHostAddress (void)[[GRPCCall alloc] initWithHost:kHostAddress
path:kUnaryCallMethod.HTTPPath path:kUnaryCallMethod.HTTPPath
requestsWriter:requestsWriter]; requestsWriter:requestsWriter];
XCTFail(@"Did not receive an exception when GRXWriter has incorrect state."); XCTFail(@"Did not receive an exception when GRXWriter has incorrect state.");

@ -58,7 +58,7 @@
requestedResponseSize:(NSNumber *)responseSize { requestedResponseSize:(NSNumber *)responseSize {
RMTStreamingOutputCallRequest *request = [self message]; RMTStreamingOutputCallRequest *request = [self message];
RMTResponseParameters *parameters = [RMTResponseParameters message]; RMTResponseParameters *parameters = [RMTResponseParameters message];
parameters.size = responseSize.integerValue; parameters.size = (int)responseSize.integerValue;
[request.responseParametersArray addObject:parameters]; [request.responseParametersArray addObject:parameters];
request.payload.body = [NSMutableData dataWithLength:payloadSize.unsignedIntegerValue]; request.payload.body = [NSMutableData dataWithLength:payloadSize.unsignedIntegerValue];
return request; return request;
@ -80,7 +80,9 @@
#pragma mark Tests #pragma mark Tests
#ifdef GRPC_COMPILE_WITH_CRONET
static cronet_engine *cronetEngine = NULL; static cronet_engine *cronetEngine = NULL;
#endif
@implementation InteropTests { @implementation InteropTests {
RMTTestService *_service; RMTTestService *_service;
@ -186,7 +188,7 @@ static cronet_engine *cronetEngine = NULL;
RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message];
for (NSNumber *size in expectedSizes) { for (NSNumber *size in expectedSizes) {
RMTResponseParameters *parameters = [RMTResponseParameters message]; RMTResponseParameters *parameters = [RMTResponseParameters message];
parameters.size = [size integerValue]; parameters.size = (int)[size integerValue];
[request.responseParametersArray addObject:parameters]; [request.responseParametersArray addObject:parameters];
} }
@ -282,7 +284,7 @@ static cronet_engine *cronetEngine = NULL;
// A buffered pipe to which we never write any value acts as a writer that just hangs. // A buffered pipe to which we never write any value acts as a writer that just hangs.
GRXBufferedPipe *requestsBuffer = [[GRXBufferedPipe alloc] init]; GRXBufferedPipe *requestsBuffer = [[GRXBufferedPipe alloc] init];
ProtoRPC *call = [_service RPCToStreamingInputCallWithRequestsWriter:requestsBuffer GRPCProtoCall *call = [_service RPCToStreamingInputCallWithRequestsWriter:requestsBuffer
handler:^(RMTStreamingInputCallResponse *response, handler:^(RMTStreamingInputCallResponse *response,
NSError *error) { NSError *error) {
XCTAssertEqual(error.code, GRPC_STATUS_CANCELLED); XCTAssertEqual(error.code, GRPC_STATUS_CANCELLED);
@ -313,7 +315,7 @@ static cronet_engine *cronetEngine = NULL;
[requestsBuffer writeValue:request]; [requestsBuffer writeValue:request];
__block ProtoRPC *call = __block GRPCProtoCall *call =
[_service RPCToFullDuplexCallWithRequestsWriter:requestsBuffer [_service RPCToFullDuplexCallWithRequestsWriter:requestsBuffer
eventHandler:^(BOOL done, eventHandler:^(BOOL done,
RMTStreamingOutputCallResponse *response, RMTStreamingOutputCallResponse *response,

@ -4,8 +4,8 @@ platform :ios, '8.0'
install! 'cocoapods', :deterministic_uuids => false install! 'cocoapods', :deterministic_uuids => false
def shared_pods def shared_pods
pod 'Protobuf', :path => "../../../third_party/protobuf" pod 'Protobuf', :path => "../../../third_party/protobuf", :inhibit_warnings => true
pod 'BoringSSL', :podspec => ".." pod 'BoringSSL', :podspec => "..", :inhibit_warnings => true
pod 'CronetFramework', :podspec => ".." pod 'CronetFramework', :podspec => ".."
pod 'gRPC', :path => "../../.." pod 'gRPC', :path => "../../.."
pod 'RemoteTest', :path => "RemoteTestClient" pod 'RemoteTest', :path => "RemoteTestClient"
@ -34,3 +34,19 @@ end
target 'InteropTestsLocalCleartext' do target 'InteropTestsLocalCleartext' do
shared_pods shared_pods
end end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'YES'
end
if target.name == 'gRPC'
target.build_configurations.each do |config|
# TODO(zyc) Remove this setting after the issue is resolved
# GPR_UNREACHABLE_CODE causes "Control may reach end of non-void
# function" warning
config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO'
end
end
end
end

@ -893,6 +893,7 @@
"$(inherited)", "$(inherited)",
); );
GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNDECLARED_SELECTOR = YES;
@ -929,6 +930,7 @@
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES; GCC_NO_COMMON_BLOCKS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNDECLARED_SELECTOR = YES;
@ -946,6 +948,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 060EF32D7EC0DF67ED617507 /* Pods-Tests.debug.xcconfig */; baseConfigurationReference = 060EF32D7EC0DF67ED617507 /* Pods-Tests.debug.xcconfig */;
buildSettings = { buildSettings = {
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
}; };
@ -955,6 +958,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = E6733B838B28453434B556E2 /* Pods-Tests.release.xcconfig */; baseConfigurationReference = E6733B838B28453434B556E2 /* Pods-Tests.release.xcconfig */;
buildSettings = { buildSettings = {
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
}; };

Loading…
Cancel
Save