Skip to content

Commit e2cd910

Browse files
committed
Merge pull request #186 from lightsprint09/travis-test-imporvements
Travis test imporvements
2 parents 492ae89 + 21ac657 commit e2cd910

File tree

5 files changed

+28
-24
lines changed

5 files changed

+28
-24
lines changed

.travis.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@ language: objective-c
22
xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder
33
xcode_scheme: SocketIO-iOS
44
osx_image: xcode7
5-
script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
5+
script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
6+
before_install:
7+
install: cd Socket.IO-Test-Server/ && npm install && cd .. && node Socket.IO-Test-Server/main.js &
8+
cache:
9+
directories:
10+
- Socket.IO-Test-Server/node_modules

Socket.IO-Test-Server/main.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
var app = require('express')()
2-
var server = app.listen(6979)
3-
var io = require('socket.io')(server)
1+
var app = require('http').createServer()
2+
var io = require('socket.io')(app);
3+
app.listen(6979)
4+
5+
46
var acknowledgementsEvents = require("./acknowledgementEvents.js")
57
var emitEvents = require("./emitEvents.js")
68
var socketEventRegister = require("./socketEventRegister.js")

Socket.IO-Test-Server/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"author": "Lukas Schmidt",
1010
"license": "MIT",
1111
"dependencies": {
12-
"express": "^4.13.1",
1312
"socket.io": "^1.3.6"
1413
}
1514
}

SocketIO-iOSTests/AbstractSocketTest.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
import XCTest
1010

1111
class AbstractSocketTest: XCTestCase {
12-
static let testLocal = false
13-
static let serverURL = AbstractSocketTest.testLocal ? "localhost:6979" : "milkbartube.com:6979"
12+
static let serverURL = "localhost:6979"
1413
static let TEST_TIMEOUT = 8.0
1514
static var socket:SocketIOClient!
1615
var testKind:TestKind?
@@ -30,6 +29,7 @@ class AbstractSocketTest: XCTestCase {
3029
}
3130
AbstractSocketTest.socket.connect()
3231
XCTAssertEqual(AbstractSocketTest.socket.status, SocketIOClientStatus.Connecting)
32+
print(AbstractSocketTest.socket.sid)
3333
waitForExpectationsWithTimeout(AbstractSocketTest.TEST_TIMEOUT, handler: nil)
3434
}
3535

@@ -66,7 +66,6 @@ class AbstractSocketTest: XCTestCase {
6666
if let expection = expection {
6767
expection.fulfill()
6868
}
69-
7069
}
7170

7271
AbstractSocketTest.socket.on(finalTestname + "Return", callback: didGetEmit)

SocketIOClientSwift/SwiftRegex.swift

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ internal class SwiftRegex: NSObject, BooleanType {
2929
NSRegularExpressionOptions.DotMatchesLineSeparators)
3030
swiftRegexCache[pattern] = regex
3131
self.regex = regex
32-
} catch let error1 as NSError {
33-
SwiftRegex.failure("Error in pattern: \(pattern) - \(error1)")
32+
} catch let error as NSError {
33+
SwiftRegex.failure("Error in pattern: \(pattern) - \(error)")
3434
self.regex = NSRegularExpression()
3535
}
3636
}
@@ -46,7 +46,7 @@ internal class SwiftRegex: NSObject, BooleanType {
4646
}
4747

4848
private final func substring(range: NSRange) -> String? {
49-
if ( range.location != NSNotFound ) {
49+
if range.location != NSNotFound {
5050
return (target as NSString).substringWithRange(range)
5151
} else {
5252
return nil
@@ -70,20 +70,19 @@ internal class SwiftRegex: NSObject, BooleanType {
7070
NSMatchingOptions.WithoutAnchoringBounds, range: targetRange))
7171
}
7272

73-
private func groupsForMatch(match: NSTextCheckingResult!) -> [String]? {
74-
if match != nil {
75-
var groups = [String]()
76-
for groupno in 0...regex.numberOfCaptureGroups {
77-
if let group = substring(match.rangeAtIndex(groupno)) {
78-
groups += [group]
79-
} else {
80-
groups += ["_"] // avoids bridging problems
81-
}
82-
}
83-
return groups
84-
} else {
73+
private func groupsForMatch(match: NSTextCheckingResult?) -> [String]? {
74+
guard let match = match else {
8575
return nil
8676
}
77+
var groups = [String]()
78+
for groupno in 0...regex.numberOfCaptureGroups {
79+
if let group = substring(match.rangeAtIndex(groupno)) {
80+
groups += [group]
81+
} else {
82+
groups += ["_"] // avoids bridging problems
83+
}
84+
}
85+
return groups
8786
}
8887

8988
subscript(groupno: Int) -> String? {
@@ -124,7 +123,7 @@ internal class SwiftRegex: NSObject, BooleanType {
124123
}
125124

126125
func allGroups() -> [[String]?] {
127-
return matchResults().map {self.groupsForMatch($0)}
126+
return matchResults().map { self.groupsForMatch($0) }
128127
}
129128

130129
func dictionary(options: NSMatchingOptions!) -> Dictionary<String,String> {

0 commit comments

Comments
 (0)