Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Say why the Time Machine test failed when it does

Țugui Dragoș8f35dedf9961
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/TimeMachineExclusionTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/TimeMachineExclusionTests.swift
index 7af3e42b..834105ab 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/TimeMachineExclusionTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/TimeMachineExclusionTests.swift
@@ -12,6 +12,16 @@ struct TimeMachineExclusionTests {
return TimeMachineExclusion.excluded(among: urls) == expected
}
+ /// What each folder reads as, what its parent reads as, and whether the mark is still on the disk, so a failure
+ /// says which of them kept the old state.
+ private func state(of urls: [URL]) -> String {
+ urls.map { url in
+ let mark = getxattr(url.path(percentEncoded: false), "com.apple.metadata:com_apple_backup_excludeItem", nil, 0, 0, 0)
+ let parent = TimeMachineExclusion.standing(of: url.deletingLastPathComponent())
+ return "\(url.lastPathComponent): \(TimeMachineExclusion.standing(of: url)), parent \(parent), mark \(mark >= 0)"
+ }.joined(separator: "; ")
+ }
+
/// The mark is an attribute on the folder, so it goes on and comes off without administrator rights. The
/// temporary folder works for this test: `tmutil isexcluded "$TMPDIR"` prints `[Excluded]`, yet
/// `CSBackupIsItemExcluded` answers false for a folder inside it.
@@ -22,16 +32,16 @@ struct TimeMachineExclusionTests {
#expect(!TimeMachineExclusion.isExcluded(modules))
#expect(TimeMachineExclusion.setExcluded(true, [modules, build]).isEmpty, "a folder refused the mark")
- #expect(try await settles([modules, build], as: [modules, build]))
+ #expect(try await settles([modules, build], as: [modules, build]), "\(state(of: [modules, build]))")
#expect(TimeMachineExclusion.standing(of: modules) == .excludedItself)
#expect(TimeMachineExclusion.setExcluded(false, [modules]).isEmpty)
- #expect(try await settles([modules, build], as: [build]))
+ #expect(try await settles([modules, build], as: [build]), "\(state(of: [modules, build]))")
// A folder inside an excluded folder is excluded from above, not by a mark of its own.
#expect(TimeMachineExclusion.standing(of: try directory.directory("app/.build/inner")) == .excludedFromAbove)
#expect(TimeMachineExclusion.setExcluded(false, [build]).isEmpty)
- #expect(try await settles([modules, build], as: []))
+ #expect(try await settles([modules, build], as: []), "\(state(of: [modules, build]))")
}
@Test func answersWithoutComplainingForAnEmptyListOrAMissingFolder() throws {