mirror of https://github.com/axmolengine/axmol.git
Merge pull request #4769 from heliclei/develop
update exception catch clause
This commit is contained in:
commit
d8186a1d3c
|
@ -1,839 +0,0 @@
|
|||
# Imports the monkeyrunner modules used by this program
|
||||
import sys
|
||||
import subprocess
|
||||
import random
|
||||
import os
|
||||
from com.android.monkeyrunner import MonkeyRunner as mr
|
||||
from com.android.monkeyrunner import MonkeyDevice as md
|
||||
from com.android.monkeyrunner import MonkeyImage as mi
|
||||
|
||||
#Define test functions.
|
||||
def common_test(a,b,c):
|
||||
for i in range(a,b):
|
||||
mr.sleep(c)
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
|
||||
def random_click(a,b,c):
|
||||
for i in range(a,b):
|
||||
touch_x = random.randint(0,s_width/20*19)
|
||||
touch_y = random.randint(0,s_height)
|
||||
device.touch(touch_x,touch_y,'DOWN_AND_UP')
|
||||
mr.sleep(c)
|
||||
|
||||
def random_drag(a,b,c):
|
||||
for i in range(a,b):
|
||||
drag_x = random.randint(0,s_width/20*18)
|
||||
drag_y = random.randint(0,s_height)
|
||||
drop_x = random.randint(0,s_width/20*18)
|
||||
drop_y = random.randint(0,s_height)
|
||||
device.drag((drag_x,drag_y),(drop_x,drop_y))
|
||||
|
||||
def check_activity(a):
|
||||
print "get running activities..."
|
||||
subprocess.call("adb shell ps > running_activities.txt",shell=True)
|
||||
#subprocess.call("adb pull running_activities.txt",shell=True)
|
||||
|
||||
f1 = open('running_activities.txt')
|
||||
while True:
|
||||
line = f1.readline()
|
||||
if not line.find('org.cocos2dx.testcpp') == -1:
|
||||
break;
|
||||
if len(line) == 0:
|
||||
str = "TestCpp wasn't running,maybe it has crashes,please checkout:"
|
||||
f2 = file('monkeyrunner_Error.log','w')
|
||||
print "get logcat information..."
|
||||
f2.write(str)
|
||||
f2.write(a)
|
||||
#subprocess.call("adb shell logcat | $ANDROID_NDK/ndk-stack -sym $ANDROID_HOME/tools/obj/local/armeabi > monkeyrunner_Error.log",shell=True);
|
||||
f2.close()
|
||||
sys.exit(1)
|
||||
print "subprocess has finished!"
|
||||
f1.close()
|
||||
|
||||
# Connects to the current device, returning a MonkeyDevice object
|
||||
device = mr.waitForConnection()
|
||||
if not device:
|
||||
print >> sys.stderr,"fail"
|
||||
check_activity("is there a device connect to the testing machine.")
|
||||
sys.exit(1)
|
||||
else:
|
||||
print "Start......"
|
||||
|
||||
# Installs the Android package. Notice that this method returns a boolean, so you can test
|
||||
# to see if the installation worked.
|
||||
if device.installPackage(sys.argv[1]):
|
||||
print "Install success!"
|
||||
else:
|
||||
print "Install failed,please make sure you have put apk in the right places"
|
||||
check_activity("you have put apk in the right place")
|
||||
sys.exit(1)
|
||||
|
||||
# sets a variable with the package's internal name
|
||||
package = 'org.cocos2dx.testcpp'
|
||||
print "Package name: "+ package
|
||||
|
||||
# sets a variable with the name of an Activity in the package
|
||||
activity = 'org.cocos2dx.testcpp.TestCpp'
|
||||
print "Activity name: " + activity
|
||||
|
||||
# sets the name of the component to start
|
||||
runComponent = package + '/' + activity
|
||||
|
||||
# Runs the component
|
||||
device.startActivity(component=runComponent)
|
||||
print "Running activity......"
|
||||
|
||||
#Set Screen's Length and Width
|
||||
s_width = 800
|
||||
s_height = 480
|
||||
|
||||
#Set boolean variable of Acticity_IsRunning
|
||||
Acticity_IsRunning = 1
|
||||
|
||||
#----------------ActionsTest----------------
|
||||
print "Run ActionsTest"
|
||||
mr.sleep(2.0)
|
||||
device.touch(s_width/2,s_height/48*5,'DOWN_AND_UP')
|
||||
#Last Test
|
||||
#device.touch(s_width/8*3,s_height/16*15,'DOWN_AND_UP')
|
||||
common_test(1,28,1.0)
|
||||
common_test(1,3,3.0)
|
||||
common_test(1,6,1.0)
|
||||
mr.sleep(1.0)
|
||||
#Next Test
|
||||
#device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
print "ActionsTest finished!"
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("ActionsTest")
|
||||
|
||||
#----------------TransitionsTest----------------
|
||||
print "Run TransitionsTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/6,'DOWN_AND_UP')
|
||||
common_test(1,27,1.0)
|
||||
mr.sleep(1.0)
|
||||
print "TransitionsTest finished!"
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("TransitionsTest")
|
||||
|
||||
#----------------ActionsProgressTest----------------
|
||||
print "Run ActionsProgressTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/48*11,'DOWN_AND_UP')
|
||||
common_test(1,8,2.0)
|
||||
mr.sleep(1.0)
|
||||
print "ActionsProgressTest finished!"
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("ActionsProgressTest")
|
||||
|
||||
#----------------EffectsTest----------------
|
||||
mr.sleep(1.0)
|
||||
print "Run EffectsTest"
|
||||
device.touch(s_width/2,s_height/3,'DOWN_AND_UP')
|
||||
common_test(1,22,3.0)
|
||||
mr.sleep(1.0)
|
||||
print "EffectsTest finished!"
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("EffectsTest")
|
||||
|
||||
#----------------ClickAndMoveTest----------------
|
||||
print "Run ClickAndMoveTest"
|
||||
mr.sleep(5.0)
|
||||
device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
random_click(1,11,2.0)
|
||||
mr.sleep(1.0)
|
||||
random_click(1,101,0.0)
|
||||
mr.sleep(1.0)
|
||||
print "ClickAndMoveTest finished!"
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("ClickAndMoveTest")
|
||||
|
||||
#----------------RotateWorldTest----------------
|
||||
print "Run RotateWorldTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/2,'DOWN_AND_UP')
|
||||
mr.sleep(5.0)
|
||||
print "RotateWorldTest finished!"
|
||||
mr.sleep(3.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("RotateWorldTest")
|
||||
|
||||
#----------------ParticleTest----------------
|
||||
print "Run ParticleTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/12*7,'DOWN_AND_UP')
|
||||
common_test(1,43,2.0)
|
||||
print "ParticleTest finished!"
|
||||
mr.sleep(2.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("ParticleTest")
|
||||
|
||||
#----------------ActionsEaseTest----------------
|
||||
print "Run ActionsEaseTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/3*2,'DOWN_AND_UP')
|
||||
mr.sleep(2.0)
|
||||
common_test(1,14,2.0)
|
||||
print "ActionsEaseTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("ActionsEaseTest")
|
||||
|
||||
#----------------MotionStreakTest----------------
|
||||
print "Run MontionStreakTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/4*3,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
random_drag(1,11,0.5)
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/4*3,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
random_drag(1,11,0.5)
|
||||
print "MontionStreakTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("MontionStreakTest")
|
||||
|
||||
#----------------DrawPrimitivesTest----------------
|
||||
print "Run DrawprimitivesTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/6*5,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
print "DrawPrimitivesTest finished!"
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("DrawPrimitivesTest")
|
||||
|
||||
#----------------NodeTest----------------
|
||||
print "Run NodeTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/12*11,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
common_test(1,14,1.0)
|
||||
print "NodeTest finished!"
|
||||
mr.sleep(3.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("NodeTest")
|
||||
mr.sleep(1.0)
|
||||
device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
|
||||
|
||||
#----------------TouchesTest----------------
|
||||
print "Run TouchesTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/12,'DOWN_AND_UP')
|
||||
print "TouchesTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("TouchesTest")
|
||||
|
||||
#----------------MenuTest----------------
|
||||
print "Run MenuTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/6,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
#Atlas Sprite
|
||||
device.touch(s_width/2,s_height/48*13,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
#Play
|
||||
device.touch(s_width/8*3,s_height/24*11,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
#items
|
||||
device.touch(s_width/2,s_height/24*11,'DOWN_AND_UP')
|
||||
device.touch(s_width/2,s_height/24*11,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
#Configuration
|
||||
device.touch(400,260,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
print "MenuTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("MenuTest")
|
||||
|
||||
#----------------ActionManagerTest----------------
|
||||
print "Run ActionManagerTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/48*11,'DOWN_AND_UP')
|
||||
common_test(1,5,3.0)
|
||||
print "ActionManagerTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("ActionManagerTest")
|
||||
|
||||
#----------------LayerTest----------------
|
||||
print "Run LayerTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/3,'DOWN_AND_UP')
|
||||
random_drag(1,11,0.5)
|
||||
mr.sleep(1.0)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
mr.sleep(2.0)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
mr.sleep(2.0)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
random_drag(1,11,0.5)
|
||||
print "LayerTest finished!"
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("LayerTest")
|
||||
|
||||
#----------------SceneTest----------------
|
||||
print "Run SceneTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/12*7,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/2,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
device.touch(s_width/2,s_height/2,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
device.touch(s_width/2,s_height/2,'DOWN_AND_UP')
|
||||
print "SceneTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("SceneTest")
|
||||
|
||||
#----------------ParallaxTest----------------
|
||||
print "Run ParallaxTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/2,'DOWN_AND_UP')
|
||||
mr.sleep(5.0)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
random_drag(1,11,0.5)
|
||||
print "ParallaxTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("ParallaxTest")
|
||||
|
||||
#----------------TileMapTest----------------
|
||||
print "Run TileMapTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/12*7,'DOWN_AND_UP')
|
||||
mr.sleep(2.0)
|
||||
for TileMap_i in range(1,20):
|
||||
random_drag(1,5,2.0)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
|
||||
mr.sleep(2.0)
|
||||
print "TileMapTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("TileMapTest")
|
||||
|
||||
#----------------IntervalTest----------------
|
||||
print "Run IntervalTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/3*2,'DOWN_AND_UP')
|
||||
mr.sleep(3.0)
|
||||
device.touch(s_width/2,s_height/12,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/12,'DOWN_AND_UP')
|
||||
print "IntervalTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("IntervalTest")
|
||||
|
||||
#----------------ChipmunkAccelTouchTest----------------
|
||||
print "Run ChipmunkAccelTouchTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/4*3,'DOWN_AND_UP')
|
||||
random_click(1,21,0.1)
|
||||
print "ChipmunkAccelTouchTest finished!"
|
||||
mr.sleep(2.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("ChipmunkAccelTouchTest")
|
||||
|
||||
#----------------LabelTest----------------
|
||||
print "Run LabelTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/6*5,'DOWN_AND_UP')
|
||||
mr.sleep(3.0)
|
||||
common_test(1,26,0.5)
|
||||
mr.sleep(1.0)
|
||||
print "LableTest finished!"
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("LabelTest")
|
||||
|
||||
#----------------TestInputTest----------------
|
||||
print "Run TestInputTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/12*11,'DOWN_AND_UP')
|
||||
print "TestInputTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("TestInputTest")
|
||||
mr.sleep(1.0)
|
||||
device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
|
||||
|
||||
#----------------SpriteTest----------------
|
||||
print "Run SpriteTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/16,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
random_click(1,11,0.1)
|
||||
mr.sleep(2.0)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
random_click(1,11,0.1)
|
||||
mr.sleep(1.0)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
common_test(1,109,0.5)
|
||||
print "SpriteTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("SpriteTest")
|
||||
|
||||
#----------------SchdulerTest----------------
|
||||
print "Run SchdulerTest"
|
||||
mr.sleep(2.0)
|
||||
device.touch(s_width/2,s_height/48*7,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
#Scheduler timeScale Test
|
||||
mr.sleep(1.0)
|
||||
device.drag((s_width/16*9,s_height/8*5),(s_width/16*7,s_height/8*5))
|
||||
mr.sleep(1.0)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
#Two custom schedulers
|
||||
mr.sleep(1.0)
|
||||
device.drag((s_width/16*5,s_height/24),(s_width/16*3,s_height/24))
|
||||
mr.sleep(1.0)
|
||||
common_test(1,11,1)
|
||||
print "SchdulerTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("SchdulerTest")
|
||||
|
||||
#----------------RenderTextureTest----------------
|
||||
print "Run RenderTextureTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/48*11,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
random_drag(1,11,0.5)
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/8*7,s_height/24,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
#Testing Z Buffer in Render Texture
|
||||
random_click(1,11,0.1)
|
||||
mr.sleep(1.0)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
print "RenderTextureTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("RenderTextureTest")
|
||||
|
||||
#----------------Testure2DTest----------------
|
||||
print "Run Testure2DTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/16*5,'DOWN_AND_UP')
|
||||
common_test(1,36,0.5)
|
||||
print "Testure2DTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("Testure2DTest")
|
||||
|
||||
#----------------Box2dTest----------------
|
||||
print "Run Box2dTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/48*19,'DOWN_AND_UP')
|
||||
random_click(1,31,0.1)
|
||||
print "Box2dTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("Box2dTest")
|
||||
|
||||
#----------------Box2dTestBed----------------
|
||||
print "Run Box2dTestBed"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/48*23,'DOWN_AND_UP')
|
||||
common_test(1,36,2.0)
|
||||
print "Box2dTestBed finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("Box2dTestBed")
|
||||
|
||||
#----------------EffectAdvancedTest----------------
|
||||
print "Run EffectAdvancedTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/16*9,'DOWN_AND_UP')
|
||||
common_test(1,6,1.0)
|
||||
print "EffectAdvancedTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("EffectAdvancedTest")
|
||||
|
||||
#----------------Accelerometer----------------
|
||||
print "Run Accelerometer"
|
||||
mr.sleep(5.0)
|
||||
device.touch(s_width/2,s_height/48*31,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
print "Accelerometer finished!"
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
mr.sleep(3.0)
|
||||
check_activity("Accelerometer")
|
||||
|
||||
#----------------KeypadTest----------------
|
||||
print "Run KeypadTest"
|
||||
mr.sleep(3.0)
|
||||
device.touch(s_width/2,s_height/48*35,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
device.press('KEYCODE_BACK','DOWN_AND_UP')
|
||||
print "KeypadTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("KeypadTest")
|
||||
|
||||
#----------------CocosDenshionTest----------------
|
||||
print "Run CocosDenshionTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/48*39,'DOWN_AND_UP')
|
||||
#device.touch(400,30,'DOWN_AND_UP')
|
||||
#device.touch(400,100,'DOWN_AND_UP')
|
||||
print "CocosDenshionTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("CocosDenshionTest")
|
||||
|
||||
#----------------PerformanceTest----------------
|
||||
print "Run PerformanceTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/48*43,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
#PerformanceNodeChildrenTest
|
||||
device.touch(s_width/2,s_height/12,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
common_test(1,6,1.0)
|
||||
#Back
|
||||
device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
#PerformanceParticleTest
|
||||
device.touch(s_width/2,s_height/6,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
#for NodeChildren_i in range(1,5):
|
||||
# device.touch(450,240,'DOWN_AND_UP')
|
||||
# mr.sleep(1.0)
|
||||
# device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
# mr.sleep(1.0)
|
||||
common_test(1,5,1.0)
|
||||
#Back
|
||||
device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
#PerformanceSpriteTest
|
||||
device.touch(s_width/2,s_height/4,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
#for NodeChildren_i in range(1,8):
|
||||
# device.touch(430,80,'DOWN_AND_UP')
|
||||
# mr.sleep(1.0)
|
||||
# device.touch(370,80,'DOWN_AND_UP')
|
||||
# mr.sleep(1.0)
|
||||
common_test(1,8,1.0)
|
||||
#Back
|
||||
device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
#PerformanceTextureTest
|
||||
#device.touch(s_width/2,s_height/3,'DOWN_AND_UP')
|
||||
#mr.sleep(1.0)
|
||||
#Back
|
||||
#device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP')
|
||||
#mr.sleep(1.0)
|
||||
#PerformanceTouchesTest
|
||||
device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
random_drag(1,11,0.2)
|
||||
#Next Test
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
random_drag(1,11,0.2)
|
||||
mr.sleep(1.0)
|
||||
#Back
|
||||
device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP')
|
||||
print "PerformanceTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("PerformanceTest")
|
||||
|
||||
#----------------ZwoptexTest----------------
|
||||
print "Run ZwoptexTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/48*47,'DOWN_AND_UP')
|
||||
print "ZwoptexTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("ZwoptexTest")
|
||||
mr.sleep(1.0)
|
||||
device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
|
||||
|
||||
#----------------CurlTest----------------
|
||||
print "Run CurlTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/4,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
random_click(1,2,1.0)
|
||||
print "CurlTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("CurlTest")
|
||||
mr.sleep(1.0)
|
||||
device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
|
||||
|
||||
#----------------UserDefaultTest----------------
|
||||
print "Run UserDefaultTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/3,'DOWN_AND_UP')
|
||||
print "UserDefaultTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("UserDefaultTest")
|
||||
mr.sleep(1.0)
|
||||
device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
|
||||
|
||||
#----------------BugsTest----------------
|
||||
print "Run BugsTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP')
|
||||
print "BugsTest is finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("BugsTest")
|
||||
mr.sleep(1.0)
|
||||
device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
|
||||
|
||||
#----------------FontTest----------------
|
||||
print "Run FontTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/2,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
common_test(1,6,0.5)
|
||||
mr.sleep(1.0)
|
||||
print "FontTest finished!"
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("FontTest")
|
||||
mr.sleep(1.0)
|
||||
device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
|
||||
|
||||
#----------------CurrentLanguageTest----------------
|
||||
print "Run CurrentLanguageTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/12*7,'DOWN_AND_UP')
|
||||
print "CurrentLanguageTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("CurrentLanguageTest")
|
||||
mr.sleep(1.0)
|
||||
device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
|
||||
|
||||
#----------------TextureCacheTest----------------
|
||||
print "Run TextureCacheTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/3*2,'DOWN_AND_UP')
|
||||
print "TextureCacheTest is finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("TextureCacheTest")
|
||||
mr.sleep(1.0)
|
||||
device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
|
||||
|
||||
#----------------ExtensionsTest----------------
|
||||
print "Run ExtensionsTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/4*3,'DOWN_AND_UP')
|
||||
#NotificationCenterTest
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/12,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/40*23,s_height/2,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/40*23,s_height/2,'DOWN_AND_UP')
|
||||
#Back
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP')
|
||||
#CCControlButtonTest
|
||||
mr.sleep(1.5)
|
||||
device.touch(s_width/2,s_height/6,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
device.drag((s_width/2,s_height/48*25),(s_width/20*13,s_height/48*25))
|
||||
mr.sleep(1.5)
|
||||
device.drag((s_width/20*13,s_height/48*25),(s_width/20*7,s_height/48*25))
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
device.touch(s_width/16*7,s_height/2,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
device.touch(s_width/40*19,s_height/2,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
random_click(1,10,0.1)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
random_click(1,10,0.1)
|
||||
mr.sleep(1.5)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
random_click(1,10,0.1)
|
||||
mr.sleep(1.5)
|
||||
#Back
|
||||
device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
#CocosBuilderTest
|
||||
device.touch(s_width/2,s_height/4,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
#Menus & Items
|
||||
device.touch(s_width/4,s_height/2,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
device.touch(s_width/4,s_height/24*11,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
device.touch(s_width/2,s_height/24*11,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
#ItemBack
|
||||
device.touch(s_width/40,s_height/24,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
#Sprite & 9 Slice
|
||||
device.touch(s_width/4*3,s_height/2,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
#ItemBack
|
||||
device.touch(s_width/40,s_height/24,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
#Button
|
||||
device.touch(s_width/4,s_height/8*5,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
device.touch(s_width/2,s_height/24*11,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
device.drag((s_width/2,s_height/24*11),(s_width/2,s_height/8*5))
|
||||
mr.sleep(1.5)
|
||||
#ItemBack
|
||||
device.touch(s_width/40,s_height/24,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
#Labels
|
||||
device.touch(s_width/4*3,s_height/8*5,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
#ItemBack
|
||||
device.touch(s_width/40,s_height/24,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
#Particle Systems
|
||||
device.touch(s_width/40,s_height/4*3,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
#ItemBack
|
||||
device.touch(s_width/40,s_height/24,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
#Scroll Views
|
||||
device.touch(s_width/4*3,s_height/4*3,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
random_drag(1,10,0.2)
|
||||
mr.sleep(1.5)
|
||||
#ItemBack
|
||||
device.touch(s_width/40,s_height/24,'DOWN_AND_UP')
|
||||
mr.sleep(1.5)
|
||||
print "ExtensionsTest finished!"
|
||||
mr.sleep(1.5)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("ExtensionsTest")
|
||||
mr.sleep(1.0)
|
||||
device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
|
||||
|
||||
#----------------ShaderTest----------------
|
||||
print "Run ShaderTest"
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/2,s_height/6*5,'DOWN_AND_UP')
|
||||
mr.sleep(7.0)
|
||||
common_test(1,7,1.0)
|
||||
mr.sleep(2.0)
|
||||
device.drag((s_width/2,s_height/3*2),(s_width/80*51,s_height/3*2))
|
||||
mr.sleep(1.0)
|
||||
device.drag((s_width/80*51,s_height/3*2),(s_width/80*29,s_height/3*2))
|
||||
mr.sleep(1.0)
|
||||
#Next Test
|
||||
device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
|
||||
print "ShaderTest finished!"
|
||||
mr.sleep(3.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("ShaderTest")
|
||||
mr.sleep(1.0)
|
||||
device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
|
||||
|
||||
#----------------MutiTouchTest----------------
|
||||
print "Run MutiTouchTest"
|
||||
mr.sleep(3.0)
|
||||
device.touch(s_width/2,s_height/12*11,'DOWN_AND_UP')
|
||||
mr.sleep(1.0)
|
||||
random_drag(1,10,0.1)
|
||||
print "MutiTouchTest finished!"
|
||||
mr.sleep(1.0)
|
||||
#MainMenu
|
||||
device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
|
||||
check_activity("MutiTouchTest")
|
||||
|
||||
#----------------Quit----------------
|
||||
mr.sleep(1.0)
|
||||
device.touch(s_width/80*77,s_height/12,'DOWN_AND_UP')
|
|
@ -1,95 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="Tests" default="help">
|
||||
|
||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||
It contains the path to the SDK. It should *NOT* be checked into
|
||||
Version Control Systems. -->
|
||||
<loadproperties srcFile="local.properties" />
|
||||
|
||||
<!-- The ant.properties file can be created by you. It is only edited by the
|
||||
'android' tool to add properties to it.
|
||||
This is the place to change some Ant specific build properties.
|
||||
Here are some properties you may want to change/update:
|
||||
|
||||
source.dir
|
||||
The name of the source directory. Default is 'src'.
|
||||
out.dir
|
||||
The name of the output directory. Default is 'bin'.
|
||||
|
||||
For other overridable properties, look at the beginning of the rules
|
||||
files in the SDK, at tools/ant/build.xml
|
||||
|
||||
Properties related to the SDK location or the project target should
|
||||
be updated using the 'android' tool with the 'update' action.
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems.
|
||||
|
||||
-->
|
||||
<property file="ant.properties" />
|
||||
|
||||
<!-- The project.properties file is created and updated by the 'android'
|
||||
tool, as well as ADT.
|
||||
|
||||
This contains project specific properties such as project target, and library
|
||||
dependencies. Lower level build properties are stored in ant.properties
|
||||
(or in .classpath for Eclipse projects).
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems. -->
|
||||
<loadproperties srcFile="project.properties" />
|
||||
|
||||
<!-- quick check on sdk.dir -->
|
||||
<fail
|
||||
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'"
|
||||
unless="sdk.dir"
|
||||
/>
|
||||
|
||||
|
||||
<!-- extension targets. Uncomment the ones where you want to do custom work
|
||||
in between standard targets -->
|
||||
|
||||
<target name="-pre-build">
|
||||
<copy todir="src/org/cocos2dx">
|
||||
<fileset dir="..\..\..\..\cocos2dx\platform\android\java\src\org\cocos2dx">
|
||||
<include name="lib/" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-pre-compile">
|
||||
<path id="android.target.classpath">
|
||||
<pathelement path="${sdk.dir}/platforms/${target}/android.jar"/>
|
||||
<pathelement path="${sdk.dir}/platforms/${target}/data/layoutlib.jar"/>
|
||||
</path>
|
||||
</target>
|
||||
|
||||
<!--
|
||||
/* This is typically used for code obfuscation.
|
||||
Compiled code location: ${out.classes.absolute.dir}
|
||||
If this is not done in place, override ${out.dex.input.absolute.dir} */
|
||||
<target name="-post-compile">
|
||||
</target>
|
||||
-->
|
||||
|
||||
<!-- Import the actual build file.
|
||||
|
||||
To customize existing targets, there are two options:
|
||||
- Customize only one target:
|
||||
- copy/paste the target into this file, *before* the
|
||||
<import> task.
|
||||
- customize it to your needs.
|
||||
- Customize the whole content of build.xml
|
||||
- copy/paste the content of the rules files (minus the top node)
|
||||
into this file, replacing the <import> task.
|
||||
- customize to your needs.
|
||||
|
||||
***********************
|
||||
****** IMPORTANT ******
|
||||
***********************
|
||||
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
|
||||
in order to avoid having your file be overridden by tools such as "android update project"
|
||||
-->
|
||||
<!-- version-tag: 1 -->
|
||||
<import file="${sdk.dir}/tools/ant/build.xml" />
|
||||
|
||||
</project>
|
|
@ -7,28 +7,9 @@ import urllib2
|
|||
import urllib
|
||||
import base64
|
||||
import requests
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
#get payload from os env
|
||||
payload_str = os.environ['payload']
|
||||
#parse to json obj
|
||||
payload = json.loads(payload_str)
|
||||
|
||||
#get pull number
|
||||
pr_num = payload['number']
|
||||
print 'pr_num:' + str(pr_num)
|
||||
|
||||
#build for pull request action 'open' and 'synchronize', skip 'close'
|
||||
action = payload['action']
|
||||
print 'action: ' + action
|
||||
if((action != 'opened') and (action != 'synchronize')):
|
||||
print 'pull request #' + str(pr_num) + ' is closed, no build triggered'
|
||||
exit(0)
|
||||
|
||||
|
||||
pr = payload['pull_request']
|
||||
url = pr['html_url']
|
||||
print "url:" + url
|
||||
pr_desc = '<h3><a href='+ url + '> pr#' + str(pr_num) + '</a></h3>'
|
||||
#set Jenkins build description using submitDescription to mock browser behavior
|
||||
#TODO: need to set parent build description
|
||||
def set_description(desc):
|
||||
|
@ -38,74 +19,90 @@ def set_description(desc):
|
|||
req.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
||||
base64string = base64.encodestring(os.environ['JENKINS_ADMIN']+ ":" + os.environ['JENKINS_ADMIN_PW']).replace('\n', '')
|
||||
req.add_header("Authorization", "Basic " + base64string)
|
||||
urllib2.urlopen(req)
|
||||
try:
|
||||
try:
|
||||
urllib2.urlopen(req)
|
||||
except:
|
||||
traceback.format_exc()
|
||||
def main():
|
||||
#get payload from os env
|
||||
payload_str = os.environ['payload']
|
||||
#parse to json obj
|
||||
payload = json.loads(payload_str)
|
||||
|
||||
#get pull number
|
||||
pr_num = payload['number']
|
||||
print 'pr_num:' + str(pr_num)
|
||||
|
||||
#build for pull request action 'open' and 'synchronize', skip 'close'
|
||||
action = payload['action']
|
||||
print 'action: ' + action
|
||||
if((action != 'opened') and (action != 'synchronize')):
|
||||
print 'pull request #' + str(pr_num) + ' is closed, no build triggered'
|
||||
exit(0)
|
||||
|
||||
|
||||
pr = payload['pull_request']
|
||||
url = pr['html_url']
|
||||
print "url:" + url
|
||||
pr_desc = '<h3><a href='+ url + '> pr#' + str(pr_num) + '</a></h3>'
|
||||
set_description(pr_desc)
|
||||
except Exception as e:
|
||||
print e
|
||||
|
||||
#get statuses url
|
||||
statuses_url = pr['statuses_url']
|
||||
#get statuses url
|
||||
statuses_url = pr['statuses_url']
|
||||
|
||||
#get pr target branch
|
||||
branch = pr['head']['ref']
|
||||
#get pr target branch
|
||||
branch = pr['base']['ref']
|
||||
|
||||
#set commit status to pending
|
||||
target_url = os.environ['BUILD_URL']
|
||||
data = {"state":"pending", "target_url":target_url}
|
||||
acccess_token = os.environ['GITHUB_ACCESS_TOKEN']
|
||||
Headers = {"Authorization":"token " + acccess_token}
|
||||
try:
|
||||
requests.post(statuses_url, data=json.dumps(data), headers=Headers)
|
||||
|
||||
#reset path to workspace root
|
||||
os.system("cd " + os.environ['WORKSPACE']);
|
||||
#set commit status to pending
|
||||
target_url = os.environ['BUILD_URL']
|
||||
data = {"state":"pending", "target_url":target_url}
|
||||
acccess_token = os.environ['GITHUB_ACCESS_TOKEN']
|
||||
Headers = {"Authorization":"token " + acccess_token}
|
||||
|
||||
#fetch pull request to local repo
|
||||
git_fetch_pr = "git fetch origin pull/" + str(pr_num) + "/head"
|
||||
os.system(git_fetch_pr)
|
||||
try:
|
||||
requests.post(statuses_url, data=json.dumps(data), headers=Headers)
|
||||
except:
|
||||
traceback.format_exc()
|
||||
|
||||
#checkout
|
||||
git_checkout = "git checkout -b " + "pull" + str(pr_num) + " FETCH_HEAD"
|
||||
os.system(git_checkout)
|
||||
#build
|
||||
#TODO: support android-mac build currently
|
||||
#TODO: add android-windows7 build
|
||||
#TODO: add android-linux build
|
||||
#TODO: add ios build
|
||||
#TODO: add mac build
|
||||
#TODO: add win32 build
|
||||
if(branch == 'develop'):
|
||||
ret = os.system("python build/android-build.py -n -j5 testcpp")
|
||||
elif(branch == 'master'):
|
||||
ret = os.system("samples/Cpp/TestCpp/proj.android/build_native.sh")
|
||||
|
||||
#update submodule
|
||||
git_update_submodule = "git submodule update --init --force"
|
||||
os.system(git_update_submodule)
|
||||
except Exception as e:
|
||||
print e
|
||||
#get build result
|
||||
print "build finished and return " + str(ret)
|
||||
if ret == 0:
|
||||
exit_code = 0
|
||||
data['state'] = "success"
|
||||
|
||||
else:
|
||||
exit_code = 1
|
||||
data['state'] = "failure"
|
||||
|
||||
|
||||
#build
|
||||
#TODO: support android-mac build currently
|
||||
#TODO: add android-windows7 build
|
||||
#TODO: add android-linux build
|
||||
#TODO: add ios build
|
||||
#TODO: add mac build
|
||||
#TODO: add win32 build
|
||||
if(branch == 'develop'):
|
||||
ret = os.system("python build/android-build.py -n -j5 testcpp")
|
||||
elif(branch == 'master'):
|
||||
ret = os.system("samples/Cpp/TestCpp/proj.android/build_native.sh")
|
||||
|
||||
#get build result
|
||||
print "build finished and return " + str(ret)
|
||||
if ret == 0:
|
||||
exit_code = 0
|
||||
data['state'] = "success"
|
||||
|
||||
else:
|
||||
exit_code = 1
|
||||
data['state'] = "failure"
|
||||
try:
|
||||
#set commit status
|
||||
requests.post(statuses_url, data=json.dumps(data), headers=Headers)
|
||||
try:
|
||||
requests.post(statuses_url, data=json.dumps(data), headers=Headers)
|
||||
except:
|
||||
traceback.format_exc()
|
||||
|
||||
#clean workspace
|
||||
os.system("cd " + os.environ['WORKSPACE']);
|
||||
os.system("git checkout develop")
|
||||
os.system("git branch -D pull" + str(pr_num))
|
||||
except Exception as e:
|
||||
print e
|
||||
exit(exit_code)
|
||||
|
||||
exit(exit_code)
|
||||
|
||||
# -------------- main --------------
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except:
|
||||
traceback.format_exc()
|
||||
exit(1)
|
||||
|
|
Loading…
Reference in New Issue