aboutsummaryrefslogtreecommitdiffstats
path: root/.extras/test-logic.sh
diff options
context:
space:
mode:
Diffstat (limited to '.extras/test-logic.sh')
-rw-r--r--.extras/test-logic.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/.extras/test-logic.sh b/.extras/test-logic.sh
index 0616c99..469ac1d 100644
--- a/.extras/test-logic.sh
+++ b/.extras/test-logic.sh
@@ -67,6 +67,23 @@ order="${order% }"
resolve_target "$T/cat/d"
[[ ${#UNMET[@]} -eq 1 ]] && ok "unmet-dep caught" || bad "unmet-dep missed"
+# --- resolve_target_dir (target from CWD/path, NOT the SBo tree) -------------
+# Local package dir, separate from the fake SBo tree above.
+LOCALREPO=$(mktemp -d); mkdir -p "$LOCALREPO/mypkg"
+echo 'REQUIRES=""' > "$LOCALREPO/mypkg/mypkg.info"
+# 1. absolute path
+got="$(resolve_target_dir "$LOCALREPO/mypkg" 2>/dev/null)"
+[[ "$got" == "$LOCALREPO/mypkg" ]] && ok "target: absolute path" || bad "abs path got [$got]"
+# 2. bare name resolved under CWD (./mypkg/)
+got="$(cd "$LOCALREPO" && resolve_target_dir "mypkg" 2>/dev/null)"
+[[ "$got" == "$LOCALREPO/mypkg" ]] && ok "target: bare name in CWD" || bad "bare-in-cwd got [$got]"
+# 3. CWD itself is the package
+got="$(cd "$LOCALREPO/mypkg" && resolve_target_dir "mypkg" 2>/dev/null)"
+[[ "$got" == "$LOCALREPO/mypkg" ]] && ok "target: CWD is the package" || bad "cwd-is-pkg got [$got]"
+# 4. missing -> failure
+resolve_target_dir "nosuchpkg" >/dev/null 2>&1 && bad "missing target should fail" || ok "target: missing fails"
+rm -rf "$LOCALREPO"
+
resolve_target "$T/cat/e"
[[ ${#CYCLES[@]} -ge 1 ]] && ok "cycle caught" || bad "cycle missed"