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.

Carry the test host in Debug builds alone

Țugui Dragoșcfa3bf85001e
diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
index 65dea5f4..82701050 100644
--- a/.github/workflows/checks.yml
+++ b/.github/workflows/checks.yml
@@ -157,6 +157,10 @@ jobs:
if [ -n "$(find "$app/Contents/Frameworks/Sparkle.framework" -name '*.xpc')" ]; then
echo "::error::Sparkle.framework carries XPC services."; exit 1
fi
+ # The host the PeelTests scheme runs the hosted tests in is a Debug build's alone.
+ if strings "$app/Contents/MacOS/Peel" | grep -q PEEL_HOSTS_TESTS; then
+ echo "::error::The Release build carries the test host."; exit 1
+ fi
# The accessibility audit drives the pointer, so it runs by hand before a release. Here it is only built.
- name: Build the accessibility audit
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index fc637a1c..35f291e0 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -554,8 +554,9 @@ its place (`SettingsView`), whose zap takes Peel's whole folder, `Terminal/` inc
own state.
- `PeelTests` holds the tests of the app's own models, run inside Peel, which the scheme launches with
`PEEL_HOSTS_TESTS` set: Peel then starts none of its work, opens no window, and shows no menu bar item, so the tests
- drive the models alone and leave the Mac's own Peel as it was. `xcodebuild test -project Peel.xcodeproj -scheme
- PeelTests -destination "platform=macOS,arch=$(uname -m)" -derivedDataPath build/DerivedData` runs them.
+ drive the models alone and leave the Mac's own Peel as it was. Only a Debug build answers that variable; a release
+ carries nothing of the host. `xcodebuild test -project Peel.xcodeproj -scheme PeelTests -destination
+ "platform=macOS,arch=$(uname -m)" -derivedDataPath build/DerivedData` runs them.
- Scanners take their slow parts as parameters (how to measure a folder, how to run a tool), so a test can
stand in for a folder that never answers or a tool that fails.
- The `Attack*Tests` files try to get past the safety rules on purpose: another case, a link, a `/.vol` path, a
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index a902a69d..8360d4ce 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -36,8 +36,8 @@ xcodebuild -project Peel.xcodeproj -scheme Peel -configuration Debug -destinatio
swift test --package-path Packages/PeelCore -Xswiftc -warnings-as-errors
```
-The app's own models are tested inside Peel, which the PeelTests scheme launches with `PEEL_HOSTS_TESTS` set, so that
-it starts nothing and shows nothing:
+The app's own models are tested inside Peel, which the PeelTests scheme launches with `PEEL_HOSTS_TESTS` set, which
+only a Debug build answers, so that it starts nothing and shows nothing:
```bash
xcodebuild -project Peel.xcodeproj -scheme PeelTests -configuration Debug \
diff --git a/Peel/Launch.swift b/Peel/Launch.swift
index c6cdeb21..574bac20 100644
--- a/Peel/Launch.swift
+++ b/Peel/Launch.swift
@@ -1,18 +1,22 @@
import AppKit
import SwiftUI
-/// Where Peel starts: Peel itself, or, for the PeelTests scheme, a host that only runs the tests.
+/// Where Peel starts: Peel itself, or, for the PeelTests scheme, a host that only runs the tests, which only a
+/// Debug build carries.
@main
enum Launch {
static func main() {
+ #if DEBUG
if PeelApp.isHostingTests {
TestHost.main()
- } else {
- PeelApp.main()
+ return
}
+ #endif
+ PeelApp.main()
}
}
+#if DEBUG
/// The app the tests of Peel's models run in. It builds none of Peel's scenes, so nothing of Peel's starts or shows,
/// and AppKit records nothing under Peel's name, such as whether its menu bar item is hidden.
struct TestHost: App {
@@ -33,3 +37,4 @@ final class TestHostDelegate: NSObject, NSApplicationDelegate {
false
}
}
+#endif
diff --git a/Peel/PeelApp.swift b/Peel/PeelApp.swift
index e7c53f02..963047db 100644
--- a/Peel/PeelApp.swift
+++ b/Peel/PeelApp.swift
@@ -20,8 +20,10 @@ final class PeelAppDelegate: NSObject, NSApplicationDelegate {
}
struct PeelApp: App {
+ #if DEBUG
/// Set by the PeelTests scheme for the Peel that hosts the tests, which then runs `TestHost` in Peel's place.
static let isHostingTests = ProcessInfo.processInfo.environment["PEEL_HOSTS_TESTS"] != nil
+ #endif
@NSApplicationDelegateAdaptor(PeelAppDelegate.self) private var delegate
static let mainWindowID = "main"