#!/usr/bin/env bash # The android-app example on a JDK 17 host: `wai create` makes the project, the SDK's host # library is built if it is not, and the replay must put the recorded session through the # sink's Kotlin API and verify its bundle. # # bash wai/examples/android-app/test/android-app.test.sh # Needs wai on PATH, a JDK 17, Rust, and network access for Gradle and its plugins the first time. set -uo pipefail REPO=$(cd "$(dirname "$0")/../../../.." && pwd) SDK="$REPO/wai/wai-sink-android" T=$(mktemp -d) wai create "$T/app" --template android-app > /dev/null || { echo "FAIL wai create"; exit 1; } . "$SDK/scripts/env.sh" [ -n "${JAVA_HOME:-}" ] || { echo "FAIL no JDK 17"; exit 1; } if ! ls "$SDK"/core/build/native/libwai_sink_jni.* > /dev/null 2>&1; then bash "$SDK/scripts/build-native.sh" host > "$T/native.log" 2>&1 || { tail -30 "$T/native.log"; echo "FAIL the SDK's host library builds"; exit 1; } fi # The Gradle the SDK pins, fetched and checked by its own script. bash "$SDK/scripts/gradle.sh" -Pwai.sink.jvmOnly=true --version > /dev/null || { echo "FAIL the pinned Gradle"; exit 1; } G="${WAI_SINK_GRADLE_DISTS:-${GRADLE_USER_HOME:-$HOME/.gradle}/wai-sink-dists}/gradle-$WAI_SINK_GRADLE_VERSION/bin/gradle" cd "$T/app" s=0 WAI_SINK_ANDROID="$SDK" "$G" --no-daemon --console=plain -q :replay:run > run.log 2>&1 || s=$? tail -3 run.log if [ $s = 0 ] && grep -q 'the bundle verifies' run.log; then echo "ok the recorded session goes through the sink's Kotlin API, and its bundle verifies"; else echo "FAIL the replay (exit $s)"; s=1; fi exit $s