Procházet zdrojové kódy

Merge pull request #249 from square/federman/travis_ci

Add Travis CI, and bring SocketRocket up to speed with XCTest
Dan Federman před 10 roky
rodič
revize
d644bdd595

+ 15 - 0
.gitignore

@@ -6,3 +6,18 @@ build/
 nohup.out
 .DS_Store
 xcuserdata/
+*.pbxuser
+!default.pbxuser
+*.mode1v3
+!default.mode1v3
+*.mode2v3
+!default.mode2v3
+*.perspectivev3
+!default.perspectivev3
+*.xcworkspace
+!default.xcworkspace
+*xcuserdata
+profile
+*.moved-aside
+DerivedData
+extern/

+ 5 - 0
.travis.yml

@@ -0,0 +1,5 @@
+language: objective-c
+osx_image: xcode6.4
+script:
+    - xcodebuild -project SocketRocket.xcodeproj -scheme "SocketRocket" -sdk iphonesimulator -configuration Debug -PBXBuildsContinueAfterErrors=0 ACTIVE_ARCH_ONLY=0 build test
+    - xcodebuild -project SocketRocket.xcodeproj -scheme "SocketRocketOSX" -sdk macosx10.10 -configuration Debug -destination "platform=OS X" -PBXBuildsContinueAfterErrors=0 build

+ 15 - 20
SRWebSocketTests/SRTAutobahnTests.m

@@ -14,8 +14,8 @@
 //   limitations under the License.
 //
 
-#import <SenTestingKit/SenTestingKit.h>
-#import <SenTestingKit/SenTestRun.h>
+#import <XCTest/XCTest.h>
+#import <XCTest/XCTestRun.h>
 #import "SRWebSocket.h"
 #import "SRTWebSocketOperation.h"
 #import "SenTestCase+SRTAdditions.h"
@@ -23,7 +23,7 @@
 #define SRLogDebug(format, ...) 
 //#define SRLogDebug(format, ...) NSLog(format, __VA_ARGS__)
 
-@interface SRTAutobahnTests : SenTestCase
+@interface SRTAutobahnTests : XCTestCase
 @end
 
 @interface TestOperation : SRTWebSocketOperation <SRWebSocketDelegate>
@@ -98,7 +98,6 @@
 {
     self = [super initWithInvocation:anInvocation];
     if (self) {
-        [self raiseAfterFailure];
         _testURLString = [[NSProcessInfo processInfo].environment objectForKey:@"SR_TEST_URL"];
         _prefixURL = [NSURL URLWithString:_testURLString];
         _agent = [NSBundle bundleForClass:[self class]].bundleIdentifier;
@@ -106,7 +105,7 @@
     return self;
 }
 
-- (unsigned int)testCaseCount;
+- (NSUInteger)testCaseCount;
 {
     if (self.invocation) {
         return [super testCaseCount];
@@ -120,7 +119,7 @@
         return caseGetter.isFinished;
     } timeout:20.0];
     
-    STAssertNil(caseGetter.error, @"CaseGetter should have successfully returned the number of testCases. Instead got error %@", caseGetter.error);
+    XCTAssertNil(caseGetter.error, @"CaseGetter should have successfully returned the number of testCases. Instead got error %@", caseGetter.error);
     
     NSInteger caseCount = caseGetter.caseCount;
     
@@ -132,7 +131,7 @@
     return NO;
 }
 
-- (void)performTest:(SenTestCaseRun *) aRun
+- (void)performTest:(XCTestCaseRun *) aRun
 {
     if (self.invocation) {
         [super performTest:aRun];
@@ -150,15 +149,11 @@
         
         NSString *description = [self caseDescriptionForCaseNumber:i];
 
-        SenTestCase *testCase = [[[self class] alloc] initWithInvocation:invocation description:description];
+        XCTestCase *testCase = [[[self class] alloc] initWithInvocation:invocation description:description];
         
-        SenTestCaseRun *run = [[SenTestCaseRun alloc] initWithTest:testCase];
+        XCTestCaseRun *run = [[XCTestCaseRun alloc] initWithTest:testCase];
         
         [testCase performTest:run];
-        
-        for (NSException *e in run.exceptions) {
-            [aRun addException:e];
-        }
     }
     [aRun stop];
     
@@ -182,7 +177,7 @@
         return testInfoOperation.isFinished;
     } timeout:60 * 60];
     
-    STAssertNil(testInfoOperation.error, @"Updating the report should not have errored");
+    XCTAssertNil(testInfoOperation.error, @"Updating the report should not have errored");
     
     return [NSString stringWithFormat:@"%@ - %@", [testInfoOperation.info objectForKey:@"id"], [testInfoOperation.info objectForKey:@"description"]];
 }
@@ -220,8 +215,8 @@
         return resultOp.isFinished;
     } timeout:60 * 60];
     
