Skip to content

Commit 49c60c4

Browse files
committed
Add checks for debugging with Visual Studio Code
1 parent f5aca87 commit 49c60c4

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22
/.build
33
/.swiftpm
4+
/.vscode
45
/docs
56
/Packages
67
/*.xcodeproj

Tests/MQTTNIOTests/MQTTNIOTests.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ import NIOSSL
2626
final class MQTTNIOTests: XCTestCase {
2727
static let hostname = ProcessInfo.processInfo.environment["MOSQUITTO_SERVER"] ?? "localhost"
2828

29+
func isVSCodeDebugging() -> Bool {
30+
return ProcessInfo.processInfo.environment["VSCODE_PID"] != nil
31+
}
32+
2933
func testConnectWithWill() throws {
3034
let client = self.createClient(identifier: "testConnectWithWill")
3135
defer { XCTAssertNoThrow(try client.syncShutdownGracefully()) }
@@ -89,6 +93,11 @@ final class MQTTNIOTests: XCTestCase {
8993
}
9094

9195
func testSSLConnect() throws {
96+
#if os(macOS)
97+
// p12 loading crashes when debugger other than Xcode is attached
98+
guard !isVSCodeDebugging() else { throw XCTSkip() }
99+
#endif
100+
92101
let client = try createSSLClient(identifier: "testSSLConnect")
93102
defer { XCTAssertNoThrow(try client.syncShutdownGracefully()) }
94103
_ = try client.connect().wait()
@@ -97,6 +106,11 @@ final class MQTTNIOTests: XCTestCase {
97106
}
98107

99108
func testWebsocketAndSSLConnect() throws {
109+
#if os(macOS)
110+
// p12 loading crashes when debugger other than Xcode is attached
111+
guard !isVSCodeDebugging() else { throw XCTSkip() }
112+
#endif
113+
100114
let client = try createWebSocketAndSSLClient(identifier: "testWebsocketAndSSLConnect")
101115
defer { XCTAssertNoThrow(try client.syncShutdownGracefully()) }
102116
_ = try client.connect().wait()
@@ -106,6 +120,11 @@ final class MQTTNIOTests: XCTestCase {
106120

107121
#if canImport(Network)
108122
func testSSLConnectFromP12() throws {
123+
#if os(macOS)
124+
// p12 loading crashes when debugger other than Xcode is attached
125+
guard !isVSCodeDebugging() else { throw XCTSkip() }
126+
#endif
127+
109128
let client = try MQTTClient(
110129
host: Self.hostname,
111130
port: 8883,

0 commit comments

Comments
 (0)