Cleaned up

This commit is contained in:
butomo1989 2018-06-22 01:16:40 +02:00
parent 2922e3ba92
commit 54d5365907
4 changed files with 26 additions and 20 deletions

View file

@ -10,8 +10,9 @@ if [ ! -f "$GENY_TEMPLATE" ]; then
exit 1 exit 1
fi fi
contents=$(cat $GENY_TEMPLATE)
getAbort() { getAbort() {
if [ "$GENYMOTION" = true ]; then
contents=$(cat $GENY_TEMPLATE)
echo "ABORT SIGNAL detected! Stopping all created emulators..." echo "ABORT SIGNAL detected! Stopping all created emulators..."
for row in $(echo "${contents}" | jq -r '.[] | @base64'); do for row in $(echo "${contents}" | jq -r '.[] | @base64'); do
get_value() { get_value() {
@ -21,6 +22,7 @@ getAbort() {
gmtool --cloud admin stopdisposable $(get_value '.device') gmtool --cloud admin stopdisposable $(get_value '.device')
done done
echo "Done" echo "Done"
fi
} }
trap 'getAbort; exit' EXIT trap 'getAbort; exit' EXIT

View file

@ -190,13 +190,17 @@ def run():
prepare_avd(device, avd_name) prepare_avd(device, avd_name)
logger.info('Run emulator...') logger.info('Run emulator...')
dp_size = os.getenv('DATAPARTITION', '550m')
with open("/root/android_emulator/config.ini", "a") as cfg:
cfg.write('\ndisk.dataPartition.size={dp}'.format(dp=dp_size))
cmd = 'emulator -avd {name} -gpu off -verbose'.format(name=avd_name) cmd = 'emulator -avd {name} -gpu off -verbose'.format(name=avd_name)
subprocess.Popen(cmd.split())
appium = convert_str_to_bool(str(os.getenv('APPIUM', False))) appium = convert_str_to_bool(str(os.getenv('APPIUM', False)))
if appium: if appium:
subprocess.Popen(cmd.split())
logger.info('Run appium server...') logger.info('Run appium server...')
appium_run(avd_name) appium_run(avd_name)
else:
result = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE).communicate()
if __name__ == '__main__': if __name__ == '__main__':
run() run()

View file

@ -4,9 +4,9 @@ if [ -z "$GENY_TEMPLATE" ]; then
GENY_TEMPLATE="/root/tmp/devices.json" GENY_TEMPLATE="/root/tmp/devices.json"
fi fi
function prepare_geny_cloud() {
contents=$(cat $GENY_TEMPLATE) contents=$(cat $GENY_TEMPLATE)
function prepare_geny_cloud() {
# Register # Register
gmtool config username="${USER}" password="${PASS}" gmtool config username="${USER}" password="${PASS}"
gmtool license register "${LICENSE}" gmtool license register "${LICENSE}"
@ -49,10 +49,10 @@ function run_appium() {
$CMD $CMD
} }
if [[ $REAL_DEVICE = true ]]; then if [ "$REAL_DEVICE" = true ]; then
echo "Using real device" echo "Using real device"
run_appium run_appium
elif [[ $GENYMOTION = true ]]; then elif [ "$GENYMOTION" = true ]; then
echo "Using Genymotion" echo "Using Genymotion"
prepare_geny_cloud prepare_geny_cloud
run_appium run_appium

View file

@ -16,12 +16,12 @@ function auto_record() {
echo "Auto record: $AUTO_RECORD" echo "Auto record: $AUTO_RECORD"
sleep 6 sleep 6
while [ $AUTO_RECORD == true ]; do while [ "$AUTO_RECORD" = true ]; do
# Check if there is test running # Check if there is test running
no_test=true no_test=true
while $no_test; do while $no_test; do
task=$(curl -s localhost:4723/wd/hub/sessions | jq -r '.value') task=$(curl -s localhost:4723/wd/hub/sessions | jq -r '.value')
if [ "$task" == "" ] || [ "$task" == "[]" ]; then if [ "$task" = "" ] || [ "$task" = "[]" ]; then
sleep .5 sleep .5
else else
start & start &
@ -30,9 +30,9 @@ function auto_record() {
done done
# Check if test is finished # Check if test is finished
while [ $no_test == false ]; do while [ $no_test = false ]; do
task=$(curl -s localhost:4723/wd/hub/sessions | jq -r '.value') task=$(curl -s localhost:4723/wd/hub/sessions | jq -r '.value')
if [ "$task" == "" ] || [ "$task" == "[]" ]; then if [ "$task" = "" ] || [ "$task" = "[]" ]; then
stop stop
no_test=true no_test=true
else else