forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·73 lines (62 loc) · 1.91 KB
/
run.sh
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
#!/bin/bash -xe
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# Parse command-line arguments
hermes_npm_package=
while (( "$#" )); do
case $1 in
--hermes-npm-package)
shift || (
echo "Missing NPM package argument"
exit 1
)
hermes_npm_package="$1"
;;
*)
echo "Unsupported argument: $1"
exit 1
;;
esac
shift
done
# Clone a fresh copy of RN master
git clone --depth=1 https://github.com/facebook/react-native
cd react-native
npm install
# Install new Hermes NPM.
npm install "$hermes_npm_package"
# Modify RN Tester app to print a log message at start-up
echo "console.log('Using Hermes: ' + (global.HermesInternal != null));" >> packages/rn-tester/js/RNTesterApp.android.js
# Wait for emulator to boot
adb wait-for-device
# Build and install release app
./gradlew :packages:rn-tester:android:app:installHermesRelease
cd ..
# Start screen recording for debug
adb shell screenrecord /sdcard/screencap.mp4 &
adb_screen_record_pid=$!
function stashScreenCapture() {
local exit_code=$?
adb shell killall -s INT screenrecord
wait $adb_screen_record_pid || true
adb pull /sdcard/screencap.mp4 /tmp/hermes/output/screencap.mp4
exit "$exit_code"
}
trap stashScreenCapture EXIT
# Start app + wait to see relevant log message
adb logcat -c || true # This sometimes fails to clear the "main" log. This is benign.
adb shell am start com.facebook.react.uiapp/.RNTesterActivity
SECONDS=0
until grep 'Using Hermes: true' <(adb logcat -d -s ReactNativeJS:I) ; do
if ((SECONDS > 30 )) ; then
echo "Did not see correct log message within 30s"
adb logcat -d > /tmp/hermes/output/adblog.txt
tar cfz /tmp/hermes/output/project.tar.gz react-native
exit 1
fi
sleep 2
done
echo "Test passed: Hermes in use in RNTester App"
exit 0