mirror of https://github.com/cirruslabs/tart.git
Merge 7f93830341 into 8aa377b71e
This commit is contained in:
commit
58cf342167
|
|
@ -19,7 +19,7 @@ class ControlSocket {
|
|||
func run() async throws {
|
||||
// Remove control socket file from previous "tart run" invocations,
|
||||
// if any, otherwise we may get the "address already in use" error
|
||||
try? FileManager.default.removeItem(atPath: controlSocketURL.path())
|
||||
try? FileManager.default.removeItem(atPath: controlSocketURL.path)
|
||||
|
||||
// Change the current working directory to a VM's base directory
|
||||
// to work around Unix domain socket 104 byte limitation [1]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
import XCTest
|
||||
@testable import tart
|
||||
|
||||
final class ControlSocketURLTests: XCTestCase {
|
||||
func testControlSocketURLResolvesToAbsolutePath() throws {
|
||||
let baseURL = URL(fileURLWithPath: "/Users/test/.tart/vms/myvm/")
|
||||
let vmDir = VMDirectory(baseURL: baseURL)
|
||||
|
||||
// The .path property resolves relative URLs to absolute paths,
|
||||
// which is required for stale socket cleanup in ControlSocket.run()
|
||||
// since it happens before the working directory is changed.
|
||||
XCTAssertEqual(
|
||||
vmDir.controlSocketURL.path,
|
||||
"/Users/test/.tart/vms/myvm/control.sock"
|
||||
)
|
||||
}
|
||||
|
||||
func testControlSocketURLRelativePathIsJustFilename() throws {
|
||||
let baseURL = URL(fileURLWithPath: "/Users/test/.tart/vms/myvm/")
|
||||
let vmDir = VMDirectory(baseURL: baseURL)
|
||||
|
||||
// The .relativePath is used for socket binding after cwd is changed
|
||||
XCTAssertEqual(
|
||||
vmDir.controlSocketURL.relativePath,
|
||||
"control.sock"
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue