Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/androidapp-road-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ runs:
echo "==> Starting Detox tests at $(date -u +%H:%M:%S)"
bash apps/brownfield-example-shared-tests/scripts/prepare-android-emulator-for-detox.sh
cd apps/AndroidApp
yarn "$ANDROIDAPP_E2E_TEST_SCRIPT"
bash apps/brownfield-example-shared-tests/scripts/run-with-android-logcat.sh apps/AndroidApp/e2e-artifacts/logcat-full.txt yarn "$ANDROIDAPP_E2E_TEST_SCRIPT"
env:
ANDROIDAPP_E2E_TEST_SCRIPT: ${{ env.ANDROIDAPP_E2E_TEST_SCRIPT }}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# Runs a command while recording the full device logcat host-side (CI + local).
# Detox's own logcat artifact is filtered to the app pid and recorded on-device
# with `logcat -f`, which is killed before it flushes, so it drops the last few
# seconds before a failure and never contains system_server lines (ANRs).
#
# Usage: run-with-android-logcat.sh <output-file> <command> [args...]
set -uo pipefail

if (( $# < 2 )); then
echo "usage: $0 <output-file> <command> [args...]" >&2
exit 2
fi

LOGCAT_FILE="$1"
shift

ADB=(adb)
if [[ -n "${ANDROID_SERIAL:-}" ]]; then
ADB=(adb -s "${ANDROID_SERIAL}")
fi

mkdir -p "$(dirname "${LOGCAT_FILE}")"
"${ADB[@]}" logcat -v threadtime -b main,system,crash >"${LOGCAT_FILE}" 2>&1 &
logcat_pid=$!
echo "==> Recording device logcat to ${LOGCAT_FILE} (pid ${logcat_pid})"

"$@"
status=$?

kill "${logcat_pid}" 2>/dev/null || true
wait "${logcat_pid}" 2>/dev/null || true

exit "${status}"
Loading