forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: The goal of this pull request is to make it easier for contributors to run Android tests locally, specifically the unit tests and integration tests. I added a bunch of checks to the local testing scripts that will warn you if your environment is misconfigured, and tell you how to fix it. I also updated the testing docs, so that the regular "Testing" page should be a decent resource to point people to when you are telling them "hey this pull request needs a test." Just Android, though, I haven't gotten to the iOS parts yet. I also disabled a couple tests that seemed quite flaky while running on a local machine, and don't seem to be providing much value. In particular, the `TestId` test just hangs on my emulator a lot and has been flaky on CI in the past, so I removed about half of its test cases to make the sample app smaller. The testMetions test appears to be dependent on screen size so I commented it out. Closes facebook#11442 Differential Revision: D4323569 Pulled By: bestander fbshipit-source-id: 9c869f3915d5c7cee438615f37986b07ab251f8c
- Loading branch information
Showing
11 changed files
with
249 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,3 +53,4 @@ node_modules | |
|
||
# Test generated files | ||
/ReactAndroid/src/androidTest/assets/AndroidTestBundle.js | ||
*.js.meta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
# Runs an Android emulator locally. | ||
# If there already is a running emulator, this just uses that. | ||
# The only reason to use this config is that it represents a known-good | ||
# virtual device configuration. | ||
# This is useful for running integration tests on a local machine. | ||
# TODO: make continuous integration use the precise same setup | ||
|
||
STATE=`adb get-state` | ||
|
||
if [ -n "$STATE" ]; then | ||
echo "An emulator is already running." | ||
exit 1 | ||
fi | ||
|
||
echo "Creating virtual device..." | ||
echo no | android create avd -n testAVD -f -t android-23 --abi default/x86 | ||
emulator -avd testAVD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
# This script validates that the Android environment is set up to run | ||
# tests on a device or emulator (as opposed to a plain Java environment). | ||
|
||
# This requires that the Android NDK is set up correctly and it also | ||
# requires that you are currently either running an emulator or have | ||
# an Android device plugged in. | ||
|
||
if [ -z "$ANDROID_NDK" ]; then | ||
echo "Error: \$ANDROID_NDK is not configured." | ||
echo "You must first install the Android NDK and then set \$ANDROID_NDK." | ||
echo "If you already installed the Android SDK, well, the NDK is a different thing that you also need to install." | ||
echo "See https://facebook.github.io/react-native/docs/android-building-from-source.html for instructions." | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$(adb get-state)" ]; then | ||
echo "Error: you must either run an emulator or connect a device." | ||
echo "You can check what devices are running with 'adb get-state'." | ||
echo "You can run scripts/run-android-emulator.sh to get a known-good emulator config." | ||
exit 1 | ||
fi | ||
|
||
while : | ||
do | ||
BOOTANIM=`adb -e shell getprop init.svc.bootanim` | ||
if [ -n `echo $BOOTANIM | grep stopped` ]; then | ||
break | ||
fi | ||
echo "Waiting for the emulator to finish booting..." | ||
sleep 3 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
# This script validates that the Android SDK is installed correctly. | ||
# This means setting ANDROID_HOME and adding its subdirectories to PATH. | ||
# If the Android SDK is not installed correctly, this script exits | ||
# with an error and a helpful message is printed. | ||
|
||
if [ -z "$ANDROID_HOME" ]; then | ||
echo "Error: \$ANDROID_HOME is not configured." | ||
echo "You must first install the Android SDK and then set \$ANDROID_HOME." | ||
echo "If you already installed the Android SDK, the problem is that you need to export ANDROID_HOME from your .bashrc or equivalent." | ||
echo "See https://facebook.github.io/react-native/docs/getting-started.html for instructions." | ||
exit 1 | ||
fi | ||
|
||
if [ ! -d "$ANDROID_HOME" ]; then | ||
echo "Error: \$ANDROID_HOME = $ANDROID_HOME but that directory does not exist." | ||
echo "It is possible that you installed then uninstalled the Android SDK." | ||
echo "In that case, you should reinstall it." | ||
echo "See https://facebook.github.io/react-native/docs/getting-started.html for instructions." | ||
exit 1 | ||
fi | ||
|
||
if [ ! -e "$ANDROID_HOME/tools/emulator" ]; then | ||
echo "Error: could not find an emulator at \$ANDROID_HOME/tools/emulator." | ||
echo "Specifically, $ANDROID_HOME/tools/emulator does not exist." | ||
echo "This indicates something is borked with your Android SDK install." | ||
echo "One possibility is that you have \$ANDROID_HOME set to the wrong value." | ||
echo "If that seems correct, you might want to try reinstalling the Android SDK." | ||
echo "See https://facebook.github.io/react-native/docs/getting-started.html for instructions." | ||
exit 1 | ||
fi | ||
|
||
if [ -z `which emulator` ]; then | ||
echo "Error: could not find 'emulator'. Specifically, 'which emulator' was empty." | ||
echo "However, the emulator seems to be installed at \$ANDROID_HOME/tools/emulator already." | ||
echo "This means that the problem is that you are not adding \$ANDROID_HOME/tools to your \$PATH." | ||
echo "You should do that, and then rerun this command." | ||
echo "Sorry for not fixing this automatically - we just didn't want to mess with your \$PATH automatically because that can break things." | ||
exit 1 | ||
fi | ||
|
||
if [ -z `which adb` ]; then | ||
echo "Error: could not find 'adb'. Specifically, 'which adb' was empty." | ||
echo "This indicates something is borked with your Android SDK install." | ||
echo "The most likely problem is that you are not adding \$ANDROID_HOME/platform-tools to your \$PATH." | ||
echo "If all else fails, try reinstalling the Android SDK." | ||
echo "See https://facebook.github.io/react-native/docs/getting-started.html for instructions." | ||
exit 1 | ||
fi | ||
|
Oops, something went wrong.