Refactored auto-recording function

This commit is contained in:
butomo1989 2017-10-30 20:42:36 +01:00
parent 08ff64d950
commit 0ea71ea6b8

View file

@ -9,37 +9,39 @@ function start() {
function stop() { function stop() {
echo "Stop video recording" echo "Stop video recording"
kill $(ps -ef | grep ffmpeg | awk '{print $2}') kill $(ps -ef | grep [f]fmpeg | awk '{print $2}')
} }
function auto_record() { function auto_record() {
if [ $AUTO_RECORD ]; then echo "Auto record: $AUTO_RECORD"
if [ ${AUTO_RECORD,,} = true ]; then sleep 6
echo "Auto recording is enable. It will record the video automatically as soon as appium receive test scenario!"
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 [ -n $task ]; then if [ "$task" == "" ] || [ "$task" == "[]" ]; then
sleep .5 sleep .5
else else
start &
no_test=false no_test=false
start
fi fi
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 [ -n $task ]; then if [ "$task" == "" ] || [ "$task" == "[]" ]; then
stop stop
no_test=true
else else
sleep .5 sleep .5
fi fi
done done
fi done
fi
echo "Auto recording is disabled!"
} }
$@ $@