# shellcheck shell=bash # lib.sh — helpers shared by the e2e cases in tests/e2e/. Every case starts with # . "$(dirname "$0")/lib.sh" # and ends with `finish`. scripts/ci/e2e-run.sh sets REPO, GENOME_DIR, SAMPLE, # FIXTURE_DIR, E2E_WORK and E2E_NOTES before it runs a case. # # A case never stops at the first failed check: it runs them all, prints one # [PASS] or [FAIL] line each, and `finish` exits 1 if any failed. Every check is # a count, a column or a content match; an exit code alone is never enough. set -uo pipefail : "${REPO:?run the cases through scripts/ci/e2e-run.sh}" : "${GENOME_DIR:?}" "${SAMPLE:?}" "${FIXTURE_DIR:?}" "${E2E_WORK:?}" "${E2E_NOTES:?}" # shellcheck source=../../versions.env . "${REPO}/versions.env" CASE_NAME="$(basename "$0" .sh)" CASE_TMP="${E2E_WORK}/tmp/${CASE_NAME}" mkdir -p "$CASE_TMP" FAILS=0 STEP_RC="" STEP_LOG="${CASE_TMP}/step.log" pass() { echo "[PASS] $*"; } fail() { echo "[FAIL] $*"; FAILS=$((FAILS + 1)); } # check : passes when the command succeeds. check() { local desc=$1; shift if "$@"; then pass "$desc"; else fail "$desc"; fi } check_eq() { if [ "$2" = "$3" ]; then pass "$1 (${2})"; else fail "$1 (got '${2}', want '${3}')"; fi } check_ge() { if [[ "$2" =~ ^[0-9]+$ ]] && [ "$2" -ge "$3" ]; then pass "$1 (${2} >= ${3})" else fail "$1 (got '${2}', want >= ${3})"; fi } has() { grep -Eq -- "$1" <<< "$2"; } lacks() { ! grep -Eq -- "$1" <<< "$2"; } # run_step