-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-validate-env.sh
More file actions
executable file
·91 lines (67 loc) · 3.41 KB
/
test-validate-env.sh
File metadata and controls
executable file
·91 lines (67 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env bash
# iOS Plugin - Environment Validation Tests
# Tests that the iOS environment is properly configured in --pure mode
# (matches CI execution environment)
set -euo pipefail
script_dir="$(cd "$(dirname "$0")" && pwd)"
. "$script_dir/../test-framework.sh"
setup_logging
echo "========================================"
echo "iOS Environment Validation (--pure)"
echo "========================================"
# Only run on macOS
if [ "$(uname -s)" != "Darwin" ]; then
echo "Skipping iOS validation tests (not macOS)"
exit 0
fi
ios_example="$script_dir/../../../examples/ios"
# Helper to run commands in pure devbox environment
run_pure() {
(cd "$ios_example" && devbox run --pure bash -c "$1" 2>/dev/null)
}
# ============================================================================
# Test: setup command
# ============================================================================
start_test "setup command completes in --pure mode"
(cd "$ios_example" && devbox run --pure setup >/dev/null 2>&1)
exit_code=$?
assert_success "[ $exit_code -eq 0 ]" "setup should exit with 0"
# ============================================================================
# Test: Xcode tools
# ============================================================================
start_test "xcrun is available"
assert_success "run_pure 'command -v xcrun'" "xcrun should be available"
start_test "xcodebuild is available"
assert_success "run_pure 'command -v xcodebuild'" "xcodebuild should be available"
start_test "xcrun can show SDK path"
assert_success "run_pure 'xcrun --show-sdk-path'" "SDK path should be available"
start_test "simctl list devices works"
assert_success "run_pure 'xcrun simctl list devices'" "simctl should work"
start_test "swift compiler is available"
assert_success "run_pure 'command -v swift'" "swift should be available"
# ============================================================================
# Test: iOS environment variables
# ============================================================================
start_test "IOS_SCRIPTS_DIR is set"
assert_success "run_pure 'test -n \"\$IOS_SCRIPTS_DIR\" && test -d \"\$IOS_SCRIPTS_DIR\"'" "scripts dir should exist"
start_test "IOS_DEVICES_DIR is set"
assert_success "run_pure 'test -n \"\$IOS_DEVICES_DIR\" && test -d \"\$IOS_DEVICES_DIR\"'" "devices dir should exist"
start_test "device definitions exist"
assert_success "run_pure 'ls \"\$IOS_DEVICES_DIR\"/*.json >/dev/null 2>&1'" "should have device JSON files"
start_test "ios.sh is in PATH"
assert_success "run_pure 'command -v ios.sh'" "ios.sh should be available"
# ============================================================================
# Test: Skip flag
# ============================================================================
start_test "setup respects IOS_SKIP_SETUP=1"
output=$(cd "$ios_example" && devbox run --pure -e IOS_SKIP_SETUP=1 setup 2>&1)
assert_contains "$output" "Skipping iOS setup" "should skip when flag is set"
# ============================================================================
# Test: Idempotency
# ============================================================================
start_test "setup is idempotent (can run 3 times)"
(cd "$ios_example" && devbox run --pure setup >/dev/null 2>&1 && devbox run --pure setup >/dev/null 2>&1 && devbox run --pure setup >/dev/null 2>&1)
exit_code=$?
assert_success "[ $exit_code -eq 0 ]" "multiple runs should succeed"
# Summary
test_summary