-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conditional Compilation Fixes. #302
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -266,6 +266,7 @@ | |
1D0F8E811B6E31B00049A7D2 /* MocktailFolder */ = {isa = PBXFileReference; lastKnownFileType = folder; path = MocktailFolder; sourceTree = "<group>"; }; | ||
1D6DB84E1B763B7A00FCF855 /* OHHTTPStubs+Mocktail.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "OHHTTPStubs+Mocktail.h"; sourceTree = "<group>"; }; | ||
1D6DB84F1B763B7A00FCF855 /* OHHTTPStubs+Mocktail.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "OHHTTPStubs+Mocktail.m"; sourceTree = "<group>"; }; | ||
1FE7BADB223157DB00FFF120 /* OHHTTPStubsProject.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = OHHTTPStubsProject.xcconfig; sourceTree = "<group>"; }; | ||
221C34A41B0CCF0600FCA8FF /* OHPathHelpersTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OHPathHelpersTests.m; sourceTree = "<group>"; }; | ||
221C34A61B0CCF9D00FCA8FF /* empty.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = empty.bundle; sourceTree = "<group>"; }; | ||
451243C1FC2A423646391951 /* Pods-TestingPods-OHHTTPStubs iOS Fmk Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TestingPods-OHHTTPStubs iOS Fmk Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TestingPods-OHHTTPStubs iOS Fmk Tests/Pods-TestingPods-OHHTTPStubs iOS Fmk Tests.debug.xcconfig"; sourceTree = "<group>"; }; | ||
|
@@ -368,6 +369,7 @@ | |
09110A3819805F4800D175E4 = { | ||
isa = PBXGroup; | ||
children = ( | ||
1FE7BADB223157DB00FFF120 /* OHHTTPStubsProject.xcconfig */, | ||
09110A4619805F4800D175E4 /* OHHTTPStubs */, | ||
095981C519806A7900807DBE /* Supporting Files */, | ||
09110A5A19805F4800D175E4 /* UnitTests */, | ||
|
@@ -1280,6 +1282,7 @@ | |
/* Begin XCBuildConfiguration section */ | ||
09110A6219805F4800D175E4 /* Debug */ = { | ||
isa = XCBuildConfiguration; | ||
baseConfigurationReference = 1FE7BADB223157DB00FFF120 /* OHHTTPStubsProject.xcconfig */; | ||
buildSettings = { | ||
ALWAYS_SEARCH_USER_PATHS = NO; | ||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; | ||
|
@@ -1336,6 +1339,7 @@ | |
}; | ||
09110A6319805F4800D175E4 /* Release */ = { | ||
isa = XCBuildConfiguration; | ||
baseConfigurationReference = 1FE7BADB223157DB00FFF120 /* OHHTTPStubsProject.xcconfig */; | ||
buildSettings = { | ||
ALWAYS_SEARCH_USER_PATHS = NO; | ||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; | ||
|
@@ -1463,10 +1467,6 @@ | |
); | ||
GCC_PRECOMPILE_PREFIX_HEADER = YES; | ||
GCC_PREFIX_HEADER = "UnitTests/UnitTests-Prefix.pch"; | ||
GCC_PREPROCESSOR_DEFINITIONS = ( | ||
"DEBUG=1", | ||
"$(inherited)", | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These were added at the target level, and caused |
||
INFOPLIST_FILE = "UnitTests/UnitTests-Info.plist"; | ||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; | ||
OTHER_LDFLAGS = ( | ||
|
@@ -1519,10 +1519,6 @@ | |
); | ||
FRAMEWORK_VERSION = A; | ||
GCC_ENABLE_OBJC_EXCEPTIONS = YES; | ||
GCC_PREPROCESSOR_DEFINITIONS = ( | ||
"DEBUG=1", | ||
"$(inherited)", | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These were added at the target level, and caused |
||
INFOPLIST_FILE = "Supporting Files/OHHTTPStubs Mac-Info.plist"; | ||
INSTALL_PATH = "@rpath"; | ||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; | ||
|
@@ -1572,10 +1568,6 @@ | |
GCC_ENABLE_OBJC_EXCEPTIONS = YES; | ||
GCC_PRECOMPILE_PREFIX_HEADER = YES; | ||
GCC_PREFIX_HEADER = "UnitTests/UnitTests-Prefix.pch"; | ||
GCC_PREPROCESSOR_DEFINITIONS = ( | ||
"DEBUG=1", | ||
"$(inherited)", | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These were added at the target level, and caused |
||
LD_RUNPATH_SEARCH_PATHS = "$inherited @executable_path/../Frameworks @loader_path/../Frameworks"; | ||
OTHER_LDFLAGS = ( | ||
"$(inherited)", | ||
|
@@ -1623,10 +1615,6 @@ | |
DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)"; | ||
DYLIB_INSTALL_NAME_BASE = "@rpath"; | ||
ENABLE_STRICT_OBJC_MSGSEND = YES; | ||
GCC_PREPROCESSOR_DEFINITIONS = ( | ||
"DEBUG=1", | ||
"$(inherited)", | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These were added at the target level, and caused |
||
INFOPLIST_FILE = "Supporting Files/OHHTTPStubs iOS-Info.plist"; | ||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; | ||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; | ||
|
@@ -1707,10 +1695,6 @@ | |
DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)"; | ||
DYLIB_INSTALL_NAME_BASE = "@rpath"; | ||
ENABLE_STRICT_OBJC_MSGSEND = YES; | ||
GCC_PREPROCESSOR_DEFINITIONS = ( | ||
"DEBUG=1", | ||
"$(inherited)", | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These were added at the target level, and caused |
||
INFOPLIST_FILE = "Supporting Files/OHHTTPStubs iOS-Info.plist"; | ||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; | ||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// OHHTTPStubsProject.xcconfig | ||
// OHHTTPStubs | ||
// | ||
// Created by Jeff Lett on 3/7/19. | ||
// Copyright © 2019 AliSoftware. All rights reserved. | ||
// | ||
|
||
// Configuration settings file format documentation can be found at: | ||
// https://help.apple.com/xcode/#/dev745c5c974 | ||
|
||
// These build settings are used to disable specific unit tests. | ||
// They can and should be overridden when running tests in CI using an xcodebuild argument. | ||
|
||
|
||
// xcodebuild Example: | ||
// xcodebuild -workspace OHHTTPStubs/OHHTTPStubs.xcworkspace -scheme "OHHTTPStubs iOS StaticLib" -sdk iphonesimulator -configuration Debug ONLY_ACTIVE_ARCH=NO OHHTTPSTUBS_SKIP_TIMING_TESTS=1 -destination 'name=iPhone 7,OS=latest' clean build test | ||
// | ||
// rake Example: | ||
// rake ios['iOS StaticLib','latest','build-for-testing test-without-building',"OHHTTPSTUBS_SKIP_TIMING_TESTS=1"] | ||
OHHTTPSTUBS_SKIP_TIMING_TESTS=0 | ||
|
||
// xcodebuild Example: | ||
// xcodebuild -workspace OHHTTPStubs/OHHTTPStubs.xcworkspace -scheme "OHHTTPStubs iOS StaticLib" -sdk iphonesimulator -configuration Debug ONLY_ACTIVE_ARCH=NO OHHTTPSTUBS_SKIP_REDIRECT_TESTS=1 -destination 'name=iPhone 7,OS=latest' clean build test | ||
// | ||
// rake Example: | ||
// rake ios['iOS StaticLib','latest','build-for-testing test-without-building',"OHHTTPSTUBS_SKIP_REDIRECT_TESTS=1"] | ||
OHHTTPSTUBS_SKIP_REDIRECT_TESTS=0 | ||
|
||
GCC_PREPROCESSOR_DEFINITIONS=$(inherited) OHHTTPSTUBS_SKIP_TIMING_TESTS=$(OHHTTPSTUBS_SKIP_TIMING_TESTS) OHHTTPSTUBS_SKIP_REDIRECT_TESTS=$(OHHTTPSTUBS_SKIP_REDIRECT_TESTS) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -294,65 +294,70 @@ - (void)test_NSURLSessionDefaultConfig_notFollowingRedirects | |
Verify that redirects of different methods and status codes are handled properly and | ||
that we retain the HTTP Method for specific HTTP status codes as well as the data payload. | ||
**/ | ||
//- (void)test_NSURLSessionDefaultConfig_MethodAndDataRetentionOnRedirect | ||
//{ | ||
// if ([NSURLSessionConfiguration class] && [NSURLSession class]) | ||
// { | ||
// NSDictionary* json = @{ @"query": @"Hello World" }; | ||
// NSArray<NSString*>* allMethods = @[@"GET", @"HEAD", @"POST", @"PATCH", @"PUT"]; | ||
// | ||
// /** 301, 302, 307, 308: GET, HEAD, POST, PATCH, PUT should all maintain HTTP method and body unchanged **/ | ||
// for (NSNumber* redirectStatusCode in @[@301, @302, @307, @308]) { | ||
// int statusCode = redirectStatusCode.intValue; | ||
// for (NSString* method in allMethods) { | ||
// | ||
// NSURLSessionConfiguration* config = [NSURLSessionConfiguration defaultSessionConfiguration]; | ||
// NSURLSessionTestDelegate* delegate = [NSURLSessionTestDelegate delegateFollowingRedirects:YES fulfillOnCompletion:nil]; | ||
// NSURLSession *session = [NSURLSession sessionWithConfiguration:config delegate:delegate delegateQueue:nil]; | ||
// | ||
// [self _test_redirect_NSURLSession:session httpMethod:method jsonBody:json delays:0.0 redirectStatusCode:statusCode | ||
// completion:^(NSString *redirectedRequestMethod, id redirectedRequestJSONBody, NSHTTPURLResponse *redirectHTTPResponse, id finalJSONResponse, NSError *errorResponse) | ||
// { | ||
// XCTAssertEqualObjects(redirectedRequestMethod, method, | ||
// @"Expected the HTTP method to be unchanged after %d redirect", statusCode); | ||
// XCTAssertEqualObjects(redirectedRequestJSONBody, json, | ||
// @"Expected %d-redirected request to have the same body as the original request", statusCode); | ||
// XCTAssertNil(redirectHTTPResponse, | ||
// @"%d Redirect response should not have been captured by the task completion block", statusCode); | ||
// XCTAssertEqualObjects(finalJSONResponse, @{ @"RequestBody": json }, | ||
// @"Unexpected JSON response received after %d redirect", statusCode); | ||
// XCTAssertNil(errorResponse, @"Unexpected error during %d redirect", statusCode); | ||
// }]; | ||
// | ||
// [session finishTasksAndInvalidate]; | ||
// } | ||
// } | ||
// | ||
// /** 303: GET, HEAD, POST, PATCH, PUT should use a GET HTTP method after redirection and not forward the body **/ | ||
// for (NSString* method in allMethods) { | ||
// | ||
// NSURLSessionConfiguration* config = [NSURLSessionConfiguration defaultSessionConfiguration]; | ||
// NSURLSessionTestDelegate* delegate = [NSURLSessionTestDelegate delegateFollowingRedirects:YES fulfillOnCompletion:nil]; | ||
// NSURLSession *session = [NSURLSession sessionWithConfiguration:config delegate:delegate delegateQueue:nil]; | ||
// | ||
// [self _test_redirect_NSURLSession:session httpMethod:method jsonBody:json delays:0.0 redirectStatusCode:303 | ||
// completion:^(NSString *redirectedRequestMethod, id redirectedRequestJSONBody, NSHTTPURLResponse *redirectHTTPResponse, id finalJSONResponse, NSError *errorResponse) | ||
// { | ||
// XCTAssertEqualObjects(redirectedRequestMethod, @"GET", @"Expected 303 redirected request HTTP method to be reset to GET"); | ||
// XCTAssertNil(redirectedRequestJSONBody, @"Expected 303-redirected request to have empty body"); | ||
// XCTAssertNil(redirectHTTPResponse, @"303 Redirect response should not have been captured by the task completion block"); | ||
// XCTAssertEqualObjects(finalJSONResponse, @{ @"RequestBody": json }, @"Unexpected JSON response received after 303 redirect"); | ||
// XCTAssertNil(errorResponse, @"Unexpected error during 303 redirect"); | ||
// }]; | ||
// | ||
// [session finishTasksAndInvalidate]; | ||
// } | ||
// } | ||
// else | ||
// { | ||
// NSLog(@"/!\\ Test skipped because the NSURLSession class is not available on this OS version. Run the tests a target with a more recent OS.\n"); | ||
// } | ||
//} | ||
#if OHHTTPSTUBS_SKIP_REDIRECT_TESTS | ||
#warning Redirect Tests will be skipped for this run. | ||
#else | ||
- (void)test_NSURLSessionDefaultConfig_MethodAndDataRetentionOnRedirect | ||
{ | ||
if ([NSURLSessionConfiguration class] && [NSURLSession class]) | ||
{ | ||
NSDictionary* json = @{ @"query": @"Hello World" }; | ||
NSArray<NSString*>* allMethods = @[@"GET", @"HEAD", @"POST", @"PATCH", @"PUT"]; | ||
|
||
/** 301, 302, 307, 308: GET, HEAD, POST, PATCH, PUT should all maintain HTTP method and body unchanged **/ | ||
for (NSNumber* redirectStatusCode in @[@301, @302, @307, @308]) { | ||
int statusCode = redirectStatusCode.intValue; | ||
for (NSString* method in allMethods) { | ||
|
||
NSURLSessionConfiguration* config = [NSURLSessionConfiguration defaultSessionConfiguration]; | ||
NSURLSessionTestDelegate* delegate = [NSURLSessionTestDelegate delegateFollowingRedirects:YES fulfillOnCompletion:nil]; | ||
NSURLSession *session = [NSURLSession sessionWithConfiguration:config delegate:delegate delegateQueue:nil]; | ||
|
||
[self _test_redirect_NSURLSession:session httpMethod:method jsonBody:json delays:0.0 redirectStatusCode:statusCode | ||
completion:^(NSString *redirectedRequestMethod, id redirectedRequestJSONBody, NSHTTPURLResponse *redirectHTTPResponse, id finalJSONResponse, NSError *errorResponse) | ||
{ | ||
XCTAssertEqualObjects(redirectedRequestMethod, method, | ||
@"Expected the HTTP method to be unchanged after %d redirect", statusCode); | ||
XCTAssertEqualObjects(redirectedRequestJSONBody, json, | ||
@"Expected %d-redirected request to have the same body as the original request", statusCode); | ||
XCTAssertNil(redirectHTTPResponse, | ||
@"%d Redirect response should not have been captured by the task completion block", statusCode); | ||
XCTAssertEqualObjects(finalJSONResponse, @{ @"RequestBody": json }, | ||
@"Unexpected JSON response received after %d redirect", statusCode); | ||
XCTAssertNil(errorResponse, @"Unexpected error during %d redirect", statusCode); | ||
}]; | ||
|
||
[session finishTasksAndInvalidate]; | ||
} | ||
} | ||
|
||
/** 303: GET, HEAD, POST, PATCH, PUT should use a GET HTTP method after redirection and not forward the body **/ | ||
for (NSString* method in allMethods) { | ||
|
||
NSURLSessionConfiguration* config = [NSURLSessionConfiguration defaultSessionConfiguration]; | ||
NSURLSessionTestDelegate* delegate = [NSURLSessionTestDelegate delegateFollowingRedirects:YES fulfillOnCompletion:nil]; | ||
NSURLSession *session = [NSURLSession sessionWithConfiguration:config delegate:delegate delegateQueue:nil]; | ||
|
||
[self _test_redirect_NSURLSession:session httpMethod:method jsonBody:json delays:0.0 redirectStatusCode:303 | ||
completion:^(NSString *redirectedRequestMethod, id redirectedRequestJSONBody, NSHTTPURLResponse *redirectHTTPResponse, id finalJSONResponse, NSError *errorResponse) | ||
{ | ||
XCTAssertEqualObjects(redirectedRequestMethod, @"GET", @"Expected 303 redirected request HTTP method to be reset to GET"); | ||
XCTAssertNil(redirectedRequestJSONBody, @"Expected 303-redirected request to have empty body"); | ||
XCTAssertNil(redirectHTTPResponse, @"303 Redirect response should not have been captured by the task completion block"); | ||
XCTAssertEqualObjects(finalJSONResponse, @{ @"RequestBody": json }, @"Unexpected JSON response received after 303 redirect"); | ||
XCTAssertNil(errorResponse, @"Unexpected error during 303 redirect"); | ||
}]; | ||
|
||
[session finishTasksAndInvalidate]; | ||
} | ||
} | ||
else | ||
{ | ||
NSLog(@"/!\\ Test skipped because the NSURLSession class is not available on this OS version. Run the tests a target with a more recent OS.\n"); | ||
} | ||
} | ||
#endif | ||
|
||
- (void)test_NSURLSessionEphemeralConfig | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Just because I like nitpicking: this feels a bit packed, so if you have the occasion of a new commit in this PR, adding an extra empty line to separate the endif and the next function while you're at it might help us breathe 😅) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 6bb7397 . |
||
{ | ||
if ([NSURLSessionConfiguration class] && [NSURLSession class]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy surprised that the space character added in there doesn't break anything btw 😅 I guess I properly remembered in the CI config file to use quotes around
"$RAKETASK"
when incoming take, pfew 😄