-    STAssertTrue(!testOp.error, @"Test operation should not have failed");
-    STAssertEqualObjects(@"OK", [resultOp.info objectForKey:@"behavior"], @"Test behavior should be OK");
+    XCTAssertTrue(!testOp.error, @"Test operation should not have failed");
+    XCTAssertEqualObjects(@"OK", [resultOp.info objectForKey:@"behavior"], @"Test behavior should be OK");
 }
 
 - (void)updateReports;
@@ -234,7 +229,7 @@
         return updateReportOperation.isFinished;
     } timeout:60 * 60];
     
-    STAssertNil(updateReportOperation.error, @"Updating the report should not have errored");
+    XCTAssertNil(updateReportOperation.error, @"Updating the report should not have errored");
 }
 
 @end
@@ -247,7 +242,7 @@
 {   
     
     NSString *path = [[url URLByAppendingPathComponent:@"runCase"] absoluteString];
-    path = [path stringByAppendingFormat:@"?case=%d&agent=%@", testNumber, agent];
+    path = [path stringByAppendingFormat:@"?case=%@&agent=%@", @(testNumber), agent];
     
     self = [super initWithURL:[NSURL URLWithString:path]];
     if (self) {
@@ -310,7 +305,7 @@
 - (id)initWithBaseURL:(NSURL *)url caseNumber:(NSInteger)caseNumber;
 {
     NSString *path = [[url URLByAppendingPathComponent:@"getCaseInfo"] absoluteString];
-    path = [path stringByAppendingFormat:@"?case=%d", caseNumber];
+    path = [path stringByAppendingFormat:@"?case=%@", @(caseNumber)];
     
     return [super initWithURL:[NSURL URLWithString:path]];
 }
@@ -330,7 +325,7 @@
 - (id)initWithBaseURL:(NSURL *)url caseNumber:(NSInteger)caseNumber agent:(NSString *)agent;
 {
     NSString *path = [[url URLByAppendingPathComponent:@"getCaseStatus"] absoluteString];
-    path = [path stringByAppendingFormat:@"?case=%d&agent=%@", caseNumber, agent];
+    path = [path stringByAppendingFormat:@"?case=%@&agent=%@", @(caseNumber), agent];
     
     return [super initWithURL:[NSURL URLWithString:path]];
 }

+ 1 - 1
SRWebSocketTests/SRWebSocketTests-Prefix.pch

@@ -16,6 +16,6 @@
 
 #ifdef __OBJC__
     #import <Foundation/Foundation.h>
-    #import <SenTestingKit/SenTestingKit.h>
+    #import <XCTest/XCTest.h>
     #import "SenTestCase+SRTAdditions.h"
 #endif

+ 2 - 2
SRWebSocketTests/SenTestCase+SRTAdditions.h

@@ -14,13 +14,13 @@
 //   limitations under the License.
 //
 
-#import <SenTestingKit/SenTestingKit.h>
+#import <XCTest/XCTest.h>
 
 
 typedef BOOL (^PXPredicateBlock)();
 
 
-@interface SenTest (PXAdditions)
+@interface XCTest (PXAdditions)
 
 - (void)runCurrentRunLoopUntilTestPasses:(PXPredicateBlock)predicate timeout:(NSTimeInterval)timeout;
 

+ 2 - 2
SRWebSocketTests/SenTestCase+SRTAdditions.m

@@ -17,7 +17,7 @@
 #import "SenTestCase+SRTAdditions.h"
 
 
-@implementation SenTestCase (SRTAdditions)
+@implementation XCTestCase (SRTAdditions)
 
 - (void)runCurrentRunLoopUntilTestPasses:(PXPredicateBlock)predicate timeout:(NSTimeInterval)timeout;
 {
@@ -32,7 +32,7 @@
         [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
     }
     
-    STAssertTrue(currentTime <= timeoutTime, @"Timed out");
+    XCTAssertTrue(currentTime <= timeoutTime, @"Timed out");
 }
 
 @end

+ 10 - 24
SocketRocket.xcodeproj/project.pbxproj

@@ -36,7 +36,6 @@
 		F6AE4520145906B20022AF3C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6B208301450F597009315AF /* Foundation.framework */; };
 		F6AE45241459071C0022AF3C /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6A12CD51451231B00C1D980 /* CFNetwork.framework */; };
 		F6AE4528145907D30022AF3C /* SenTestCase+SRTAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = F6AE4527145907D30022AF3C /* SenTestCase+SRTAdditions.m */; };
-		F6BDA804145900D200FE3253 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6BDA803145900D200FE3253 /* SenTestingKit.framework */; };
 		F6BDA806145900D200FE3253 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6B208301450F597009315AF /* Foundation.framework */; };
 		F6BDA80C145900D200FE3253 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F6BDA80A145900D200FE3253 /* InfoPlist.strings */; };
 		F6BDA8161459016900FE3253 /* SRTAutobahnTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F6BDA8151459016900FE3253 /* SRTAutobahnTests.m */; };
