Skip to content

Commit d3c553f

Browse files
authored
SWIFT-1600 Update compile script to ensure tests compile on minimum supported Swift version (#766)
1 parent d4f2ea1 commit d3c553f

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

.evergreen/compile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ INSTALL_DIR="${PROJECT_DIRECTORY}/opt"
1010
# configure Swift
1111
. ${PROJECT_DIRECTORY}/.evergreen/configure-swift.sh
1212

13-
swift build
13+
swift build --build-tests

Tests/MongoSwiftTests/MongoClientTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ final class MongoClientTests: MongoSwiftTestCase {
7474
}
7575
}
7676

77+
#if compiler(>=5.5.2) && canImport(_Concurrency)
78+
@available(macOS 10.15, *)
7779
func testListDatabasesComment() async throws {
7880
try await self.withTestClient { client in
7981
// comment only supported here for 4.4+
@@ -101,6 +103,7 @@ final class MongoClientTests: MongoSwiftTestCase {
101103
expect(receivedEvents[1].command["comment"]).to(beNil())
102104
}
103105
}
106+
#endif
104107

105108
func testClientIdGeneration() throws {
106109
let ids = try (0...2).map { _ in

Tests/MongoSwiftTests/MongoCollection+IndexTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
#if compiler(>=5.5.2) && canImport(_Concurrency)
12
import Foundation
23
import MongoSwift
34
import Nimble
45
import TestsCommon
56

7+
@available(macOS 10.15, *)
68
final class MongoCollection_IndexTests: MongoSwiftTestCase {
79
func testCreateListDropIndexesComment() async throws {
810
try await self.withTestClient { client in
@@ -66,3 +68,4 @@ final class MongoCollection_IndexTests: MongoSwiftTestCase {
6668
}
6769
}
6870
}
71+
#endif

Tests/MongoSwiftTests/MongoConnectionStringTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -598,28 +598,28 @@ final class ConnectionStringTests: MongoSwiftTestCase {
598598
func testIPv4AddressParsing() throws {
599599
// valid IPv4
600600
let connString1 = try MongoConnectionString(string: "mongodb://1.2.3.4")
601-
guard let host = connString1.hosts.first else {
601+
guard let host1 = connString1.hosts.first else {
602602
XCTFail("connection string should contain one host")
603603
return
604604
}
605-
expect(host.host).to(equal("1.2.3.4"))
606-
expect(host.type).to(equal(.ipv4))
605+
expect(host1.host).to(equal("1.2.3.4"))
606+
expect(host1.type).to(equal(.ipv4))
607607
// invalid IPv4 should fall back to hostname (only three numbers)
608608
let connString2 = try MongoConnectionString(string: "mongodb://1.2.3")
609-
guard let host = connString2.hosts.first else {
609+
guard let host2 = connString2.hosts.first else {
610610
XCTFail("connection string should contain one host")
611611
return
612612
}
613-
expect(host.host).to(equal("1.2.3"))
614-
expect(host.type).to(equal(.hostname))
613+
expect(host2.host).to(equal("1.2.3"))
614+
expect(host2.type).to(equal(.hostname))
615615
// invalid IPv4 should fall back to hostname (numbers out of bounds)
616616
let connString3 = try MongoConnectionString(string: "mongodb://256.1.2.3")
617-
guard let host = connString3.hosts.first else {
617+
guard let host3 = connString3.hosts.first else {
618618
XCTFail("connection string should contain one host")
619619
return
620620
}
621-
expect(host.host).to(equal("256.1.2.3"))
622-
expect(host.type).to(equal(.hostname))
621+
expect(host3.host).to(equal("256.1.2.3"))
622+
expect(host3.type).to(equal(.hostname))
623623
}
624624

625625
func testAuthSourceInDescription() throws {

Tests/MongoSwiftTests/MongoDatabaseTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
#if compiler(>=5.5.2) && canImport(_Concurrency)
12
import Foundation
23
import MongoSwift
34
import Nimble
45
import TestsCommon
56

7+
@available(macOS 10.15, *)
68
final class MongoDatabaseTests: MongoSwiftTestCase {
79
func testListCollectionsComment() async throws {
810
try await self.withTestClient { client in
@@ -39,3 +41,4 @@ final class MongoDatabaseTests: MongoSwiftTestCase {
3941
}
4042
}
4143
}
44+
#endif

0 commit comments

Comments
 (0)