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:
RKS
2026-09-26 08:40:20 -07:00
committed by GitHub
parent bb4acb2468
commit 8ac52501c3
2 changed files with 8 additions and 1 deletions
+2 -1
View File
@@ -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")