Skip to content

Commit

Permalink
Refactored auto-recording function
Browse files Browse the repository at this point in the history
  • Loading branch information
budtmo committed Oct 30, 2017
1 parent 08ff64d commit 0ea71ea
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions src/record.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,39 @@ function start() {

function stop() {
echo "Stop video recording"
kill $(ps -ef | grep ffmpeg | awk '{print $2}')
kill $(ps -ef | grep [f]fmpeg | awk '{print $2}')
}

function auto_record() {
if [ $AUTO_RECORD ]; then
if [ ${AUTO_RECORD,,} = true ]; then
echo "Auto recording is enable. It will record the video automatically as soon as appium receive test scenario!"
echo "Auto record: $AUTO_RECORD"
sleep 6

# Check if there is test running
no_test=true
while $no_test; do
task=$(curl -s localhost:4723/wd/hub/sessions | jq -r '.value')
if [ -n $task ]; then
sleep .5
else
no_test=false
start
fi
done
while [ $AUTO_RECORD == "True" ]; do
# Check if there is test running
no_test=true
while $no_test; do
task=$(curl -s localhost:4723/wd/hub/sessions | jq -r '.value')
if [ "$task" == "" ] || [ "$task" == "[]" ]; then
sleep .5
else
start &
no_test=false
fi
done

# Check if test is finished
while [ $no_test = false ]; do
task=$(curl -s localhost:4723/wd/hub/sessions | jq -r '.value')
if [ -n $task ]; then
stop
else
sleep .5
fi
done
fi
fi
# Check if test is finished
while [ $no_test == false ]; do
task=$(curl -s localhost:4723/wd/hub/sessions | jq -r '.value')
if [ "$task" == "" ] || [ "$task" == "[]" ]; then
stop
no_test=true
else
sleep .5
fi
done
done

echo "Auto recording is disabled!"
}

$@

0 comments on commit 0ea71ea

Please sign in to comment.