aboutsummaryrefslogtreecommitdiffstats
path: root/.extras/test-logic.sh
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-07-13 10:33:50 +0200
committerDanilo M. <danix@danix.xyz>2026-07-13 10:33:50 +0200
commit5d1fb3ab2e027176dfd29e6bcc69d606aa550c2b (patch)
treee564663957d18d4bee00cfb7f9496ac61b1bb687 /.extras/test-logic.sh
parent368023455770538ad0f7568ee83cf4cef0a4eabc (diff)
downloadsbo-slackbuilds-5d1fb3ab2e027176dfd29e6bcc69d606aa550c2b.tar.gz
sbo-slackbuilds-5d1fb3ab2e027176dfd29e6bcc69d606aa550c2b.zip
test-build: port dep cache, namespaced by image digest
Diffstat (limited to '.extras/test-logic.sh')
-rw-r--r--.extras/test-logic.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/.extras/test-logic.sh b/.extras/test-logic.sh
index e48586e..d4249bb 100644
--- a/.extras/test-logic.sh
+++ b/.extras/test-logic.sh
@@ -107,6 +107,32 @@ load_overrides
[[ ${#OV_DROP[@]} -eq 0 ]] && ok "overrides inert on 15.0" || bad "overrides applied on 15.0"
VERSION_ID="current"
+# --- cache ------------------------------------------------------------------
+PKG_CACHE=$(mktemp -d)
+CACHE_ROOT="$PKG_CACHE/sha256-deadbeef" # simulate a resolved digest namespace
+mkc() { mkdir -p "$CACHE_ROOT/$1/$2"; : > "$CACHE_ROOT/$1/$2/$3"; }
+
+mkc net libfoo "libfoo-1.1-x86_64-1_danix.txz"
+[[ "$(cache_decision net libfoo 1.1)" == "cached" ]] && ok "cache hit on version match" || bad "cache_decision got [$(cache_decision net libfoo 1.1)]"
+[[ "$(cache_decision net libfoo 1.2)" == "bump:1.1:1.2" ]] && ok "cache bump reported" || bad "cache bump got [$(cache_decision net libfoo 1.2)]"
+[[ "$(cache_decision net libbar 1.0)" == "new" ]] && ok "cache new for absent" || bad "cache new got [$(cache_decision net libbar 1.0)]"
+
+hit="$(cache_path net libfoo 1.1)"
+[[ "$hit" == "$CACHE_ROOT/net/libfoo/libfoo-1.1-x86_64-1_danix.txz" ]] && ok "cache_path returns hit" || bad "cache_path got [$hit]"
+[[ -z "$(cache_path net libfoo 9.9)" ]] && ok "cache_path empty on miss" || bad "cache_path not empty on miss"
+
+srctmp=$(mktemp -d); : > "$srctmp/libfoo-1.2-x86_64-1_danix.txz"
+cache_store net libfoo "$srctmp/libfoo-1.2-x86_64-1_danix.txz"
+count=$(find "$CACHE_ROOT/net/libfoo" -name '*.t?z' | wc -l)
+[[ "$count" -eq 1 ]] && ok "cache_store evicts to one file" || bad "cache_store left $count files"
+[[ -e "$CACHE_ROOT/net/libfoo/libfoo-1.2-x86_64-1_danix.txz" ]] && ok "cache_store stored new file" || bad "cache_store did not store"
+rm -rf "$srctmp"
+
+# disabled cache -> new
+CACHE_ROOT_SAVE="$CACHE_ROOT"; USE_CACHE=0
+[[ "$(cache_decision net libfoo 1.2)" == "new" ]] && ok "--no-cache disables (new)" || bad "disabled cache got [$(cache_decision net libfoo 1.2)]"
+USE_CACHE=1; CACHE_ROOT="$CACHE_ROOT_SAVE"
+
echo
echo "$pass passed, $fail failed"
[[ $fail -eq 0 ]] || exit 1