run_release_test.sh 2.14 KB
Newer Older
1 2 3 4 5
#!/usr/bin/env bash
# Copyright 2014 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

6 7 8 9 10 11 12 13 14 15 16 17 18 19
# Usage:
#
#   ./run_release_test.sh <bundletool.jar path> <adb path>
#
# In CI, this script currently depends on a modified version of bundletool because
# ddmlib which bundletool depends on does not yet support detecting QEMU emulator device
# density system properties. See https://android.googlesource.com/platform/tools/base/+/refs/heads/master/ddmlib/src/main/java/com/android/ddmlib/IDevice.java#46
#
# The modified bundletool which waives the density requirement is at:
# https://chrome-infra-packages.appspot.com/p/flutter/android/bundletool/+/vFt1jA0cUeZLmUCVR5NG2JVB-SgJ18GH_pVYKMOlfUIC

bundletool_jar_path=$1
adb_path=$2

20
# Store the time to prevent capturing logs from previous runs.
21
script_start_time=$($adb_path shell 'date +"%m-%d %H:%M:%S.0"')
22

23
$adb_path uninstall "io.flutter.integration.deferred_components_test"
24 25 26 27 28 29

rm -f build/app/outputs/bundle/release/app-release.apks
rm -f build/app/outputs/bundle/release/run_logcat.log

flutter build appbundle

30
java -jar $bundletool_jar_path build-apks --bundle=build/app/outputs/bundle/release/app-release.aab --output=build/app/outputs/bundle/release/app-release.apks --local-testing --ks android/testing-keystore.jks --ks-key-alias testing_key --ks-pass pass:012345
31
java -jar $bundletool_jar_path install-apks --apks=build/app/outputs/bundle/release/app-release.apks
32

33
$adb_path shell "
34 35 36
am start -n io.flutter.integration.deferred_components_test/.MainActivity
exit
"
37
run_start_time_seconds=$(date +%s)
38 39 40 41 42
while read LOGLINE
do
    if [[ "${LOGLINE}" == *"Running deferred code"* ]]; then
        echo "Found ${LOGLINE}"
        echo "All tests passed."
43
        pkill -P $$
44 45 46 47
        exit 0
    fi
    # Timeout if expected log not found
    current_time=$(date +%s)
48
    if [[ $((current_time - run_start_time_seconds)) -ge 300 ]]; then
49
        echo "Failure: Timed out, deferred component did not load."
50
        pkill -P $$
51 52
        exit 1
    fi
53
done < <($adb_path logcat -T "$script_start_time")
54

55 56
echo "Failure: Deferred component did not load."
exit 1