diff --git a/Sources/tart/Commands/Set.swift b/Sources/tart/Commands/Set.swift index 39025f8..389c6d5 100644 --- a/Sources/tart/Commands/Set.swift +++ b/Sources/tart/Commands/Set.swift @@ -67,7 +67,9 @@ struct Set: AsyncParsableCommand { vmConfig.display.unit = display.unit } - vmConfig.displayRefit = displayRefit + if let displayRefit = displayRefit { + vmConfig.displayRefit = displayRefit + } if randomMAC { vmConfig.macAddress = VZMACAddress.randomLocallyAdministered() diff --git a/Tests/TartTests/CommandBehaviorTests.swift b/Tests/TartTests/CommandBehaviorTests.swift index a07750f..7194c00 100644 --- a/Tests/TartTests/CommandBehaviorTests.swift +++ b/Tests/TartTests/CommandBehaviorTests.swift @@ -206,6 +206,22 @@ final class CommandBehaviorTests: XCTestCase { } } + func testSetPreservesDisplayRefitWhenChangingOtherOptions() async throws { + try await withTemporaryTartHome { + let vmDir = try makeStandaloneVM(named: "display-refit", diskContents: "disk") + var vmConfig = try VMConfig(fromURL: vmDir.configURL) + vmConfig.displayRefit = false + try vmConfig.save(toURL: vmDir.configURL) + + let command = try Set.parseAsRoot(["display-refit", "--cpu", "4"]) as! Set + try await command.run() + + let updatedConfig = try VMConfig(fromURL: vmDir.configURL) + XCTAssertEqual(updatedConfig.displayRefit, false) + XCTAssertEqual(updatedConfig.cpuCount, 4) + } + } + func testRemoteAdditionalDiskRetainsTemporaryBackingFileLock() throws { try withTemporaryTartHome { let storage = try VMStorageOCI()