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.

An accessibility audit of every page, run by hand before a release

Țugui Dragoș4d0ff649212f
diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
index 6a689e07..a1162e1f 100644
--- a/.github/workflows/checks.yml
+++ b/.github/workflows/checks.yml
@@ -46,6 +46,12 @@ jobs:
xcodebuild -project Peel.xcodeproj -scheme Peel -configuration Debug \
-derivedDataPath build/DerivedData CODE_SIGNING_ALLOWED=NO build
+ # The accessibility audit drives the pointer, so it runs by hand before a release. Here it is only built.
+ - name: Build the accessibility audit
+ run: |
+ xcodebuild -project Peel.xcodeproj -scheme PeelUITests -configuration Debug \
+ -derivedDataPath build/DerivedData CODE_SIGNING_ALLOWED=NO build-for-testing
+
# The string catalogs are synced by running `Scripts/sync_localizations.py` by hand. This step fails when a
# catalog is out of date. It reads the strings from the Debug build above, in `build/DerivedData`.
- name: The string catalogs are in step with the code
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index 53ea594b..1e724173 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -180,6 +180,9 @@ refuses it.
folder swapped between the check and the move.
- A few tests read this Mac instead of a fixture, and the slowest ones run only when asked for
(`PEEL_TEST_THIS_MAC=1`).
+- `PeelUITests` runs Xcode's accessibility audit on every page, About, Settings, and the menu bar panel, in both
+ appearances. It drives the pointer and quits a Peel that is open, so it has a scheme of its own and runs by hand
+ before a release; the checks only build it.
- `Scripts/sync_localizations.py --check` fails when a string catalog is behind the code, and
`Scripts/generate_manual.py --check` when the manual page of `peel` is behind the tool.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 69a92b0a..02d58a71 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -22,9 +22,9 @@ exports the domain first, so putting the file back undoes it. Every `brew` call
- macOS 26 or later. Peel is built with the macOS 27 SDK for macOS 26 and later.
- Xcode 27 or later, with Swift 6.4.
- A team to sign with, even a free one. The project names its maintainer's team, so build with yours: add
- `DEVELOPMENT_TEAM=YOUR_TEAM_ID` to the `xcodebuild` command, or choose your team for the four targets under
- Signing & Capabilities in Xcode and leave that change out of your commits. The helper accepts only an app signed
- by the same team as itself, so the app and the helper you build work together. The tests need no signing.
+ `DEVELOPMENT_TEAM=YOUR_TEAM_ID` to the `xcodebuild` command, or choose your team for the targets under Signing &
+ Capabilities in Xcode and leave that change out of your commits. The helper accepts only an app signed by the
+ same team as itself, so the app and the helper you build work together. The package's tests need no signing.
- Nothing else. The only dependency is Apple's swift-argument-parser, which Xcode fetches.
```bash
@@ -41,7 +41,7 @@ without build output rather than empty the catalogs. After changing a command of
`python3 Scripts/generate_manual.py` as well, which writes its manual page, `Support/peel.1`, from the tool just
built.
-The app's four targets build with warnings as errors, and that is the bar a change has to clear. The package's
+The project's targets build with warnings as errors, and that is the bar a change has to clear. The package's
manifest doesn't set it, so ask for it on the command line to hold the package to the same bar:
```bash
@@ -57,6 +57,16 @@ runs only when asked for, and it is worth running before a release:
PEEL_TEST_THIS_MAC=1 swift test --package-path Packages/PeelCore --filter SuggestedSelectionOnThisMacTests
```
+Before a release, run Xcode's accessibility audit on every page, About, Settings, and the menu bar panel, in the
+light appearance and the dark one. It moves the pointer, types, and quits a Peel that is open, so it has a scheme
+of its own and runs only when asked for, on a Mac nobody is using. macOS asks once to give the test runner
+Accessibility, and for an administrator's password when Automation Mode turns on. Each result comes with a picture
+of the screen, in the test report:
+
+```bash
+xcodebuild test -project Peel.xcodeproj -scheme PeelUITests -derivedDataPath build/DerivedData DEVELOPMENT_TEAM=YOUR_TEAM_ID
+```
+
[ARCHITECTURE.md](ARCHITECTURE.md) explains how the parts fit together.
## Where things live
@@ -65,6 +75,7 @@ PEEL_TEST_THIS_MAC=1 swift test --package-path Packages/PeelCore --filter Sugges
- `PeelHelper/`: the privileged helper. Read its section below before touching it.
- `PeelFinder/`: the sandboxed Finder Sync extension.
- `PeelCLI/`: the `peel` command line tool, a thin entry point.
+- `PeelUITests/`: the accessibility audit, run by hand before a release.
- `Packages/PeelCore/`: everything that decides and acts, with the tests. `PeelCore` scans, matches, and removes;
`PeelPrivileged` is the part the helper shares; `PeelCommandLine` holds the `peel` commands.
- `Localization/`: every translation, and nothing else: the string catalogs of the app and the Finder extension.
diff --git a/Peel.xcodeproj/project.pbxproj b/Peel.xcodeproj/project.pbxproj
index 7e74aa4e..1562c424 100644
--- a/Peel.xcodeproj/project.pbxproj
+++ b/Peel.xcodeproj/project.pbxproj
@@ -42,6 +42,13 @@
remoteGlobalIDString = AA0000000000000000000042;
remoteInfo = PeelCLI;
};
+ AA0000000000000000000060 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = AA0000000000000000000001 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = AA0000000000000000000006;
+ remoteInfo = Peel;
+ };
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -101,6 +108,7 @@
AA0000000000000000000043 /* peel */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = peel; sourceTree = BUILT_PRODUCTS_DIR; };
AA0000000000000000000050 /* Peel.icon */ = {isa = PBXFileReference; lastKnownFileType = folder.iconcomposer.icon; path = Peel.icon; sourceTree = "<group>"; };
AA0000000000000000000051 /* Logo.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Logo.xcassets; sourceTree = "<group>"; };
+ AA000000000000000000005B /* PeelUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PeelUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFileSystemSynchronizedRootGroup section */
@@ -134,6 +142,11 @@
path = PeelFinder;
sourceTree = "<group>";
};
+ AA000000000000000000005A /* PeelUITests */ = {
+ isa = PBXFileSystemSynchronizedRootGroup;
+ path = PeelUITests;
+ sourceTree = "<group>";
+ };
/* End PBXFileSystemSynchronizedRootGroup section */
/* Begin PBXFrameworksBuildPhase section */
@@ -168,6 +181,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ AA000000000000000000005E /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
@@ -178,6 +198,7 @@
AA0000000000000000000020 /* PeelHelper */,
AA0000000000000000000033 /* PeelFinder */,
AA0000000000000000000041 /* PeelCLI */,
+ AA000000000000000000005A /* PeelUITests */,
AA0000000000000000000056 /* Localization */,
AA000000000000000000004F /* Logo */,
AA0000000000000000000031 /* Support */,
@@ -192,6 +213,7 @@
AA0000000000000000000022 /* PeelHelper */,
AA0000000000000000000035 /* PeelFinder.appex */,
AA0000000000000000000043 /* peel */,
+ AA000000000000000000005B /* PeelUITests.xctest */,
);
name = Products;
sourceTree = "<group>";
@@ -324,6 +346,26 @@
productReference = AA0000000000000000000004 /* Peel.app */;
productType = "com.apple.product-type.application";
};
+ AA000000000000000000005C /* PeelUITests */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = AA0000000000000000000062 /* Build configuration list for PBXNativeTarget "PeelUITests" */;
+ buildPhases = (
+ AA000000000000000000005D /* Sources */,
+ AA000000000000000000005E /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ AA0000000000000000000061 /* PBXTargetDependency */,
+ );
+ fileSystemSynchronizedGroups = (
+ AA000000000000000000005A /* PeelUITests */,
+ );
+ name = PeelUITests;
+ productName = PeelUITests;
+ productReference = AA000000000000000000005B /* PeelUITests.xctest */;
+ productType = "com.apple.product-type.bundle.ui-testing";
+ };
/* End PBXNativeTarget section */
/* Begin PBXProject section */
@@ -346,6 +388,10 @@
AA0000000000000000000042 = {
CreatedOnToolsVersion = 27.0;
};
+ AA000000000000000000005C = {
+ CreatedOnToolsVersion = 27.0;
+ TestTargetID = AA0000000000000000000006;
+ };
};
};
buildConfigurationList = AA000000000000000000000A /* Build configuration list for PBXProject "Peel" */;
@@ -386,6 +432,7 @@
AA0000000000000000000021 /* PeelHelper */,
AA0000000000000000000034 /* PeelFinder */,
AA0000000000000000000042 /* PeelCLI */,
+ AA000000000000000000005C /* PeelUITests */,
);
};
/* End PBXProject section */
@@ -467,6 +514,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ AA000000000000000000005D /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
@@ -485,6 +539,11 @@
target = AA0000000000000000000042 /* PeelCLI */;
targetProxy = AA000000000000000000004B /* PBXContainerItemProxy */;
};
+ AA0000000000000000000061 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = AA0000000000000000000006 /* Peel */;
+ targetProxy = AA0000000000000000000060 /* PBXContainerItemProxy */;
+ };
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
@@ -833,6 +892,46 @@
};
name = Release;
};
+ AA0000000000000000000063 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 261001;
+ DEVELOPMENT_TEAM = 6R6J264YA2;
+ GENERATE_INFOPLIST_FILE = YES;
+ MARKETING_VERSION = 1.0.1;
+ OTHER_SWIFT_FLAGS = "$(inherited) -enable-upcoming-feature ImmutableWeakCaptures";
+ PRODUCT_BUNDLE_IDENTIFIER = com.tuguidragos.Peel.UITests;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_APPROACHABLE_CONCURRENCY = YES;
+ SWIFT_UPCOMING_FEATURE_EXISTENTIAL_ANY = YES;
+ SWIFT_UPCOMING_FEATURE_INTERNAL_IMPORTS_BY_DEFAULT = YES;
+ SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
+ SWIFT_VERSION = 6.0;
+ TEST_TARGET_NAME = Peel;
+ };
+ name = Debug;
+ };
+ AA0000000000000000000064 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 261001;
+ DEVELOPMENT_TEAM = 6R6J264YA2;
+ GENERATE_INFOPLIST_FILE = YES;
+ MARKETING_VERSION = 1.0.1;
+ OTHER_SWIFT_FLAGS = "$(inherited) -enable-upcoming-feature ImmutableWeakCaptures";
+ PRODUCT_BUNDLE_IDENTIFIER = com.tuguidragos.Peel.UITests;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_APPROACHABLE_CONCURRENCY = YES;
+ SWIFT_UPCOMING_FEATURE_EXISTENTIAL_ANY = YES;
+ SWIFT_UPCOMING_FEATURE_INTERNAL_IMPORTS_BY_DEFAULT = YES;
+ SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
+ SWIFT_VERSION = 6.0;
+ TEST_TARGET_NAME = Peel;
+ };
+ name = Release;
+ };
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@@ -881,6 +980,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ AA0000000000000000000062 /* Build configuration list for PBXNativeTarget "PeelUITests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ AA0000000000000000000063 /* Debug */,
+ AA0000000000000000000064 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
/* End XCConfigurationList section */
/* Begin XCLocalSwiftPackageReference section */
diff --git a/Peel.xcodeproj/xcshareddata/xcschemes/PeelUITests.xcscheme b/Peel.xcodeproj/xcshareddata/xcschemes/PeelUITests.xcscheme
new file mode 100644
index 00000000..46f4eb81
--- /dev/null
+++ b/Peel.xcodeproj/xcshareddata/xcschemes/PeelUITests.xcscheme
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "2700"
+ version = "1.7">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "NO"
+ buildForProfiling = "NO"
+ buildForArchiving = "NO"
+ buildForAnalyzing = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "AA000000000000000000005C"
+ BuildableName = "PeelUITests.xctest"
+ BlueprintName = "PeelUITests"
+ ReferencedContainer = "container:Peel.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES">
+ <Testables>
+ <TestableReference
+ skipped = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "AA000000000000000000005C"
+ BuildableName = "PeelUITests.xctest"
+ BlueprintName = "PeelUITests"
+ ReferencedContainer = "container:Peel.xcodeproj">
+ </BuildableReference>
+ </TestableReference>
+ </Testables>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/PeelUITests/AccessibilityAuditTests.swift b/PeelUITests/AccessibilityAuditTests.swift
new file mode 100644
index 00000000..cecf3c41
--- /dev/null
+++ b/PeelUITests/AccessibilityAuditTests.swift
@@ -0,0 +1,107 @@
+import XCTest
+
+/// Runs Xcode's accessibility audit on every page of Peel, on About, on each pane of Settings, and on the menu bar
+/// panel, in the light appearance and in the dark one, and keeps a picture of the screen with each result.
+///
+/// It moves the pointer, types, and quits a Peel that is already open, so it runs only when asked, from the
+/// PeelUITests scheme, on a Mac nobody is using. macOS asks once for the test runner to get Accessibility, and for
+/// an administrator's password each time Automation Mode turns on. Every audit here only reads what is on screen.
+/// The action audit is left out: Apple doesn't say what it does to a control, and in Peel a switch changes a macOS
+/// setting and a button moves files. For contrast under Increase Contrast, run it again with that setting on.
+@MainActor
+final class AccessibilityAuditTests: XCTestCase {
+ private static let audits: XCUIAccessibilityAuditType = [
+ .contrast, .elementDetection, .hitRegion, .sufficientElementDescription, .parentChild,
+ ]
+
+ /// Every page, in the order of the View menu, which is the sidebar's.
+ private static let pages = [
+ "Home", "Tweaks", "History",
+ "Applications", "Orphaned Files", "Intel Software", "Package Receipts", "Homebrew",
+ "Space", "Developer", "Build Artifacts", "Installers and Backups", "Duplicates", "iCloud Drive", "File Search",
+ "Background Items", "Extensions", "Plug-ins",
+ ]
+
+ private static let settingsPanes = ["General", "Exclusions", "Privacy", "Helper"]
+
+ func testEverythingInTheLightAppearance() {
+ auditEverything(appearance: "Light")
+ }
+
+ func testEverythingInTheDarkAppearance() {
+ auditEverything(appearance: "Dark")
+ }
+
+ private func auditEverything(appearance: String) {
+ continueAfterFailure = true
+ let app = XCUIApplication()
+ // In English, so menus are found by their titles, and in the appearance asked for. Arguments come before
+ // the Mac's own settings, for Peel alone.
+ app.launchArguments = [
+ "-AppleLanguages", "(en)",
+ "-AppleLocale", "en_US",
+ "-AppleInterfaceStyleSwitchesAutomatically", "NO",
+ "-AppleInterfaceStyle", appearance,
+ ]
+ app.launch()
+
+ for page in Self.pages {
+ choose(page, inMenu: "View", of: app)
+ waitForTheScan(of: page, in: app)
+ audit(page, appearance: appearance, of: app)
+ }
+
+ choose("About Peel", inMenu: "Peel", of: app)
+ audit("About", appearance: appearance, of: app)
+ app.typeKey("w", modifierFlags: .command)
+
+ app.typeKey(",", modifierFlags: .command)
+ let settings = app.windows
+ .containing(.any, identifier: "Exclusions")
+ .containing(.any, identifier: "Helper")
+ .firstMatch
+ for pane in Self.settingsPanes {
+ settings.toolbars.descendants(matching: .any)[pane].firstMatch.click()
+ audit("Settings, \(pane)", appearance: appearance, of: app)
+ }
+ app.typeKey("w", modifierFlags: .command)
+
+ // The menu bar item can be turned off in Settings, and then there is no panel to look at.
+ let menuBarItem = app.statusItems.firstMatch
+ if menuBarItem.exists {
+ menuBarItem.click()
+ audit("The menu bar panel", appearance: appearance, of: app)
+ menuBarItem.click()
+ }
+
+ app.terminate()
+ }
+
+ private func choose(_ item: String, inMenu menu: String, of app: XCUIApplication) {
+ let title = app.menuBars.menuBarItems[menu]
+ title.click()
+ title.menuItems[item].click()
+ }
+
+ /// Waits for the page's scan to end. While one runs, the toolbar's Rescan turns into Stop, a moment after the
+ /// scan starts.
+ private func waitForTheScan(of page: String, in app: XCUIApplication) {
+ let stop = app.toolbars.buttons["Stop"]
+ guard stop.waitForExistence(timeout: 2) else { return }
+ XCTAssertTrue(stop.waitForNonExistence(timeout: 300), "\(page) was still scanning after 5 minutes")
+ }
+
+ private func audit(_ name: String, appearance: String, of app: XCUIApplication) {
+ XCTContext.runActivity(named: "\(name), \(appearance)") { activity in
+ let picture = XCTAttachment(screenshot: XCUIScreen.main.screenshot())
+ picture.name = "\(name), \(appearance)"
+ picture.lifetime = .keepAlways
+ activity.add(picture)
+ do {
+ try app.performAccessibilityAudit(for: Self.audits)
+ } catch {
+ XCTFail("The audit of \(name) couldn't run: \(error)")
+ }
+ }
+ }
+}