Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Let the simulator test wait for simctl's answer, not the clock
Țugui Dragoș401dd77a8ae1
diff --git a/Packages/PeelCore/Sources/PeelCore/Space/Simctl.swift b/Packages/PeelCore/Sources/PeelCore/Space/Simctl.swiftindex 5e6a4291..76510f7d 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/Simctl.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/Simctl.swift@@ -10,15 +10,15 @@ enum Simctl {)/// What `simctl help runtime` prints, which it writes to standard error. Nil when `xcrun` would find no `simctl`- /// in the active developer folder, or the program did not answer.- static func runtimeHelp() async -> String? {+ /// in the active developer folder, or the program did not answer within `timeout` seconds, when there is one.+ static func runtimeHelp(within timeout: TimeInterval? = 5) async -> String? {guard let developer = await DeveloperFolder.active(),FileManager.default.isExecutableFile(atPath: developer.appending(path: "usr/bin/simctl").path(percentEncoded: false))else { return nil }let answer = await Subprocess.run(- program.path(percentEncoded: false), ["help", "runtime"], environment: [:], timeout: 5,+ program.path(percentEncoded: false), ["help", "runtime"], environment: [:], timeout: timeout,errorsIntoOutput: true)guard case .success(let output) = answer, output.status == 0 else { return nil }diff --git a/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift b/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swiftindex b0a85b06..aed0f669 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift@@ -511,7 +511,7 @@ public enum SpaceInventory {minimumSize: Int64,exclusions: Exclusions = .none,measure: @escaping FileSize.Measure,- simctlRuntimeHelp: @escaping @Sendable () async -> String? = Simctl.runtimeHelp+ simctlRuntimeHelp: @escaping @Sendable () async -> String? = { await Simctl.runtimeHelp() }) async -> SpaceReport {let containers = appContainers(in: home)let groups = groupContainers(in: home)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swiftindex 35bed618..9cb9ca1a 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swift@@ -426,7 +426,9 @@ struct SpaceInventoryTests {} ?? falselet isInstalled = FileManager.default.isExecutableFile(atPath: Simctl.program.path(percentEncoded: false))- let help = await Simctl.runtimeHelp()+ // Space gives `simctl` five seconds, and on a busy Mac it can take longer to reach CoreSimulator's service,+ // so the test waits for its whole answer.+ let help = await Simctl.runtimeHelp(within: nil)if xcrunFindsOne && isInstalled {#expect(help?.contains("Usage: simctl runtime") == true)