@@ -88,8 +87,7 @@
 		F6B2082D1450F597009315AF /* libSocketRocket.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSocketRocket.a; sourceTree = BUILT_PRODUCTS_DIR; };
 		F6B208301450F597009315AF /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
 		F6B208341450F597009315AF /* SocketRocket-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketRocket-Prefix.pch"; sourceTree = "<group>"; };
-		F6BDA802145900D200FE3253 /* SRWebSocketTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SRWebSocketTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
-		F6BDA803145900D200FE3253 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; };
+		F6BDA802145900D200FE3253 /* SRWebSocketTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SRWebSocketTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
 		F6BDA809145900D200FE3253 /* SRWebSocketTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SRWebSocketTests-Info.plist"; sourceTree = "<group>"; };
 		F6BDA80B145900D200FE3253 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
 		F6BDA810145900D200FE3253 /* SRWebSocketTests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SRWebSocketTests-Prefix.pch"; sourceTree = "<group>"; };
@@ -137,7 +135,6 @@
 			buildActionMask = 2147483647;
 			files = (
 				F6C41C98145F7C6100641356 /* libicucore.dylib in Frameworks */,
-				F6BDA804145900D200FE3253 /* SenTestingKit.framework in Frameworks */,
 				F6BDA806145900D200FE3253 /* Foundation.framework in Frameworks */,
 				F6AE451D145906A70022AF3C /* libSocketRocket.a in Frameworks */,
 				F6AE45241459071C0022AF3C /* CFNetwork.framework in Frameworks */,
@@ -221,7 +218,7 @@
 			isa = PBXGroup;
 			children = (
 				F6B2082D1450F597009315AF /* libSocketRocket.a */,
-				F6BDA802145900D200FE3253 /* SRWebSocketTests.octest */,
+				F6BDA802145900D200FE3253 /* SRWebSocketTests.xctest */,
 				F62417E314D52F3C003CE997 /* TestChat.app */,
 				F668C880153E91210044DBAC /* SocketRocket.framework */,
 			);
@@ -236,7 +233,6 @@
 				F6A12CD51451231B00C1D980 /* CFNetwork.framework */,
 				F6A12CD3145122FC00C1D980 /* Security.framework */,
 				F6B208301450F597009315AF /* Foundation.framework */,
-				F6BDA803145900D200FE3253 /* SenTestingKit.framework */,
 				F62417E514D52F3C003CE997 /* UIKit.framework */,
 				F62417E814D52F3C003CE997 /* CoreGraphics.framework */,
 				F668C883153E91210044DBAC /* Other Frameworks */,
@@ -375,8 +371,8 @@
 			);
 			name = SRWebSocketTests;
 			productName = SRWebSocketTests;
-			productReference = F6BDA802145900D200FE3253 /* SRWebSocketTests.octest */;
-			productType = "com.apple.product-type.bundle.ocunit-test";
+			productReference = F6BDA802145900D200FE3253 /* SRWebSocketTests.xctest */;
+			productType = "com.apple.product-type.bundle.unit-test";
 		};
 /* End PBXNativeTarget section */
 
@@ -736,23 +732,18 @@
 			buildSettings = {
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(SDKROOT)/Developer/Library/Frameworks",
-					"$(DEVELOPER_LIBRARY_DIR)/Frameworks",
-					"\"$(DEVELOPER_DIR)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks\"",
+					"$(inherited)",
 				);
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = "SRWebSocketTests/SRWebSocketTests-Prefix.pch";
 				INFOPLIST_FILE = "SRWebSocketTests/SRWebSocketTests-Info.plist";
-				LIBRARY_SEARCH_PATHS = (
-					"$(inherited)",
-					"\"$(DEVELOPER_DIR)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/usr/lib/system\"",
-					"\"$(DEVELOPER_DIR)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/usr/lib\"",
-				);
 				OTHER_LDFLAGS = (
 					"-all_load",
 					"-ObjC",
+					"-framework",
+					XCTest,
 				);
 				PRODUCT_NAME = "$(TARGET_NAME)";
-				WRAPPER_EXTENSION = octest;
 			};
 			name = Debug;
 		};
@@ -761,23 +752,18 @@
 			buildSettings = {
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(SDKROOT)/Developer/Library/Frameworks",
-					"$(DEVELOPER_LIBRARY_DIR)/Frameworks",
-					"\"$(DEVELOPER_DIR)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks\"",
+					"$(inherited)",
 				);
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = "SRWebSocketTests/SRWebSocketTests-Prefix.pch";
 				INFOPLIST_FILE = "SRWebSocketTests/SRWebSocketTests-Info.plist";
-				LIBRARY_SEARCH_PATHS = (
-					"$(inherited)",
-					"\"$(DEVELOPER_DIR)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/usr/lib/system\"",
-					"\"$(DEVELOPER_DIR)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/usr/lib\"",
-				);
 				OTHER_LDFLAGS = (
 					"-all_load",
 					"-ObjC",
+					"-framework",
+					XCTest,
 				);
 				PRODUCT_NAME = "$(TARGET_NAME)";
-				WRAPPER_EXTENSION = octest;
 			};
 			name = Release;
 		};