11#! /usr/bin/env bash
22# Loop running HLS tasty tests until a Broken pipe or test failure is observed.
33# Originally ran only the "open close" test; now supports multiple patterns.
4+ # Ensures successful build before running any tests.
45# Logs each run to test-logs/<pattern-slug>-loop-<n>.log, rotating every 100 files per pattern.
56#
67# Environment you can tweak:
78# MAX_ITER : maximum iterations before giving up (default: 1000)
89# SLEEP_SECS : seconds to sleep between iterations (default: 0)
910# SHOW_EVERY : print progress/iteration header every N iterations (default: 100, 1 = every run, <=0 = disabled)
1011# LOG_STDERR : set to 1 to enable verbose stderr logging (HLS_TEST_LOG_STDERR & HLS_TEST_HARNESS_STDERR) (default: 1)
11- # TEST_BIN : path to the built test binary (auto-discovered if not set)
1212# NO_BUILD_ONCE : set to non-empty to skip the initial cabal build step
1313#
1414# Test selection:
@@ -58,7 +58,7 @@ echo "[loop] Starting at ${start_ts}" >&2
5858# - Use case-insensitive extended regex for failures/timeouts in logs
5959# - Broken pipe: case-insensitive fixed-string search
6060BROKEN_PIPE_RE=' Broken pipe'
61- TEST_FAILED_RE=' fail |timeout'
61+ TEST_FAILED_RE=' failed |timeout'
6262DEBUG_DETECT=" ${DEBUG_DETECT:- 0} "
6363
6464# Resolve what to run each iteration as pairs of BIN and PATTERN
@@ -96,8 +96,8 @@ if [[ ${#items[@]} -eq 0 ]]; then
9696 exit 2
9797fi
9898
99- # Build required test binaries once upfront (unless NO_BUILD_ONCE is set or TEST_BIN overrides )
100- if [[ -z " ${NO_BUILD_ONCE:- } " && -z " ${TEST_BIN :- } " ]]; then
99+ # Build required test binaries once upfront (unless NO_BUILD_ONCE is set)
100+ if [[ -z " ${NO_BUILD_ONCE:- } " ]]; then
101101 # collect unique BIN names
102102 declare -a bins_to_build=()
103103 for it in " ${items[@]} " ; do
@@ -109,7 +109,11 @@ if [[ -z "${NO_BUILD_ONCE:-}" && -z "${TEST_BIN:-}" ]]; then
109109 done
110110 if (( ${# bins_to_build[@]} > 0 )) ; then
111111 echo " [loop] Building test targets once upfront: ${bins_to_build[*]} " >&2
112- cabal build " ${bins_to_build[@]} " >&2 || true
112+ if ! cabal build " ${bins_to_build[@]} " >&2 ; then
113+ echo " [loop][error] Build failed. Cannot proceed with tests." >&2
114+ exit 2
115+ fi
116+ echo " [loop] Build succeeded. Proceeding with tests." >&2
113117 fi
114118fi
115119
@@ -125,11 +129,7 @@ get_bin_path() {
125129 fi
126130 done
127131 local path=" "
128- if [[ -n " ${TEST_BIN:- } " ]]; then
129- path=" ${TEST_BIN} "
130- else
131- path=$( find dist-newstyle -type f -name " $name " -perm -111 2> /dev/null | head -n1 || true)
132- fi
132+ path=$( find dist-newstyle -type f -name " $name " -perm -111 2> /dev/null | head -n1 || true)
133133 BIN_NAMES+=(" $name " ); BIN_PATHS+=(" $path " )
134134 echo " $path "
135135}
0 commit comments