forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmobile_build_wrapper_test.sh
More file actions
executable file
·101 lines (89 loc) · 3.6 KB
/
Copy pathmobile_build_wrapper_test.sh
File metadata and controls
executable file
·101 lines (89 loc) · 3.6 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
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
fixture_dir="$(mktemp -d "${TMPDIR:-/tmp}/omi-mobile-wrapper.XXXXXX")"
trap 'rm -rf "$fixture_dir"' EXIT
mkdir -p "$fixture_dir/scripts" "$fixture_dir/ios"
cp "$ROOT_DIR/setup.sh" "$fixture_dir/setup.sh"
cp "$ROOT_DIR/scripts/validate_mobile_build_config.sh" "$fixture_dir/scripts/validate_mobile_build_config.sh"
chmod +x "$fixture_dir/scripts/validate_mobile_build_config.sh"
log_file="$fixture_dir/flutter.log"
(
cd "$fixture_dir"
source ./setup.sh >/dev/null
flutter() {
{
printf 'flutter'
printf ' %s' "$@"
printf '\n'
} >>"$log_file"
}
pod() {
{
printf 'pod'
printf ' %s' "$@"
printf '\n'
} >>"$log_file"
}
dart() {
{
printf 'dart'
printf ' %s' "$@"
printf '\n'
} >>"$log_file"
}
check_ios_prerequisites() { :; }
select_ios_device() { printf 'TEST-DEVICE\n'; }
run_build_ios prod
grep -F 'flutter run --flavor prod -d TEST-DEVICE --dart-define=OMI_APP_PROFILE=mobile_beta' "$log_file" >/dev/null
[[ "$(grep -F 'OMI_APP_PROFILE=mobile_beta' "$log_file" | tr ' ' '\n' | grep -c '^--dart-define=')" == 1 ]]
if run_build_ios prod --dart-define=OMI_APP_PROFILE=production; then
echo 'FAIL: wrapper accepted a conflicting profile define' >&2
exit 1
fi
# OMI_MOBILE_BUILD_MODE: debug (default) adds no mode flag; profile/release
# add exactly one. Regression: a dev debug build on a physical iPhone crashed
# at launch as soon as flutter run disconnected (iOS refuses a JIT Dart VM
# without tooling), and nothing in the wrapper offered the AOT alternative.
: >"$log_file"
run_build_ios dev
grep -F 'flutter run --flavor dev -d TEST-DEVICE --dart-define=OMI_APP_PROFILE=local_dev' "$log_file" >/dev/null
if grep -E -- '--profile|--release' "$log_file" >/dev/null; then
echo 'FAIL: default build mode added a profile/release flag' >&2
exit 1
fi
: >"$log_file"
OMI_MOBILE_BUILD_MODE=profile run_build_ios dev
grep -F 'flutter run --flavor dev -d TEST-DEVICE --dart-define=OMI_APP_PROFILE=local_dev --profile' "$log_file" >/dev/null
: >"$log_file"
OMI_MOBILE_BUILD_MODE=release run_build_android dev
grep -E '^flutter run --flavor dev .*--release$' "$log_file" >/dev/null
: >"$log_file"
if OMI_MOBILE_BUILD_MODE=bogus run_build_ios dev 2>/dev/null; then
echo 'FAIL: wrapper accepted an unknown OMI_MOBILE_BUILD_MODE' >&2
exit 1
fi
if grep -F 'flutter run' "$log_file" >/dev/null; then
echo 'FAIL: wrapper ran flutter with an unknown OMI_MOBILE_BUILD_MODE' >&2
exit 1
fi
# A debug build headed for a physical iPhone gets the untethered-crash
# warning naming the fix; an AOT build does not.
_ios_device_is_physical() { return 0; }
warning_file="$fixture_dir/warning.log"
OMI_DEV_HOST=192.168.1.2 run_build_ios dev 2>"$warning_file"
grep -F 'OMI_MOBILE_BUILD_MODE=profile' "$warning_file" >/dev/null
OMI_DEV_HOST=192.168.1.2 OMI_MOBILE_BUILD_MODE=profile run_build_ios dev 2>"$warning_file"
if grep -F 'OMI_MOBILE_BUILD_MODE=profile' "$warning_file" >/dev/null; then
echo 'FAIL: profile build still warned about the untethered debug crash' >&2
exit 1
fi
# The remedy builds the dev flavor, so a beta (prod-flavor) build must not
# be pointed at it.
run_build_ios prod 2>"$warning_file"
if grep -F 'OMI_MOBILE_BUILD_MODE=profile' "$warning_file" >/dev/null; then
echo 'FAIL: prod-flavor build was given the dev-only untethered remedy' >&2
exit 1
fi
)
echo 'mobile build wrapper injects one required profile, rejects conflicts, and honors OMI_MOBILE_BUILD_MODE'