Skip to content

Commit 1cc763c

Browse files
authored
Merge pull request #619 from Quick/test-swift-5.0
Fix Swift 4.2 compatibility on Linux
2 parents c68f5fd + 3724944 commit 1cc763c

File tree

6 files changed

+29
-10
lines changed

6 files changed

+29
-10
lines changed

.travis.yml

+18-2
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,37 @@ matrix:
1616
osx_image: xcode9.4
1717
- os: osx
1818
env: TYPE=macos
19-
osx_image: xcode10
19+
osx_image: xcode10.1
2020
- os: osx
2121
env:
2222
- TYPE=swiftpm
2323
- os: osx
2424
env:
2525
- TYPE=swiftpm
26-
osx_image: xcode10
26+
osx_image: xcode10.1
2727
- os: linux
2828
dist: trusty
2929
sudo: required
3030
env:
3131
- TYPE=swiftpm
3232
install:
3333
- eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)"
34+
- os: linux
35+
dist: trusty
36+
sudo: required
37+
env:
38+
- TYPE=swiftpm
39+
- SWIFT_VERSION=4.2.1
40+
install:
41+
- eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)"
42+
# - os: linux
43+
# dist: trusty
44+
# sudo: required
45+
# env:
46+
# - TYPE=swiftpm
47+
# - SWIFT_VERSION=5.0-DEVELOPMENT-SNAPSHOT-2019-01-13-a
48+
# install:
49+
# - eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)"
3450
install:
3551
- if [[ "$TYPE" == "podspec" ]]; then sudo gem install bundler; bundle install; fi
3652
script:

Sources/Nimble/Adapters/NimbleEnvironment.swift

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Foundation
33

44
/// "Global" state of Nimble is stored here. Only DSL functions should access / be aware of this
55
/// class' existence
6-
internal class NimbleEnvironment {
6+
internal class NimbleEnvironment: NSObject {
77
static var activeInstance: NimbleEnvironment {
88
get {
99
let env = Thread.current.threadDictionary["NimbleEnvironment"]
@@ -30,11 +30,14 @@ internal class NimbleEnvironment {
3030
var suppressTVOSAssertionWarning: Bool = false
3131
var awaiter: Awaiter
3232

33-
init() {
33+
override init() {
3434
let timeoutQueue = DispatchQueue.global(qos: .userInitiated)
3535
awaiter = Awaiter(
3636
waitLock: AssertionWaitLock(),
3737
asyncQueue: .main,
38-
timeoutQueue: timeoutQueue)
38+
timeoutQueue: timeoutQueue
39+
)
40+
41+
super.init()
3942
}
4043
}

Sources/Nimble/Matchers/BeIdenticalTo.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import Foundation
44
/// as the expected instance.
55
public func beIdenticalTo(_ expected: Any?) -> Predicate<Any> {
66
return Predicate.define { actualExpression in
7-
#if os(Linux)
7+
#if os(Linux) && !swift(>=4.1.50)
88
let actual = try actualExpression.evaluate() as? AnyObject
99
#else
1010
let actual = try actualExpression.evaluate() as AnyObject?
1111
#endif
1212

1313
let bool: Bool
14-
#if os(Linux)
14+
#if os(Linux) && !swift(>=4.1.50)
1515
bool = actual === (expected as? AnyObject) && actual !== nil
1616
#else
1717
bool = actual === (expected as AnyObject?) && actual !== nil

Sources/Nimble/Utils/Await.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ internal class AwaitPromiseBuilder<T> {
261261
self.trigger.timeoutSource.resume()
262262
while self.promise.asyncResult.isIncomplete() {
263263
// Stopping the run loop does not work unless we run only 1 mode
264-
#if swift(>=4.2)
264+
#if swift(>=4.2) && (os(macOS) || os(iOS) || os(tvOS))
265265
_ = RunLoop.current.run(mode: .default, before: .distantFuture)
266266
#else
267267
_ = RunLoop.current.run(mode: .defaultRunLoopMode, before: .distantFuture)

Sources/Nimble/Utils/Stringers.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22

33
internal func identityAsString(_ value: Any?) -> String {
44
let anyObject: AnyObject?
5-
#if os(Linux)
5+
#if os(Linux) && !swift(>=4.1.50)
66
anyObject = value as? AnyObject
77
#else
88
anyObject = value as AnyObject?

test

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function test_podspec {
8484

8585
function test_swiftpm {
8686
if [ -d .build ]; then
87-
run swift build --clean
87+
run swift package clean
8888
fi
8989
run swift build && swift test
9090
}

0 commit comments

Comments
 (0)