THRIFT-4838: Add unix socket support for Swift
Client: Swift
Patch: Kino Roy
diff --git a/test/swift/CrossTests/Sources/TestClient/main.swift b/test/swift/CrossTests/Sources/TestClient/main.swift
index 6817981..d627408 100644
--- a/test/swift/CrossTests/Sources/TestClient/main.swift
+++ b/test/swift/CrossTests/Sources/TestClient/main.swift
@@ -40,7 +40,12 @@
   }
 
   static func getTransport(parameters: TestClientParameters) throws -> TTransport {
-    let socketTransport = try TSocketTransport(hostname: parameters.host!, port: parameters.port!)
+      let socketTransport: TTransport = try { () throws -> TTransport in
+          if let domainSocket = parameters.domainSocket {
+            return try TSocketTransport(path: domainSocket)
+          }
+          return try TSocketTransport(hostname: parameters.host!, port: parameters.port!)
+      }()
     if parameters.transport == .framed {
       return TFramedTransport(transport: socketTransport)
     } 
diff --git a/test/swift/CrossTests/Sources/TestServer/main.swift b/test/swift/CrossTests/Sources/TestServer/main.swift
index 15564d3..433bde7 100644
--- a/test/swift/CrossTests/Sources/TestServer/main.swift
+++ b/test/swift/CrossTests/Sources/TestServer/main.swift
@@ -34,19 +34,31 @@
     let processor = ThriftTestProcessor(service: service)
     
     
-    switch (parameters.proto, parameters.transport) {
-    case (.binary, .buffered):
+    switch (parameters.proto, parameters.transport, parameters.domainSocket) {
+    case (.binary, .buffered, .none):
       let proto = TBinaryProtocol.self
       server = try TSocketServer(port: parameters.port!, inProtocol: proto, outProtocol: proto, processor: processor)
-    case (.binary, .framed):
+    case (.binary, .framed, .none):
       let proto = TBinaryProtocol.self
       server = try TFramedSocketServer(port: parameters.port!, inProtocol: proto, outProtocol: proto, processor: processor)
-    case (.compact, .buffered):
+    case (.compact, .buffered, .none):
       let proto = TCompactProtocol.self
       server = try TSocketServer(port: parameters.port!, inProtocol: proto, outProtocol: proto, processor: processor)
-    case (.compact, .framed):
+    case (.compact, .framed, .none):
       let proto = TCompactProtocol.self
       server = try TFramedSocketServer(port: parameters.port!, inProtocol: proto, outProtocol: proto, processor: processor)
+    case (.binary, .buffered, .some(let domainSocket)):
+      let proto = TBinaryProtocol.self
+      server = try TSocketServer(path: domainSocket, inProtocol: proto, outProtocol: proto, processor: processor)
+    case (.binary, .framed, .some(let domainSocket)):
+      let proto = TBinaryProtocol.self
+      server = try TFramedSocketServer(path: domainSocket, inProtocol: proto, outProtocol: proto, processor: processor)
+    case (.compact, .buffered, .some(let domainSocket)):
+      let proto = TCompactProtocol.self
+      server = try TSocketServer(path: domainSocket, inProtocol: proto, outProtocol: proto, processor: processor)
+    case (.compact, .framed, .some(let domainSocket)):
+      let proto = TCompactProtocol.self
+      server = try TFramedSocketServer(path: domainSocket, inProtocol: proto, outProtocol: proto, processor: processor)
     default:
       throw ParserError.unsupportedOption
     }
diff --git a/test/tests.json b/test/tests.json
index 015a559..c9bd068 100644
--- a/test/tests.json
+++ b/test/tests.json
@@ -797,14 +797,14 @@
       "workdir": "swift/CrossTests/.build/x86_64-unknown-linux-gnu/debug",
       "protocols": ["binary", "compact"],
       "transports": ["buffered", "framed"],
-      "sockets": ["ip"]
+      "sockets": ["ip", "domain"]
     },
     "client": {
       "command": ["TestClient"],
       "workdir": "swift/CrossTests/.build/x86_64-unknown-linux-gnu/debug",
       "protocols": ["binary", "compact"],
       "transports": ["buffered", "framed"],
-      "sockets": ["ip"]
+      "sockets": ["ip", "domain"]
     }
   }
 ]