@@ -533,39 +533,36 @@ generate_web_caps_json() {
533533
534534generate_mobile_caps_json () {
535535 local max_total=$1
536+ local output_file=" $WORKSPACE_DIR /$PROJECT_FOLDER /usage_file.json"
537+ : > " $output_file " # Clear the output file
538+
536539 local count=0
537- local usage_file=" /tmp/device_usage.txt"
538- : > " $usage_file "
539540
540- local json=" ["
541- for template in " ${MOBILE_DEVICE_TEMPLATES[@]} " ; do
542- IFS=" |" read -r platformName deviceName baseVersion <<< " $template"
543- local usage
544- usage=$( grep -Fxc " $deviceName " " $usage_file " )
541+ local json=" ["
545542
546- if [ " $usage " -ge 5 ]; then
543+ for template in " ${MOBILE_ALL[@]} " ; do
544+ IFS=" |" read -r platformName deviceName baseVersion <<< " $template"
545+ if [ " $APP_PLATFORM " == " ios" ] && [ " $platformName " != " ios" ]; then
546+ continue
547+ elif [ " $APP_PLATFORM " == " android" ] || [ " $APP_PLATFORM " == " all" ] && [ " $platformName " != " android" ]; then
547548 continue
548549 fi
549-
550+
550551 json=" ${json} {
551552 \" bstack:options\" : {
552553 \" deviceName\" : \" ${deviceName} \" ,
553554 \" osVersion\" : \" ${baseVersion} .0\"
554555 }
555556 },"
556557
557- echo " $deviceName " >> " $usage_file "
558558 count=$(( count + 1 ))
559559 if [ " $count " -ge " $max_total " ]; then
560560 break
561561 fi
562- done
563-
562+ done # End of the loop
564563 json=" ${json% ,} ]"
565- echo " $json "
566- rm -f " $usage_file "
564+ echo " $json " > " $output_file "
567565}
568-
569566# ===== Fetch plan details (writes to GLOBAL) =====
570567fetch_plan_details () {
571568 log_msg_to " ℹ️ Fetching BrowserStack Plan Details..." " $GLOBAL "
@@ -829,7 +826,7 @@ setup_web_nodejs() {
829826 local_flag=true
830827 fi
831828
832- # Log local flag status
829+ Log local flag status
833830 if [ " $local_flag " = " true" ]; then
834831 log_msg_to " ✅ BrowserStack Local is ENABLED for this run." " $PRE_RUN_LOG_FILE "
835832 else
@@ -1154,37 +1151,32 @@ EOF
11541151}
11551152
11561153
1157- setup_mobile_js () {
1154+ setup_mobile_nodejs () {
11581155 local local_flag=$1
11591156 local parallels=$2
11601157 local log_file=$3
11611158
1162- REPO=" webdriverio-appium-app-browserstack"
1159+ cd $WORKSPACE_DIR /$PROJECT_FOLDER || return 1
1160+
1161+ REPO=" now-webdriverio-appium-app-browserstack"
11631162 if [ ! -d " $REPO " ]; then
1164- git clone -b sdk https://github.com/browserstack /$REPO
1163+ git clone -b sdk https://github.com/BrowserStackCE /$REPO
11651164 fi
1166- cd " $REPO /android/" || return 1
1165+
1166+ cd " $REPO /test/" || return 1
11671167
11681168 validate_prereqs || return 1
11691169 npm install >> " $log_file " 2>&1 || true
1170- cd " examples/run-parallel-test" || return 1
1171- caps_file=" parallel.conf.js"
1172-
1173- if sed --version > /dev/null 2>&1 ; then
1174- sed -i " s/\(maxInstances:\)[[:space:]]*[0-9]\+/\1 $parallels /" " $caps_file " || true
1175- else
1176- sed -i ' ' " s/\(maxInstances:\)[[:space:]]*[0-9]\+/\1 $parallels /" " $caps_file " || true
1177- fi
1178-
1179- caps_json=$( generate_mobile_caps_json " $parallels " )
1180- printf " %s\n" " capabilities: $caps_json ," > " $caps_file " .tmp || true
1181- mv " $caps_file " .tmp " $caps_file " || true
1170+ generate_mobile_caps_json " $parallels "
11821171
11831172 export BROWSERSTACK_USERNAME=" $BROWSERSTACK_USERNAME "
11841173 export BROWSERSTACK_ACCESS_KEY=" $BROWSERSTACK_ACCESS_KEY "
1174+ export BSTACK_PARALLELS=$parallels
1175+
1176+ npm run test > " $log_file " 2>&1 || true
1177+ [ -f " $log_file " ] && sed -n ' 1,200p' " $log_file " | while read -r l; do log_msg_to " mobile: $l " " $GLOBAL " ; done
11851178
1186- npm run parallel > " $log_file " 2>&1 || true
1187- [ -f " $log_file " ] && sed -n ' 1,200p' " $log_file " | while read -r l; do log_msg_to " mobile: $l " " $GLOBAL " ; done
1179+ # rm $WORKSPACE_DIR/$PROJECT_FOLDER/usage_file.json || true
11881180 return 0
11891181}
11901182
@@ -1209,7 +1201,7 @@ setup_mobile() {
12091201 case " $TECH_STACK " in
12101202 Java) setup_mobile_java " $local_flag " " $parallels_per_platform " " $MOBILE_LOG_FILE " ;;
12111203 Python) setup_mobile_python " $local_flag " " $parallels_per_platform " " $MOBILE_LOG_FILE " ;;
1212- NodeJS) setup_mobile_js " $local_flag " " $parallels_per_platform " " $MOBILE_LOG_FILE " ;;
1204+ NodeJS) setup_mobile_nodejs " $local_flag " " $parallels_per_platform " " $MOBILE_LOG_FILE " ;;
12131205 * ) log_msg_to " Unknown TECH_STACK: $TECH_STACK " " $MOBILE_LOG_FILE " ; return 1 ;;
12141206 esac
12151207
0 commit comments