22# shellcheck shell=bash
33
44setup_environment () {
5- local setup_type=$1 # "web" or "mobile"
5+ local setup_type=$1
66 local tech_stack=$2
77 local max_parallels
88
@@ -17,7 +17,7 @@ setup_environment() {
1717 max_parallels=$TEAM_PARALLELS_MAX_ALLOWED_MOBILE
1818 fi
1919
20- log_msg_to " Starting ${setup_type} setup for $TECH_STACK " " $NOW_RUN_LOG_FILE "
20+ log_msg_to " Starting ${setup_type} setup for " " $tech_stack " " $NOW_RUN_LOG_FILE "
2121
2222 local local_flag=false
2323
@@ -134,7 +134,7 @@ setup_app_java() {
134134 local app_url=$BROWSERSTACK_APP
135135 log_msg_to " APP_PLATFORM: $APP_PLATFORM " >> " $NOW_RUN_LOG_FILE " 2>&1
136136
137- clone_repository $REPO $TARGET_DIR
137+ clone_repository " $REPO " " $TARGET_DIR "
138138
139139 if [[ " $APP_PLATFORM " == " all" || " $APP_PLATFORM " == " android" ]]; then
140140 cd " android/testng-examples" || return 1
@@ -145,7 +145,7 @@ setup_app_java() {
145145
146146 # YAML config path
147147 export BROWSERSTACK_CONFIG_FILE=" ./browserstack.yml"
148- platform_yaml=$( generate_mobile_platforms $TEAM_PARALLELS_MAX_ALLOWED_MOBILE " yaml" )
148+ platform_yaml=$( generate_mobile_platforms " $TEAM_PARALLELS_MAX_ALLOWED_MOBILE " " yaml" )
149149
150150 cat >> " $BROWSERSTACK_CONFIG_FILE " << EOF
151151app: ${app_url}
182182 show_spinner " $cmd_pid "
183183 wait " $cmd_pid "
184184
185- cd " $WORKSPACE_DIR /$PROJECT_FOLDER "
185+ cd " $WORKSPACE_DIR /$PROJECT_FOLDER " || return 1
186186 return 0
187187}
188188
@@ -232,14 +232,14 @@ EOF
232232 print_tests_running_log_section " browserstack-sdk pytest -s src/test/suites/*.py --browserstack.config ./src/conf/browserstack_parallel.yml"
233233 log_msg_to " 🚀 Running 'browserstack-sdk pytest -s tests/bstack-sample-test.py'. This could take a few minutes. Follow the Automaton build here: https://automation.browserstack.com/"
234234 # Run tests
235- browserstack-sdk pytest -s src/test/suites/* .py --browserstack.config ./src/conf/browserstack_parallel.yml >> $NOW_RUN_LOG_FILE 2>&1
235+ browserstack-sdk pytest -s src/test/suites/* .py --browserstack.config ./src/conf/browserstack_parallel.yml >> " $NOW_RUN_LOG_FILE " 2>&1
236236 # &
237237 # cmd_pid=$!|| return 1
238238
239239 # show_spinner "$cmd_pid"
240240 # wait "$cmd_pid"
241241
242- cd " $WORKSPACE_DIR /$PROJECT_FOLDER "
242+ cd " $WORKSPACE_DIR /$PROJECT_FOLDER " || return 1
243243 return 0
244244}
245245
@@ -251,24 +251,20 @@ setup_app_python() {
251251 REPO=" now-pytest-appium-app-browserstack"
252252 TARGET_DIR=" $WORKSPACE_DIR /$PROJECT_FOLDER /$REPO "
253253
254- clone_repository $REPO $TARGET_DIR
254+ clone_repository " $REPO " " $TARGET_DIR "
255255
256256 detect_setup_python_env
257257
258258 # Install dependencies
259259 pip install -r requirements.txt >> " $NOW_RUN_LOG_FILE " 2>&1
260260 log_success " Dependencies installed"
261261
262-
263- # Prepare platform-specific YAMLs in android/ and ios/
264- local original_platform=" $APP_PLATFORM "
265-
266262 local app_url=$BROWSERSTACK_APP
267263 local platform_yaml
268264
269265 export BSTACK_PARALLELS=1
270266 export BROWSERSTACK_CONFIG_FILE=" ./android/browserstack.yml"
271- platform_yaml=$( generate_mobile_platforms $TEAM_PARALLELS_MAX_ALLOWED_MOBILE " yaml" )
267+ platform_yaml=$( generate_mobile_platforms " $TEAM_PARALLELS_MAX_ALLOWED_MOBILE " " yaml" )
272268
273269 cat >> " $BROWSERSTACK_CONFIG_FILE " << EOF
274270
@@ -312,13 +308,13 @@ setup_web_nodejs() {
312308 TARGET_DIR=" $WORKSPACE_DIR /$PROJECT_FOLDER /$REPO "
313309 mkdir -p " $WORKSPACE_DIR /$PROJECT_FOLDER "
314310
315- clone_repository $REPO $TARGET_DIR
311+ clone_repository " $REPO " " $TARGET_DIR "
316312
317313
318314 # === 2️⃣ Install Dependencies ===
319315 log_msg_to " ⚙️ Running 'npm install'"
320316 log_info " Installing dependencies"
321- npm install >> $NOW_RUN_LOG_FILE 2>&1 || return 1
317+ npm install >> " $NOW_RUN_LOG_FILE " 2>&1 || return 1
322318 log_success " Dependencies installed"
323319
324320 local caps_json=" "
@@ -345,7 +341,7 @@ setup_web_nodejs() {
345341 # === 8️⃣ Run Tests ===
346342 log_msg_to " 🚀 Running 'npm run test'. This could take a few minutes. Follow the Automaton build here: https://automation.browserstack.com/"
347343 print_tests_running_log_section " npm run test"
348- npm run test >> $NOW_RUN_LOG_FILE 2>&1 || return 1 &
344+ npm run test >> " $NOW_RUN_LOG_FILE " 2>&1 || return 1 &
349345 cmd_pid=$! || return 1
350346
351347 show_spinner " $cmd_pid "
@@ -367,15 +363,15 @@ setup_app_nodejs() {
367363 TARGET_DIR=" $WORKSPACE_DIR /$PROJECT_FOLDER /$REPO "
368364 TEST_FOLDER=" /test"
369365
370- clone_repository $REPO $TARGET_DIR $TEST_FOLDER
366+ clone_repository $REPO " $TARGET_DIR " " $TEST_FOLDER "
371367
372368 # === 2️⃣ Install Dependencies ===
373369 log_info " Installing dependencies"
374370 log_msg_to " ⚙️ Running 'npm install'"
375- npm install >> $NOW_RUN_LOG_FILE 2>&1 || return 1
371+ npm install >> " $NOW_RUN_LOG_FILE " 2>&1 || return 1
376372 log_success " Dependencies installed"
377373
378- caps_json=$( generate_mobile_platforms $TEAM_PARALLELS_MAX_ALLOWED_MOBILE " json" )
374+ caps_json=$( generate_mobile_platforms " $TEAM_PARALLELS_MAX_ALLOWED_MOBILE " " json" )
379375
380376
381377 export BSTACK_CAPS_JSON=$caps_json
@@ -444,7 +440,7 @@ run_setup_wrapper() {
444440 fi
445441 ;;
446442 * )
447- log_msg_to " ❌ Invalid TEST_TYPE: $TEST_TYPE "
443+ log_msg_to " ❌ Invalid TEST_TYPE: $test_type "
448444 exit 1
449445 ;;
450446 esac
0 commit comments