aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-07-07 18:34:00 +0200
committerDanilo M. <danix@danix.xyz>2026-07-07 18:34:00 +0200
commit84904cb9dba93b7466e7847efdf6dfa48541a31a (patch)
tree774c4f2ac9ce0b161d7c8fd2f074147240704456
parentf0e458c39b475a887c43c7f4d3616ebb94f798ac (diff)
downloadmkhintfile-84904cb9dba93b7466e7847efdf6dfa48541a31a.tar.gz
mkhintfile-84904cb9dba93b7466e7847efdf6dfa48541a31a.zip
feat: fetch_manifest + fake-wget manifest fixture support
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
-rwxr-xr-xmkhint12
-rwxr-xr-xtests/mkhint_test.sh37
2 files changed, 41 insertions, 8 deletions
diff --git a/mkhint b/mkhint
index 2a18abc..544bdee 100755
--- a/mkhint
+++ b/mkhint
@@ -513,6 +513,18 @@ manifest_url_for() {
pkg_has_manifest() {
[[ -n "${BUNDLE_MANIFESTS[$1]:-}" ]]
}
+
+# fetch_manifest <url> — download the manifest to a temp file, echo its path.
+# Non-zero on wget failure. Caller cleans up (path is under TMP_DIR).
+fetch_manifest() {
+ local url="$1"
+ [[ -d "$TMP_DIR" ]] || mkdir -p "$TMP_DIR"
+ local out="${TMP_DIR}/manifest"
+ rm -f "$out"
+ wget -O "$out" "$url" >&2 || return 1
+ [[ -s "$out" ]] || return 1
+ printf '%s\n' "$out"
+}
# ── end bundled-dep manifest handling ─────────────────────────────────────────
# Create new hint file
diff --git a/tests/mkhint_test.sh b/tests/mkhint_test.sh
index 959cbdb..e9e50ac 100755
--- a/tests/mkhint_test.sh
+++ b/tests/mkhint_test.sh
@@ -209,22 +209,29 @@ run_mkhint() {
return $rc
}
-# Mock wget — writes fake content, md5 will be deterministic
+# Mock wget — writes fake content, md5 will be deterministic. URLs containing
+# deps.txt instead serve a manifest fixture ($MOCK_BASE/manifest_fixture) if
+# present, so bundled-dep manifest tests can control fetch_manifest's input.
mock_wget() {
# Replace wget in PATH with a fake that writes URL as content
mkdir -p "$MOCK_BASE/bin"
- cat > "$MOCK_BASE/bin/wget" << 'EOF'
+ cat > "$MOCK_BASE/bin/wget" << EOF
#!/bin/bash
-# fake wget: write URL to -O target
url=""
out=""
-while [[ $# -gt 0 ]]; do
- case "$1" in
- -O) out="$2"; shift 2 ;;
- *) url="$1"; shift ;;
+while [[ \$# -gt 0 ]]; do
+ case "\$1" in
+ -O) out="\$2"; shift 2 ;;
+ *) url="\$1"; shift ;;
esac
done
-echo "FAKE_CONTENT_FOR_${url}" > "$out"
+if [[ "\$url" == *deps.txt* && -f "$MOCK_BASE/manifest_fixture" ]]; then
+ cat "$MOCK_BASE/manifest_fixture" > "\$out"
+elif [[ "\$url" == *deps.txt* ]]; then
+ exit 1 # simulate manifest fetch failure when no fixture set
+else
+ echo "FAKE_CONTENT_FOR_\${url}" > "\$out"
+fi
exit 0
EOF
chmod +x "$MOCK_BASE/bin/wget"
@@ -1531,6 +1538,20 @@ set -e
&& { echo " PASS: unlisted pkg non-zero"; (( PASS++ )); } \
|| { echo " FAIL: unlisted pkg should be non-zero"; (( FAIL++ )); ERRORS+=("T-BM6b"); }
+# ── T-BM7: fetch_manifest downloads to a temp file ───────────────────────────
+echo ""
+echo "T-BM7: fetch_manifest returns a path with the fixture content"
+cat > "$MOCK_BASE/manifest_fixture" << 'EOF'
+LIBUV_URL https://github.com/libuv/libuv/archive/v1.52.1.tar.gz
+LIBUV_SHA256 abc
+EOF
+BM_SRC='source <(sed -n "/# ── bundled-dep manifest handling/,/# ── end bundled-dep/p" '"$SCRIPT"')'
+mpath=$(bash -c "TMP_DIR='$MOCK_TMP'; PATH=\"$MOCK_BASE/bin:\$PATH\"; $BM_SRC; fetch_manifest 'https://example.com/v1/deps.txt'")
+[[ -f "$mpath" ]] && grep -q 'LIBUV_URL' "$mpath" \
+ && { echo " PASS: fetch_manifest content"; (( PASS++ )); } \
+ || { echo " FAIL: fetch_manifest path='$mpath'"; (( FAIL++ )); ERRORS+=("T-BM7"); }
+rm -f "$MOCK_BASE/manifest_fixture"
+
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
teardown