-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c99f31d
commit abc4edd
Showing
2 changed files
with
136 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
log=/tmp/adb.log | ||
echo "# $$ "$(date "+%Y/%m/%d %H:%M:%S") >> $log | ||
echo "# ppid: $(ps -o command $(ps -o ppid $$ | tail -1) | tail -1)" >> $log | ||
echo "adb $@" >> $log | ||
if echo "$@" | grep -E "logcat |exec-out |uiautomator runtest" &>/dev/null; then | ||
echo "exec" >> $log | ||
exec /Users/seveniruby/Library/Android/sdk//platform-tools/adb.bak "$@" | ||
elif echo "$@" | grep "dumpsys package io.appium.settings" &>/dev/null; then | ||
echo "mock" >> $log | ||
cat /Users/seveniruby/temp/appium/package.mock | tee -a $log | ||
elif echo "$@" | grep "io\.appium\.settings" &>/dev/null;then | ||
echo "mock" >> $log | ||
echo "11111" | tee -a $log | ||
else | ||
result=$(/Users/seveniruby/Library/Android/sdk//platform-tools/adb.bak "$@") | ||
echo "origin" >> $log | ||
echo "$result" | tee -a $log | ||
fi | ||
echo "" >> $log |
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,117 @@ | ||
hogwarts() { | ||
echo ' | ||
# __ __ | ||
# / /_ ____ ____ __ ______ ______/ /______ | ||
# / __ \/ __ \/ __ `/ | /| / / __ `/ ___/ __/ ___/ | ||
# / / / / /_/ / /_/ /| |/ |/ / /_/ / / / /_(__ ) | ||
# /_/ /_/\____/\__, / |__/|__/\__,_/_/ \__/____/ | ||
# /____/ | ||
' | ||
echo "Hogwarts Testing Kit" | ||
echo | ||
|
||
local help install start | ||
ARGS="install start" pp "$@" | ||
|
||
if [ -n "$help" -o "$#" = 0 ]; then | ||
echo "hogwarts provide such functions" | ||
grep "() *{" $BASHGEMS_HOME/lib/hogwarts.sh | ||
return | ||
fi | ||
if [ -n "$install" ]; then | ||
eval hogwarts_install_$install | ||
fi | ||
} | ||
|
||
#use some command with proxy | ||
#proxy npm install -g appium | ||
proxy() { | ||
local http_proxy https_proxy | ||
if curl -s http://www.baidu.com -x http://127.0.0.1:3128 &>/dev/null; then | ||
http_proxy=http://127.0.0.1:3128 https_proxy=$http_proxy "$@" | ||
else | ||
http_proxy=http://39.105.132.200:$(date +6%m%d) https_proxy=$http_proxy "$@" | ||
fi | ||
} | ||
|
||
chromedriver_list() { | ||
curl https://raw.githubusercontent.com/appium/appium/master/docs/en/writing-running-appium/web/chromedriver.md 2>/dev/null | grep "|" | grep -v "2.[0-9] " | grep -v "2.1[0-9]" | ||
echo chromedriver in CN: https://npm.taobao.org/mirrors/chromedriver | ||
echo chromedriver in US: http://chromedriver.storage.googleapis.com/ | ||
echo chromedriver vs chrome version: https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/web/chromedriver.md | ||
} | ||
|
||
hogwarts_install_test() { | ||
echo "${FUNCNAME[1]} -> ${FUNCNAME[0]}" | ||
} | ||
hogwarts_install_stf() { | ||
brew install rethinkdb graphicsmagick zeromq protobuf yasm pkg-config | ||
npm install -g stf | ||
} | ||
|
||
Hogwarts_start_stf() { | ||
rethinkdb & | ||
stf local | ||
} | ||
|
||
hogwarts_install_jenkins() { | ||
local image=jenkins/jenkins:lts | ||
docker run -ti --rm --entrypoint="/bin/bash" $image -c "whoami && id" | ||
echo "maybe you need chown -R 1000 ~/jenkins/hogwarts" | ||
docker run -d --name jenkins_hogwarts \ | ||
-p 8080:8080 -p 50000:50000 \ | ||
-v ~/jenkins/hogwarts:/var/jenkins_home \ | ||
$image | ||
echo "you need use such password for init" | ||
docker exec jenkins_hogwarts sh -c 'cat /var/jenkins_home/secrets/initialAdminPassword' | ||
} | ||
|
||
hogwarts_install_appium() { | ||
if which node; then | ||
npm version | ||
else | ||
echo you should install node 8 or above | ||
if which brew; then | ||
brew install node | ||
else | ||
echo you should install brew by /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | ||
fi | ||
fi | ||
which java || echo you should install java | ||
which adb || echo you should install android sdk and put adb directory in your PATH | ||
echo search appium versions | ||
proxy npm view appium versions --json | tail | ||
echo start install appium | ||
proxy npm install -g appium --verbose | ||
echo start install ios testing toolkit | ||
if which brew; then | ||
brew info libimobiledevice || brew install libimobiledevice | ||
brew info ios-webkit-debug-proxy || brew install ios-webkit-debug-proxy | ||
fi | ||
echo start install ios-deploy | ||
npm info ios-deploy || npm install -g ios-deploy --verbose | ||
appium --version | ||
} | ||
|
||
hogwarts_get_capabilitys_android() { | ||
local info=$(adb logcat -d "*:S" "ActivityManager:I" | grep -i displayed | grep -o '[^/ ]*/[^: ]*') | ||
local package=$(echo "$info" | awk -F/ '{print $1}' | tail -1) | ||
local activity=$(echo "$info" | grep $package | head -1 | awk -F/ '{print $2}') | ||
echo " | ||
{ | ||
\"platformName\": \"android\", | ||
\"deviceName\": \"hogwarts\", | ||
\"automationName\": \"uiautomator2\", | ||
\"appPackage\": \"$package\", | ||
\"appActivity\": \"$activity\" | ||
} | ||
" | ||
} | ||
|
||
hogwarts_start_avd() { | ||
local name=$(emulator -list-avds | grep $1) | ||
( | ||
cd $(dirname $(which emulator)) | ||
emulator @$name | ||
) | ||
} |