Skip to content

Commit 9fb2dd9

Browse files
committed
init_env: robust root discovery & idempotent load
- Add __INIT_ENV_LOADED guard to prevent double sourcing. - Detect ROOT_DIR (CWD or walk-up) and export TOOLS/paths. - Quietly source utils; fail fast if utils/functestlib.sh missing. - Fix empty so platform/network helpers are available. Signed-off-by: Srikanth Muppandam <[email protected]>
1 parent 609e0e0 commit 9fb2dd9

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Runner/init_env

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,25 @@ if [ -z "$ROOT_DIR" ]; then
2929
fi
3030
fi
3131

32-
if [ ! -d "$ROOT_DIR/utils" ] || [ ! -f "$ROOT_DIR/utils/functestlib.sh" ]; then
33-
echo "[ERROR] Could not detect testkit root (missing utils/ or functestlib.sh)" >&2
32+
# --- Validate and export key environment paths ---
33+
if [ -z "${ROOT_DIR:-}" ] || [ ! -d "$ROOT_DIR/utils" ] || [ ! -f "$ROOT_DIR/utils/functestlib.sh" ]; then
34+
echo "[ERROR] Could not detect testkit root (missing utils/ or functestlib.sh)" >&2
3435
exit 1
3536
fi
3637

3738
export ROOT_DIR
3839
export TOOLS="$ROOT_DIR/utils"
3940
export __RUNNER_SUITES_DIR="$ROOT_DIR/suites"
4041
export __RUNNER_UTILS_BIN_DIR="$ROOT_DIR/common"
42+
43+
# --- Ensure TOOLS is usable in all shells ---
44+
case ":$PATH:" in
45+
*":$TOOLS:"*) : ;;
46+
*) PATH="$TOOLS:$PATH"; export PATH ;;
47+
esac
48+
49+
# --- Optional: pre-check for required tools (safe no-op for minimal builds) ---
50+
if [ -f "$TOOLS/functestlib.sh" ]; then
51+
# shellcheck disable=SC1090,SC1091
52+
. "$TOOLS/functestlib.sh" >/dev/null 2>&1 || true
53+
fi

0 commit comments

Comments
 (0)