2121# Android → --driver devicelab
2222# iOS → default driver
2323#
24- # Failed test runs are retried in CI only (iOS and Android ). Override with
25- # MAESTRO_MAX_RETRIES (default: 1 locally, 2 in CI). DeviceLab driver startup
26- # crashes on CI Android get extra cleanup between attempts.
24+ # In CI, failed flows are retried individually (not the whole suite ). Override
25+ # with MAESTRO_MAX_RETRIES (default: 1 locally, 2 in CI). DeviceLab driver
26+ # startup crashes on CI Android get extra cleanup between attempts.
2727
2828set -euo pipefail
2929
@@ -167,7 +167,29 @@ cleanup_devicelab_driver() {
167167 sleep 8
168168}
169169
170- run_maestro () {
170+ collect_flow_files () {
171+ local item
172+ for item in $FLOWS ; do
173+ [ " $item " = " $ASSETS_DIR " ] && continue
174+ if [ -d " $item " ]; then
175+ find " $item " -name ' *.yaml' | sort
176+ elif [ -f " $item " ]; then
177+ echo " $item "
178+ fi
179+ done
180+ }
181+
182+ maestro_test_paths () {
183+ local flow=" $1 "
184+ local paths=" "
185+ [ -d " $ASSETS_DIR " ] && paths=" $ASSETS_DIR "
186+ paths+=" $flow "
187+ echo " $paths "
188+ }
189+
190+ run_maestro_with_targets () {
191+ local test_targets=" $1 "
192+ shift
171193 local max_attempts rc tmp attempt=1 delayed_retry=0
172194 if [ -n " ${MAESTRO_MAX_RETRIES:- } " ]; then
173195 max_attempts=" $MAESTRO_MAX_RETRIES "
@@ -184,11 +206,11 @@ run_maestro() {
184206 # Global flags (--device, --driver, --env, tags) come before `test`.
185207 if [[ " $OSTYPE " == darwin* ]]; then
186208 # shellcheck disable=SC2086
187- script -q /dev/null " $MAESTRO_BIN " --platform " $PLATFORM " --device " $DEVICE_ID " $DRIVER_ARGS $EXTRA " $@ " test $FLOWS 2>&1 | tee " $tmp "
209+ script -q /dev/null " $MAESTRO_BIN " --platform " $PLATFORM " --device " $DEVICE_ID " $DRIVER_ARGS $EXTRA " $@ " test $test_targets 2>&1 | tee " $tmp "
188210 else
189211 local cmd
190212 # shellcheck disable=SC2086
191- cmd=$( printf ' %q ' " $MAESTRO_BIN " --platform " $PLATFORM " --device " $DEVICE_ID " $DRIVER_ARGS $EXTRA " $@ " test $FLOWS )
213+ cmd=$( printf ' %q ' " $MAESTRO_BIN " --platform " $PLATFORM " --device " $DEVICE_ID " $DRIVER_ARGS $EXTRA " $@ " test $test_targets )
192214 script -qec " $cmd " /dev/null 2>&1 | tee " $tmp "
193215 fi
194216 rc=${PIPESTATUS[0]}
@@ -236,6 +258,20 @@ run_maestro() {
236258 done
237259}
238260
261+ run_maestro () {
262+ if is_ci; then
263+ local flow failed=0
264+ while IFS= read -r flow; do
265+ [ -z " $flow " ] && continue
266+ echo " === Running flow: $flow ==="
267+ run_maestro_with_targets " $( maestro_test_paths " $flow " ) " " $@ " || failed=1
268+ done < <( collect_flow_files)
269+ return " $failed "
270+ fi
271+
272+ run_maestro_with_targets " $FLOWS " " $@ "
273+ }
274+
239275set +e
240276
241277echo " === Running maestro tests ==="
0 commit comments