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.
instrumentation tests are executed with BUCK
Summary:Added ability to run instrumentation tests with BUCK. This change uses BUCK to build and run instrumentation tests facebook style. The gains are that we can execute the same tests internally at FB and in OSS. Also running tests not via graddle:connect command is 1.5 minutes faster. I'll keep keep an eye on stability Gradle and BUCK builds for a while. Closes facebook#6176 Differential Revision: D2999878 Pulled By: bestander fb-gh-sync-id: d715ba231769e57100685a1256f2e530c589921c shipit-source-id: d715ba231769e57100685a1256f2e530c589921c
- Loading branch information
Showing
9 changed files
with
123 additions
and
83 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
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 was deleted.
Oops, something went wrong.
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,5 @@ | ||
android_resource( | ||
name = 'assets', | ||
assets = '.', | ||
visibility = ['PUBLIC'], | ||
) |
24 changes: 24 additions & 0 deletions
24
ReactAndroid/src/androidTest/buck-runner/AndroidManifest.xml
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,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.facebook.react.tests"> | ||
|
||
<supports-screens android:anyDensity="true" /> | ||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
<!-- needed for screenshot tests --> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
|
||
<application> | ||
<uses-library android:name="android.test.runner" /> | ||
<activity | ||
android:name="com.facebook.react.testing.ReactAppTestActivity" | ||
android:theme="@style/Theme.ReactNative.AppCompat.Light.NoActionBar.FullScreen"> | ||
</activity> | ||
</application> | ||
|
||
<instrumentation | ||
android:name="android.support.test.runner.AndroidJUnitRunner" | ||
android:targetPackage="com.facebook.react.tests" | ||
android:label="Buck runs instrumentation tests"/> | ||
|
||
</manifest> |
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,23 @@ | ||
include_defs('//ReactAndroid/DEFS') | ||
|
||
# We are running instrumentation tests in simple mode: app code and instrumentation are in the same APK | ||
# Currently you need to run these commands to execute tests: | ||
# | ||
# node local-cli/cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/assets/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js | ||
# gradle :ReactAndroid:packageReactNdkLibsForBuck | ||
# buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests | ||
# ./scripts/run-android-instrumentation-tests.sh com.facebook.react.tests | ||
android_binary( | ||
name = 'instrumentation-tests', | ||
manifest = 'AndroidManifest.xml', | ||
keystore = '//keystores:debug', | ||
deps = [ | ||
react_native_integration_tests_target('java/com/facebook/react/tests:tests'), | ||
react_native_integration_tests_target('assets:assets'), | ||
react_native_target('jni/prebuilt:reactnative-libs'), | ||
react_native_target('jni/prebuilt:android-jsc'), | ||
react_native_dep('libraries/soloader/java/com/facebook/soloader:soloader'), | ||
react_native_target('java/com/facebook/react/devsupport:devsupport'), | ||
], | ||
) | ||
|
This file was deleted.
Oops, something went wrong.
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,52 @@ | ||
#!/bin/bash | ||
|
||
export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$PATH" | ||
|
||
# clear the logs | ||
adb logcat -c | ||
|
||
# run tests and check output | ||
python - $1 << END | ||
import re | ||
import subprocess as sp | ||
import sys | ||
import threading | ||
import time | ||
done = False | ||
test_app = sys.argv[1] | ||
def update(): | ||
# prevent CircleCI from killing the process for inactivity | ||
while not done: | ||
time.sleep(5) | ||
print "Running in background. Waiting for 'adb' command reponse..." | ||
t = threading.Thread(target=update) | ||
t.dameon = True | ||
t.start() | ||
def run(): | ||
sp.Popen(['adb', 'wait-for-device']).communicate() | ||
p = sp.Popen('adb shell am instrument -w %s/android.support.test.runner.AndroidJUnitRunner' % test_app, | ||
shell=True, stdout=sp.PIPE, stderr=sp.PIPE, stdin=sp.PIPE) | ||
return p.communicate() | ||
success = re.compile(r'OK \(\d+ tests\)') | ||
stdout, stderr = run() | ||
done = True | ||
print stderr | ||
print stdout | ||
if success.search(stderr + stdout): | ||
sys.exit(0) | ||
else: | ||
# dump the logs | ||
sp.Popen(['adb', 'logcat', '-d']).communicate() | ||
sys.exit(1) # make sure we fail if the test failed | ||
END | ||
|
||
RETVAL=$? | ||
|
||
exit $RETVAL |