From ef925e433d356261ea4de8bb9e5c2feacff6eaa7 Mon Sep 17 00:00:00 2001 From: 12 <153109197+LittleYier@users.noreply.github.com> Date: Tue, 13 Oct 2026 21:25:07 +0900 Subject: [PATCH] Keep display refit setting when tart set changes other options (#1369) --- Sources/tart/Commands/Set.swift | 4 +++- Tests/TartTests/CommandBehaviorTests.swift | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) 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()