commit 254867909e70e71fb6b716c4cfb9456a2454d00c
parent d1bc04dd38093b6149c4e479e5ce5402ace47ac7
Author: Michael Camilleri <[email protected]>
Date: Wed, 4 Nov 2026 08:30:17 +0900
Quieten the unit test run
The unit test output was mixed with dozens of log lines from system
frameworks in the test host, which made real failures and warnings easy
to overlook.
This commit sets OS_ACTIVITY_DT_MODE to NO for the test action, so
those logs are no longer mirrored into the output. It also fixes the
one warning among them that was real: the SQLite delete-all test removed
its directory while the store was open, which SQLite reported as an
integrity violation. The test now closes the store first.
The simulator helper now picks the newest iPhone Pro, on the newest
runtime that has one, rather than the first iPhone listed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat
| M | Reportage.xcodeproj/xcshareddata/xcschemes/Reportage.xcscheme | | | 9 | ++++++++- |
| M | Scripts/select-simulator.sh | | | 46 | ++++++++++++++++++++++++++++++++++------------ |
| M | Tests/Unit/ReportStoreTests.swift | | | 7 | +++++++ |
| M | project.yml | | | 2 | ++ |
4 files changed, 51 insertions(+), 13 deletions(-)
diff --git a/Reportage.xcodeproj/xcshareddata/xcschemes/Reportage.xcscheme b/Reportage.xcodeproj/xcshareddata/xcschemes/Reportage.xcscheme
@@ -45,7 +45,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- shouldUseLaunchSchemeArgsEnv = "YES"
+ shouldUseLaunchSchemeArgsEnv = "NO"
onlyGenerateCoverageForSpecifiedTargets = "NO">
<MacroExpansion>
<BuildableReference
@@ -72,6 +72,13 @@
</Testables>
<CommandLineArguments>
</CommandLineArguments>
+ <EnvironmentVariables>
+ <EnvironmentVariable
+ key = "OS_ACTIVITY_DT_MODE"
+ value = "NO"
+ isEnabled = "YES">
+ </EnvironmentVariable>
+ </EnvironmentVariables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
diff --git a/Scripts/select-simulator.sh b/Scripts/select-simulator.sh
@@ -2,28 +2,50 @@
# Shared helper: resolves a usable iOS Simulator for the given major version.
# Source this file, then call: select_simulator [major] (default major: 27)
# On success sets RUNTIME, DESTINATION_OS, and DEVICE; on failure prints to stderr and returns 1.
+#
+# The device is the newest 'iPhone N Pro' (not the Pro Max), on the newest
+# runtime that has one. Without one, it's the first iPhone on the newest
+# runtime.
select_simulator() {
local major="${1:-27}"
- local runtime_line
- runtime_line=$(xcrun simctl list runtimes available \
+ local runtime_lines
+ runtime_lines=$(xcrun simctl list runtimes available \
| grep "iOS ${major}\." \
- | sort -t. -k1,1n -k2,2n \
- | tail -1 || true)
+ | sort -t. -k1,1n -k2,2n -r || true)
- RUNTIME=$(sed 's/.*iOS \([0-9.]*\).*/\1/' <<<"${runtime_line}")
- DESTINATION_OS=$(sed 's/.*(\([0-9.]*\) -.*/\1/' <<<"${runtime_line}")
-
- if [ -z "$RUNTIME" ] || [ -z "$DESTINATION_OS" ]; then
+ if [ -z "$runtime_lines" ]; then
echo "No available iOS ${major}.x simulator runtime found." >&2
return 1
fi
- DEVICE=$(xcrun simctl list devices available "iOS ${RUNTIME}" \
- | grep "iPhone" \
- | head -1 \
- | sed 's/^ *\(.*\) ([A-F0-9-]*).*/\1/' || true)
+ local runtime_line="" device="" line version candidate
+ while IFS= read -r line; do
+ version=$(sed 's/.*iOS \([0-9.]*\).*/\1/' <<<"${line}")
+ candidate=$(xcrun simctl list devices available "iOS ${version}" \
+ | sed -n 's/^ *\(iPhone [0-9][0-9]* Pro\) ([A-F0-9-]*).*/\1/p' \
+ | sort -t' ' -k2,2n \
+ | tail -1 || true)
+ if [ -n "$candidate" ]; then
+ runtime_line="$line"
+ device="$candidate"
+ break
+ fi
+ done <<<"${runtime_lines}"
+
+ if [ -z "$device" ]; then
+ runtime_line=$(head -1 <<<"${runtime_lines}")
+ version=$(sed 's/.*iOS \([0-9.]*\).*/\1/' <<<"${runtime_line}")
+ device=$(xcrun simctl list devices available "iOS ${version}" \
+ | grep "iPhone" \
+ | head -1 \
+ | sed 's/^ *\(.*\) ([A-F0-9-]*).*/\1/' || true)
+ fi
+
+ RUNTIME=$(sed 's/.*iOS \([0-9.]*\).*/\1/' <<<"${runtime_line}")
+ DESTINATION_OS=$(sed 's/.*(\([0-9.]*\) -.*/\1/' <<<"${runtime_line}")
+ DEVICE="$device"
if [ -z "$DEVICE" ]; then
echo "No available iPhone simulator found for iOS ${RUNTIME}." >&2
diff --git a/Tests/Unit/ReportStoreTests.swift b/Tests/Unit/ReportStoreTests.swift
@@ -431,6 +431,13 @@ struct ReportStoreTests {
#expect(try persistence.viewContext.count(for: ReportEntity.fetchRequest()) == 0)
#expect(try persistence.viewContext.count(for: ResponseEntity.fetchRequest()) == 0)
#expect(try persistence.viewContext.count(for: QuestionEntity.fetchRequest()) == 0)
+
+ // Closed before the directory is removed, so SQLite's files aren't
+ // deleted while open.
+ let coordinator = persistence.container.persistentStoreCoordinator
+ for store in coordinator.persistentStores {
+ try coordinator.remove(store)
+ }
}
}
diff --git a/project.yml b/project.yml
@@ -126,6 +126,8 @@ schemes:
config: Debug
test:
config: Debug
+ environmentVariables:
+ OS_ACTIVITY_DT_MODE: NO
targets:
- name: Reportage Unit Tests
parallelizable: false