@@ -25,7 +25,7 @@ COVERAGE_REPORT="term"
2525KEEP_RUNNING=false
2626SELECTED_CORES=" "
2727INCLUDE_LOCAL_CORES=false
28- TEST_FILES=" "
28+ TEST_FILES=()
2929PARALLEL=false
3030PARALLEL_WORKERS=" auto"
3131
@@ -102,7 +102,7 @@ while [[ $# -gt 0 ]]; do
102102 usage
103103 exit 1
104104 fi
105- TEST_FILES= " $TEST_FILES $1 "
105+ TEST_FILES+=( " $1 " )
106106 shift
107107 ;;
108108 --help)
@@ -542,37 +542,37 @@ main() {
542542
543543 # Run pytest
544544 # Build pytest command
545- PYTEST_CMD= " pytest"
545+ PYTEST_ARGS=( pytest)
546546 # and the specific pytest command for running serial pickle tests
547- SERIAL_PYTEST_CMD= " pytest -m seriallocal"
547+ SERIAL_PYTEST_ARGS=( pytest -m seriallocal)
548548 # Only add -n0 if pytest-xdist is available; otherwise, plain pytest is already serial
549549 if python - << 'EOF ' >/dev/null 2>&1
550550import xdist # noqa: F401
551551EOF
552552 then
553- SERIAL_PYTEST_CMD= " $SERIAL_PYTEST_CMD -n0"
553+ SERIAL_PYTEST_ARGS+=( -n0)
554554 fi
555555
556556 # Add test files if specified
557- if [ -n " $ TEST_FILES" ]; then
558- PYTEST_CMD= " $PYTEST_CMD $ TEST_FILES"
559- print_message $BLUE " Test files specified: $TEST_FILES "
557+ if [ ${ # TEST_FILES[@]} -gt 0 ]; then
558+ PYTEST_ARGS+=( " ${ TEST_FILES[@]} " )
559+ print_message $BLUE " Test files specified: ${ TEST_FILES[*]} "
560560 # and turn off serial local tests, so we run only selected files
561561 run_serial_local_tests=false
562562 fi
563563
564564 # Add markers if needed (only if no specific test files were given)
565- if [ -z " $ TEST_FILES" ]; then
565+ if [ ${ # TEST_FILES[@]} -eq 0 ]; then
566566 # Check if we selected all cores - if so, run all tests without marker filtering
567567 all_cores=" memory mongo pickle redis s3 sql"
568568 selected_sorted=$( echo " $SELECTED_CORES " | tr ' ' ' \n' | sort | tr ' \n' ' ' | xargs)
569569 all_sorted=$( echo " $all_cores " | tr ' ' ' \n' | sort | tr ' \n' ' ' | xargs)
570570
571571 if [ " $selected_sorted " != " $all_sorted " ]; then
572- PYTEST_CMD= " $PYTEST_CMD -m \ "$pytest_markers \" "
572+ PYTEST_ARGS+=( -m " $pytest_markers " )
573573 else
574574 print_message $BLUE " Running all tests without markers since all cores are selected"
575- PYTEST_CMD= " $PYTEST_CMD -m \ " not seriallocal\" "
575+ PYTEST_ARGS+=( -m " not seriallocal" )
576576 run_serial_local_tests=true
577577 fi
578578 else
@@ -582,19 +582,19 @@ EOF
582582 all_sorted=$( echo " $all_cores " | tr ' ' ' \n' | sort | tr ' \n' ' ' | xargs)
583583
584584 if [ " $selected_sorted " != " $all_sorted " ]; then
585- PYTEST_CMD= " $PYTEST_CMD -m \ "$pytest_markers \" "
585+ PYTEST_ARGS+=( -m " $pytest_markers " )
586586 fi
587587 fi
588588
589589 # Add verbose flag if needed
590590 if [ " $VERBOSE " = true ]; then
591- PYTEST_CMD= " $PYTEST_CMD -v "
592- SERIAL_PYTEST_CMD= " $SERIAL_PYTEST_CMD -v "
591+ PYTEST_ARGS+=(-v)
592+ SERIAL_PYTEST_ARGS+=(-v)
593593 fi
594594
595595 # Add parallel testing options if requested
596596 if [ " $PARALLEL " = true ]; then
597- PYTEST_CMD= " $PYTEST_CMD -n $PARALLEL_WORKERS "
597+ PYTEST_ARGS+=( -n " $PARALLEL_WORKERS " )
598598
599599 # Show parallel testing info
600600 if [ " $PARALLEL_WORKERS " = " auto" ]; then
@@ -610,16 +610,16 @@ EOF
610610 fi
611611
612612 # Add coverage options
613- PYTEST_CMD= " $PYTEST_CMD --cov=cachier --cov-report=$COVERAGE_REPORT "
614- SERIAL_PYTEST_CMD= " $SERIAL_PYTEST_CMD --cov=cachier --cov-report=$COVERAGE_REPORT --cov-append"
613+ PYTEST_ARGS+=( --cov=cachier --cov-report=" $COVERAGE_REPORT " )
614+ SERIAL_PYTEST_ARGS+=( --cov=cachier --cov-report=" $COVERAGE_REPORT " --cov-append)
615615
616616 # Print and run the command
617- print_message $BLUE " Running: $PYTEST_CMD "
618- eval $PYTEST_CMD
617+ print_message $BLUE " Running: $( printf ' %q ' " ${PYTEST_ARGS[@]} " ) "
618+ " ${PYTEST_ARGS[@]} "
619619
620620 if [ " $run_serial_local_tests " = true ]; then
621- print_message $BLUE " Running serial local tests (pickle, memory) with: $SERIAL_PYTEST_CMD "
622- eval $SERIAL_PYTEST_CMD
621+ print_message $BLUE " Running serial local tests (pickle, memory) with: $( printf ' %q ' " ${SERIAL_PYTEST_ARGS[@]} " ) "
622+ " ${SERIAL_PYTEST_ARGS[@]} "
623623 else
624624 print_message $BLUE " Skipping serial local tests (pickle, memory) since not requested"
625625 fi
0 commit comments