diff --git a/src/record.sh b/src/record.sh index 4380738..e4c39bb 100644 --- a/src/record.sh +++ b/src/record.sh @@ -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!" } $@