|
3 | 3 | # |
4 | 4 | # Tests for the ios_find_app() precedence chain in deploy.sh. |
5 | 5 | # These tests use temporary directories with fixture .app bundles. |
6 | | -# Does NOT require Xcode (xcodebuild tests are skipped). |
| 6 | +# Requires macOS (uses PlistBuddy for plist creation/reading). |
7 | 7 |
|
8 | 8 | set -euo pipefail |
9 | 9 |
|
10 | 10 | script_dir="$(cd "$(dirname "$0")" && pwd)" |
11 | 11 | . "$script_dir/../test-framework.sh" |
12 | 12 | setup_logging |
13 | 13 |
|
| 14 | +# Only run on macOS |
| 15 | +if [ "$(uname -s)" != "Darwin" ]; then |
| 16 | + echo "Skipping iOS app resolution tests (not on macOS)" |
| 17 | + exit 0 |
| 18 | +fi |
| 19 | + |
14 | 20 | # ============================================================================ |
15 | 21 | # Setup |
16 | 22 | # ============================================================================ |
@@ -38,16 +44,7 @@ create_fake_app() { |
38 | 44 | app_dir="$1" |
39 | 45 | bundle_id="${2:-com.test.app}" |
40 | 46 | mkdir -p "$app_dir" |
41 | | - cat > "$app_dir/Info.plist" <<PLIST |
42 | | -<?xml version="1.0" encoding="UTF-8"?> |
43 | | -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
44 | | -<plist version="1.0"> |
45 | | -<dict> |
46 | | - <key>CFBundleIdentifier</key> |
47 | | - <string>${bundle_id}</string> |
48 | | -</dict> |
49 | | -</plist> |
50 | | -PLIST |
| 47 | + /usr/libexec/PlistBuddy -c "Add :CFBundleIdentifier string $bundle_id" "$app_dir/Info.plist" 2>/dev/null || true |
51 | 48 | } |
52 | 49 |
|
53 | 50 | echo "========================================" |
@@ -180,24 +177,19 @@ assert_contains "$error_output" "No .app bundle found" "Error should mention no |
180 | 177 | assert_contains "$error_output" "IOS_APP_ARTIFACT" "Error should mention env var" |
181 | 178 |
|
182 | 179 | # ============================================================================ |
183 | | -# Tests: ios_extract_bundle_id (macOS only - uses PlistBuddy) |
| 180 | +# Tests: ios_extract_bundle_id |
184 | 181 | # ============================================================================ |
185 | 182 |
|
186 | | -if [ -x /usr/libexec/PlistBuddy ]; then |
187 | | - start_test "ios_extract_bundle_id - extracts from Info.plist" |
188 | | - test_root="$TMPDIR_BASE/test_bundle" |
189 | | - create_fake_app "$test_root/MyApp.app" "com.example.myapp" |
190 | | - result=$(ios_extract_bundle_id "$test_root/MyApp.app" 2>/dev/null) |
191 | | - assert_equal "com.example.myapp" "$result" "Should extract correct bundle ID" |
192 | | - |
193 | | - start_test "ios_extract_bundle_id - fails on missing Info.plist" |
194 | | - test_root="$TMPDIR_BASE/test_bundle_missing" |
195 | | - mkdir -p "$test_root/NoInfo.app" |
196 | | - assert_failure "ios_extract_bundle_id '$test_root/NoInfo.app'" "Should fail without Info.plist" |
197 | | -else |
198 | | - echo "" |
199 | | - echo "SKIP: ios_extract_bundle_id tests (PlistBuddy not available on this platform)" |
200 | | -fi |
| 183 | +start_test "ios_extract_bundle_id - extracts from Info.plist" |
| 184 | +test_root="$TMPDIR_BASE/test_bundle" |
| 185 | +create_fake_app "$test_root/MyApp.app" "com.example.myapp" |
| 186 | +result=$(ios_extract_bundle_id "$test_root/MyApp.app" 2>/dev/null) |
| 187 | +assert_equal "com.example.myapp" "$result" "Should extract correct bundle ID" |
| 188 | + |
| 189 | +start_test "ios_extract_bundle_id - fails on missing Info.plist" |
| 190 | +test_root="$TMPDIR_BASE/test_bundle_missing" |
| 191 | +mkdir -p "$test_root/NoInfo.app" |
| 192 | +assert_failure "ios_extract_bundle_id '$test_root/NoInfo.app'" "Should fail without Info.plist" |
201 | 193 |
|
202 | 194 | # ============================================================================ |
203 | 195 | # Tests: ios_resolve_app_glob |
|
0 commit comments