Skip to content

Commit f3ded3c

Browse files
committed
Normalize indentation to spaces in run-android-tests.sh
1 parent 549e826 commit f3ded3c

File tree

1 file changed

+80
-80
lines changed

1 file changed

+80
-80
lines changed

scripts/run-android-tests.sh

Lines changed: 80 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ abort_on_error() {
4646

4747
# Exit with code 1 and message
4848
abort() {
49-
error "$1. Aborting."
50-
exit 1
49+
error "$1. Aborting."
50+
exit 1
5151
}
5252

5353
# Parse command line options
@@ -96,7 +96,7 @@ echo ""
9696
highlight "Installing APK..."
9797
adb kill-server 2>/dev/null
9898
for i in $(seq 1 $INSTALL_RETRIES); do
99-
msg "Waiting for Android device..."
99+
msg "Waiting for Android device..."
100100
if adb wait-for-device && adb install -r ./exports/android.apk; then
101101
break
102102
elif [ $i -eq $INSTALL_RETRIES ]; then
@@ -114,95 +114,95 @@ fi
114114

115115
# Run tests on device
116116
run_tests() {
117-
local tests=$1
118-
119-
# Wait for device lockscreen to be unlocked
120-
for i in $(seq 1 $LOCKSCREEN_RETRIES); do
121-
local lock_state=$(adb shell dumpsys window | grep mDreamingLockscreen)
122-
if echo "$lock_state" | grep -q "mDreamingLockscreen=false"; then
123-
msg "Device lockscreen is unlocked and ready"
124-
break
125-
elif [ $i -eq $LOCKSCREEN_RETRIES ]; then
126-
abort "Device lockscreen still active after $LOCKSCREEN_RETRIES attempts"
127-
fi
128-
warning "Device lockscreen is active, please unlock it..."
129-
sleep 2
130-
done
131-
132-
highlight "Launching APK..."
133-
for i in $(seq 1 $LAUNCH_RETRIES); do
134-
adb shell am start -n io.sentry.godot.project/com.godot.game.GodotApp --es SENTRY_TEST 1 --es SENTRY_TEST_INCLUDE "$tests"
135-
if [ $? -eq 0 ]; then
136-
# Success
137-
break
138-
elif [ $i -eq $LAUNCH_RETRIES ]; then
139-
abort "Failed to launch APK after $LAUNCH_RETRIES attempts"
140-
else
141-
error "Launch attempt $i failed, retrying..."
142-
sleep 1
143-
fi
144-
done
145-
146-
# Get PID
147-
local pid=""
148-
for i in $(seq 1 $PID_RETRIES); do
149-
pid=$(adb shell pidof io.sentry.godot.project)
150-
if [ -n "$pid" ]; then
151-
break
152-
fi
153-
sleep 1
154-
done
155-
156-
if [ -z "$pid" ]; then
157-
error "Failed to get PID of the app"
158-
return 3
159-
fi
160-
161-
# Start logcat, streaming to stdout and monitoring for completion
162-
highlight "Reading logs..."
163-
164-
local exit_code=1 # Default general failure
165-
local clean_exit=0
166-
167-
# Process logcat output
168-
while IFS= read -r line; do
169-
echo "$line"
170-
171-
# Check for test run completion
172-
if echo "$line" | grep -q ">>> Test run complete with code:"; then
173-
exit_code=$(echo "$line" | sed 's/.*>>> Test run complete with code: \([0-9]*\).*/\1/')
174-
# Not quitting yet -- waiting for Godot to terminate.
175-
fi
176-
177-
# Check Godot exit condition
178-
if echo "$line" | grep -q "OnGodotTerminating"; then
179-
clean_exit=1
117+
local tests=$1
118+
119+
# Wait for device lockscreen to be unlocked
120+
for i in $(seq 1 $LOCKSCREEN_RETRIES); do
121+
local lock_state=$(adb shell dumpsys window | grep mDreamingLockscreen)
122+
if echo "$lock_state" | grep -q "mDreamingLockscreen=false"; then
123+
msg "Device lockscreen is unlocked and ready"
124+
break
125+
elif [ $i -eq $LOCKSCREEN_RETRIES ]; then
126+
abort "Device lockscreen still active after $LOCKSCREEN_RETRIES attempts"
127+
fi
128+
warning "Device lockscreen is active, please unlock it..."
129+
sleep 2
130+
done
131+
132+
highlight "Launching APK..."
133+
for i in $(seq 1 $LAUNCH_RETRIES); do
134+
adb shell am start -n io.sentry.godot.project/com.godot.game.GodotApp --es SENTRY_TEST 1 --es SENTRY_TEST_INCLUDE "$tests"
135+
if [ $? -eq 0 ]; then
136+
# Success
137+
break
138+
elif [ $i -eq $LAUNCH_RETRIES ]; then
139+
abort "Failed to launch APK after $LAUNCH_RETRIES attempts"
140+
else
141+
error "Launch attempt $i failed, retrying..."
142+
sleep 1
143+
fi
144+
done
145+
146+
# Get PID
147+
local pid=""
148+
for i in $(seq 1 $PID_RETRIES); do
149+
pid=$(adb shell pidof io.sentry.godot.project)
150+
if [ -n "$pid" ]; then
151+
break
152+
fi
153+
sleep 1
154+
done
155+
156+
if [ -z "$pid" ]; then
157+
error "Failed to get PID of the app"
158+
return 3
159+
fi
160+
161+
# Start logcat, streaming to stdout and monitoring for completion
162+
highlight "Reading logs..."
163+
164+
local exit_code=1 # Default general failure
165+
local clean_exit=0
166+
167+
# Process logcat output
168+
while IFS= read -r line; do
169+
echo "$line"
170+
171+
# Check for test run completion
172+
if echo "$line" | grep -q ">>> Test run complete with code:"; then
173+
exit_code=$(echo "$line" | sed 's/.*>>> Test run complete with code: \([0-9]*\).*/\1/')
174+
# Not quitting yet -- waiting for Godot to terminate.
175+
fi
176+
177+
# Check Godot exit condition
178+
if echo "$line" | grep -q "OnGodotTerminating"; then
179+
clean_exit=1
180180
timeout 2 cat || true # Continue reading for a bit in case there are remaining logs
181-
break
182-
fi
183-
done < <(timeout $TEST_TIMEOUT adb logcat --pid=$pid -s $LOGCAT_FILTERS)
181+
break
182+
fi
183+
done < <(timeout $TEST_TIMEOUT adb logcat --pid=$pid -s $LOGCAT_FILTERS)
184184

185-
# Check if never finished
186-
if [ $exit_code -eq 1 ]; then
187-
error "Test run was interrupted or failed to complete properly!"
188-
fi
185+
# Check if never finished
186+
if [ $exit_code -eq 1 ]; then
187+
error "Test run was interrupted or failed to complete properly!"
188+
fi
189189

190190
# Check if process still running
191191
local current_pid=$(adb shell pidof io.sentry.godot.project 2>/dev/null || echo "")
192192
if [ -n "$current_pid" ]; then
193-
if [ $exit_code -eq 0 ]; then
194-
exit_code=88
195-
fi
193+
if [ $exit_code -eq 0 ]; then
194+
exit_code=88
195+
fi
196196
error "Godot app process still running"
197197
adb shell am force-stop io.sentry.godot.project
198198
# Check if not exited cleanly
199-
elif [ $clean_exit -eq 0 ]; then
200-
warning "Unclean exit detected. Godot possibly crashed."
199+
elif [ $clean_exit -eq 0 ]; then
200+
warning "Unclean exit detected. Godot possibly crashed."
201201
fi
202202

203-
msg "Test run finished with code: $exit_code"
203+
msg "Test run finished with code: $exit_code"
204204

205-
return $exit_code
205+
return $exit_code
206206
}
207207

208208

0 commit comments

Comments
 (0)