summaryrefslogtreecommitdiffstats
path: root/tests/mkhint_test.sh
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-07-05 20:01:10 +0200
committerDanilo M. <danix@danix.xyz>2026-07-05 20:01:10 +0200
commit10407e9d48cd64ca85723bd7b444846b9633fc57 (patch)
treeb894d186134ae683041699f0f932dcfe56195950 /tests/mkhint_test.sh
parente216ee2b156bad7d2359acb6e12f96670b57d3ac (diff)
downloadmkhintfile-10407e9d48cd64ca85723bd7b444846b9633fc57.tar.gz
mkhintfile-10407e9d48cd64ca85723bd7b444846b9633fc57.zip
test: harness support for slackrepo stub and PACKAGES_DIR
Diffstat (limited to 'tests/mkhint_test.sh')
-rwxr-xr-xtests/mkhint_test.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/mkhint_test.sh b/tests/mkhint_test.sh
index d34f90f..fc84bf9 100755
--- a/tests/mkhint_test.sh
+++ b/tests/mkhint_test.sh
@@ -5,6 +5,7 @@ SCRIPT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/mkhint"
MOCK_BASE="/tmp/mkhint_test_$$"
MOCK_REPO="$MOCK_BASE/repo"
MOCK_HINT="$MOCK_BASE/hints"
+MOCK_PKGS="$MOCK_BASE/packages"
MOCK_TMP="$MOCK_BASE/tmp"
PASS=0
@@ -182,6 +183,8 @@ run_mkhint() {
-e "s|TMP_DIR=\".*\"|TMP_DIR=\"$MOCK_TMP\"|" \
-e "s|NVCHECKER_CONFIG=\".*\"|NVCHECKER_CONFIG=\"$MOCK_BASE/nvchecker.toml\"|" \
-e "s|PHANTOM_DEPS_FILE=\".*\"|PHANTOM_DEPS_FILE=\"$MOCK_BASE/phantom-deps\"|" \
+ -e "s|PACKAGES_DIR=\".*\"|PACKAGES_DIR=\"$MOCK_PKGS\"|" \
+ -e "s|MKHINT_CONFIG=\".*\"|MKHINT_CONFIG=\"$MOCK_BASE/config\"|" \
"$SCRIPT" > "$tmp_script"
bash "$tmp_script" "$@"
local rc=$?
@@ -236,6 +239,25 @@ EOF
fi
}
+# Stub slackrepo: log "<action> <args...>" to $MOCK_BASE/slackrepo.log
+mock_slackrepo() {
+ mkdir -p "$MOCK_BASE/bin"
+ cat > "$MOCK_BASE/bin/slackrepo" << 'EOF'
+#!/bin/bash
+echo "$*" >> "$SLACKREPO_LOG"
+exit 0
+EOF
+ chmod +x "$MOCK_BASE/bin/slackrepo"
+ export SLACKREPO_LOG="$MOCK_BASE/slackrepo.log"
+}
+
+# Create a fake built package: $1=category $2=pkgname $3=version
+seed_pkg() {
+ local cat="$1" pkg="$2" ver="$3"
+ mkdir -p "$MOCK_PKGS/$cat/$pkg"
+ : > "$MOCK_PKGS/$cat/$pkg/${pkg}-${ver}-x86_64-1_danix.txz"
+}
+
assert_contains() {
local desc="$1" file="$2" pattern="$3"
if grep -q "$pattern" "$file" 2>/dev/null; then
@@ -309,6 +331,7 @@ echo "========================================"
setup
mock_wget
mock_nvchecker_tools
+mock_slackrepo
# ── T1: --new from .info, no version ──────────────────────────────────────────
echo ""