From 198f24c6843c1209922a7a7334eea508fdbf9631 Mon Sep 17 00:00:00 2001 From: Lukas Schmidt Date: Fri, 18 Sep 2015 18:09:35 +0200 Subject: [PATCH 01/11] clean code --- SocketIO-iOSTests/AbstractSocketTest.swift | 1 - SocketIOClientSwift/SwiftRegex.swift | 31 +++++++++++----------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/SocketIO-iOSTests/AbstractSocketTest.swift b/SocketIO-iOSTests/AbstractSocketTest.swift index 1fd61c2..18ee1f3 100644 --- a/SocketIO-iOSTests/AbstractSocketTest.swift +++ b/SocketIO-iOSTests/AbstractSocketTest.swift @@ -66,7 +66,6 @@ class AbstractSocketTest: XCTestCase { if let expection = expection { expection.fulfill() } - } AbstractSocketTest.socket.on(finalTestname + "Return", callback: didGetEmit) diff --git a/SocketIOClientSwift/SwiftRegex.swift b/SocketIOClientSwift/SwiftRegex.swift index fcd7652..b088918 100644 --- a/SocketIOClientSwift/SwiftRegex.swift +++ b/SocketIOClientSwift/SwiftRegex.swift @@ -29,8 +29,8 @@ internal class SwiftRegex: NSObject, BooleanType { NSRegularExpressionOptions.DotMatchesLineSeparators) swiftRegexCache[pattern] = regex self.regex = regex - } catch let error1 as NSError { - SwiftRegex.failure("Error in pattern: \(pattern) - \(error1)") + } catch let error as NSError { + SwiftRegex.failure("Error in pattern: \(pattern) - \(error)") self.regex = NSRegularExpression() } } @@ -46,7 +46,7 @@ internal class SwiftRegex: NSObject, BooleanType { } private final func substring(range: NSRange) -> String? { - if ( range.location != NSNotFound ) { + if range.location != NSNotFound { return (target as NSString).substringWithRange(range) } else { return nil @@ -70,20 +70,19 @@ internal class SwiftRegex: NSObject, BooleanType { NSMatchingOptions.WithoutAnchoringBounds, range: targetRange)) } - private func groupsForMatch(match: NSTextCheckingResult!) -> [String]? { - if match != nil { - var groups = [String]() - for groupno in 0...regex.numberOfCaptureGroups { - if let group = substring(match.rangeAtIndex(groupno)) { - groups += [group] - } else { - groups += ["_"] // avoids bridging problems - } - } - return groups - } else { + private func groupsForMatch(match: NSTextCheckingResult?) -> [String]? { + guard let match = match else { return nil } + var groups = [String]() + for groupno in 0...regex.numberOfCaptureGroups { + if let group = substring(match.rangeAtIndex(groupno)) { + groups += [group] + } else { + groups += ["_"] // avoids bridging problems + } + } + return groups } subscript(groupno: Int) -> String? { @@ -124,7 +123,7 @@ internal class SwiftRegex: NSObject, BooleanType { } func allGroups() -> [[String]?] { - return matchResults().map {self.groupsForMatch($0)} + return matchResults().map { self.groupsForMatch($0) } } func dictionary(options: NSMatchingOptions!) -> Dictionary { From 5b6b36a2dc7c139fb8aa75822d920aa490473480 Mon Sep 17 00:00:00 2001 From: Lukas Schmidt Date: Fri, 18 Sep 2015 18:14:12 +0200 Subject: [PATCH 02/11] travis test --- .travis.yml | 3 ++- SocketIO-iOSTests/AbstractSocketTest.swift | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 71a19d2..38419f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,5 @@ language: objective-c xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder xcode_scheme: SocketIO-iOS osx_image: xcode7 -script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO \ No newline at end of file +script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO +before_install: node Socket.IO-Test-Server/main.js \ No newline at end of file diff --git a/SocketIO-iOSTests/AbstractSocketTest.swift b/SocketIO-iOSTests/AbstractSocketTest.swift index 18ee1f3..9cc6084 100644 --- a/SocketIO-iOSTests/AbstractSocketTest.swift +++ b/SocketIO-iOSTests/AbstractSocketTest.swift @@ -9,7 +9,7 @@ import XCTest class AbstractSocketTest: XCTestCase { - static let testLocal = false + static let testLocal = true static let serverURL = AbstractSocketTest.testLocal ? "localhost:6979" : "milkbartube.com:6979" static let TEST_TIMEOUT = 8.0 static var socket:SocketIOClient! From 9a39524ba221962cca1fc1732a12b9e1a7a5d00b Mon Sep 17 00:00:00 2001 From: Lukas Schmidt Date: Fri, 18 Sep 2015 18:19:05 +0200 Subject: [PATCH 03/11] npm install before running test server --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 38419f4..6da9c88 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,8 @@ xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder xcode_scheme: SocketIO-iOS osx_image: xcode7 script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -before_install: node Socket.IO-Test-Server/main.js \ No newline at end of file +before_install: cd Socket.IO-Test-Server/ && npm install +install: node Socket.IO-Test-Server/main.js +cache: + directories: + - Socket.IO-Test-Server/node_modules \ No newline at end of file From 1a48adb03dd25dea1b47697ff52d40f813b240b7 Mon Sep 17 00:00:00 2001 From: Lukas Schmidt Date: Fri, 18 Sep 2015 18:23:49 +0200 Subject: [PATCH 04/11] move out of server dir --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6da9c88..9544eb8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder xcode_scheme: SocketIO-iOS osx_image: xcode7 script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -before_install: cd Socket.IO-Test-Server/ && npm install +before_install: cd Socket.IO-Test-Server/ && npm install && cd .. install: node Socket.IO-Test-Server/main.js cache: directories: From 30c1a4df975ea739d5854db45c7e99d830a6435f Mon Sep 17 00:00:00 2001 From: Lukas Schmidt Date: Sat, 19 Sep 2015 20:28:44 +0200 Subject: [PATCH 05/11] parallel test server --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9544eb8..c6ccdf1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,12 @@ language: objective-c xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder xcode_scheme: SocketIO-iOS osx_image: xcode7 -script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO +before_install: + - brew update + - brew outdated xctool || brew upgrade xctool +script: xctool -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO before_install: cd Socket.IO-Test-Server/ && npm install && cd .. -install: node Socket.IO-Test-Server/main.js +install: node Socket.IO-Test-Server/main.js & cache: directories: - Socket.IO-Test-Server/node_modules \ No newline at end of file From 9c16ffade8420bd67ea61babadeed36ab9de22ee Mon Sep 17 00:00:00 2001 From: Lukas Schmidt Date: Sat, 19 Sep 2015 20:32:25 +0200 Subject: [PATCH 06/11] xctool not working --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c6ccdf1..533127c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ osx_image: xcode7 before_install: - brew update - brew outdated xctool || brew upgrade xctool -script: xctool -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO +script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO before_install: cd Socket.IO-Test-Server/ && npm install && cd .. install: node Socket.IO-Test-Server/main.js & cache: From 14b0022fdc4379cf2cefaa03ab89d16cf71392cc Mon Sep 17 00:00:00 2001 From: Lukas Schmidt Date: Sat, 19 Sep 2015 20:41:58 +0200 Subject: [PATCH 07/11] remove node dependencies --- Socket.IO-Test-Server/main.js | 8 +++++--- Socket.IO-Test-Server/package.json | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Socket.IO-Test-Server/main.js b/Socket.IO-Test-Server/main.js index fb4a05d..4f13276 100644 --- a/Socket.IO-Test-Server/main.js +++ b/Socket.IO-Test-Server/main.js @@ -1,6 +1,8 @@ -var app = require('express')() -var server = app.listen(6979) -var io = require('socket.io')(server) +var app = require('http').createServer() +var io = require('socket.io')(app); +app.listen(6979) + + var acknowledgementsEvents = require("./acknowledgementEvents.js") var emitEvents = require("./emitEvents.js") var socketEventRegister = require("./socketEventRegister.js") diff --git a/Socket.IO-Test-Server/package.json b/Socket.IO-Test-Server/package.json index a62aa0b..eb10dba 100644 --- a/Socket.IO-Test-Server/package.json +++ b/Socket.IO-Test-Server/package.json @@ -9,7 +9,6 @@ "author": "Lukas Schmidt", "license": "MIT", "dependencies": { - "express": "^4.13.1", "socket.io": "^1.3.6" } } From 0d7d319cc31842373ff6b2db3ef7b4862e13b324 Mon Sep 17 00:00:00 2001 From: Lukas Schmidt Date: Sat, 19 Sep 2015 20:42:07 +0200 Subject: [PATCH 08/11] remove remote test server option --- SocketIO-iOSTests/AbstractSocketTest.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SocketIO-iOSTests/AbstractSocketTest.swift b/SocketIO-iOSTests/AbstractSocketTest.swift index 9cc6084..58ae03a 100644 --- a/SocketIO-iOSTests/AbstractSocketTest.swift +++ b/SocketIO-iOSTests/AbstractSocketTest.swift @@ -9,8 +9,7 @@ import XCTest class AbstractSocketTest: XCTestCase { - static let testLocal = true - static let serverURL = AbstractSocketTest.testLocal ? "localhost:6979" : "milkbartube.com:6979" + static let serverURL = "localhost:6979" static let TEST_TIMEOUT = 8.0 static var socket:SocketIOClient! var testKind:TestKind? @@ -30,6 +29,7 @@ class AbstractSocketTest: XCTestCase { } AbstractSocketTest.socket.connect() XCTAssertEqual(AbstractSocketTest.socket.status, SocketIOClientStatus.Connecting) + print(AbstractSocketTest.socket.sid) waitForExpectationsWithTimeout(AbstractSocketTest.TEST_TIMEOUT, handler: nil) } From 7a146bf6ac5bca1cfdf34fb822f33aacf05d0671 Mon Sep 17 00:00:00 2001 From: Lukas Schmidt Date: Sat, 19 Sep 2015 20:50:12 +0200 Subject: [PATCH 09/11] try using xctool --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 533127c..a01af34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,12 @@ language: objective-c xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder xcode_scheme: SocketIO-iOS -osx_image: xcode7 -before_install: - - brew update - - brew outdated xctool || brew upgrade xctool -script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -before_install: cd Socket.IO-Test-Server/ && npm install && cd .. +osx_image: xcode7 +before_install: + - cd Socket.IO-Test-Server/ && npm install && cd .. + - brew update + - brew outdated xctool || brew upgrade xctool +script: xctool -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO install: node Socket.IO-Test-Server/main.js & cache: directories: From 6ab7455a08936d2bb259eb3659fd2077170037bf Mon Sep 17 00:00:00 2001 From: Lukas Schmidt Date: Sat, 19 Sep 2015 20:57:52 +0200 Subject: [PATCH 10/11] valid yaml --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index a01af34..717ea41 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,13 @@ language: objective-c xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder xcode_scheme: SocketIO-iOS -osx_image: xcode7 -before_install: - - cd Socket.IO-Test-Server/ && npm install && cd .. - - brew update - - brew outdated xctool || brew upgrade xctool +osx_image: xcode7 +before_install: + - brew update + - brew outdated xctool || brew upgrade xctool script: xctool -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -install: node Socket.IO-Test-Server/main.js & +before_install: +install: cd Socket.IO-Test-Server/ && npm install && cd .. && node Socket.IO-Test-Server/main.js & cache: directories: - Socket.IO-Test-Server/node_modules \ No newline at end of file From 21ac65733f095dd409fdc6d4fbdffa39b4b8cfbb Mon Sep 17 00:00:00 2001 From: Lukas Schmidt Date: Sat, 19 Sep 2015 21:01:06 +0200 Subject: [PATCH 11/11] back to xcodebuild --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 717ea41..46756e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,7 @@ language: objective-c xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder xcode_scheme: SocketIO-iOS osx_image: xcode7 -before_install: - - brew update - - brew outdated xctool || brew upgrade xctool -script: xctool -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO +script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO before_install: install: cd Socket.IO-Test-Server/ && npm install && cd .. && node Socket.IO-Test-Server/main.js & cache: