mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 09:35:48 +00:00
f827f7b79a
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 https://github.com/facebook/react-native/pull/6176 Differential Revision: D2999878 Pulled By: bestander fb-gh-sync-id: d715ba231769e57100685a1256f2e530c589921c shipit-source-id: d715ba231769e57100685a1256f2e530c589921c
53 lines
1.1 KiB
Bash
Executable File
53 lines
1.1 KiB
Bash
Executable File
#!/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
|