mirror of
https://github.com/cirruslabs/tart.git
synced 2026-09-30 03:01:12 +02:00
fix(storage): preserve running VM delete errors (#1350)
* fix(storage): preserve running VM delete errors Do not reinterpret RuntimeError.VMIsRunning as a missing VM when the storage wrapper bridges errors through NSError. Refs #1345 * test(storage): initialize running VM lock file * test(storage): hold VM lock in a child process * fix(storage): narrow file-not-found error matching * test(storage): use Swift error-domain regression coverage
This commit is contained in:
@@ -38,7 +38,8 @@ class VMStorageHelper {
|
||||
|
||||
extension NSError {
|
||||
func isFileNotFound() -> Bool {
|
||||
return self.code == NSFileNoSuchFileError || self.code == NSFileReadNoSuchFileError
|
||||
return self.domain == NSCocoaErrorDomain &&
|
||||
(self.code == NSFileNoSuchFileError || self.code == NSFileReadNoSuchFileError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +116,12 @@ final class CommandBehaviorTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
func testFileNotFoundRequiresCocoaErrorDomain() {
|
||||
XCTAssertTrue(NSError(domain: NSCocoaErrorDomain, code: NSFileNoSuchFileError).isFileNotFound())
|
||||
XCTAssertTrue(NSError(domain: NSCocoaErrorDomain, code: NSFileReadNoSuchFileError).isFileNotFound())
|
||||
XCTAssertFalse(RuntimeError.VMIsRunning("running").isFileNotFound())
|
||||
}
|
||||
|
||||
func testSetDiskRejectsStackedVMBeforeSavingConfig() async throws {
|
||||
try await withTemporaryTartHome {
|
||||
let vmDir = try VMStorageLocal().create("stacked")
|
||||
|
||||
Reference in New Issue
Block a user