aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-07-03 13:15:49 +0200
committerDanilo M. <danix@danix.xyz>2026-07-03 13:15:49 +0200
commit21aabc67cb9e8e76c6fab6727690a3a9c02a98da (patch)
tree8f80dd92386be5055a12b9cd68dbba5c71d1ad92 /tests
parent5fdb01eaaa88146e31a611423b269678074085f3 (diff)
downloadmkhintfile-21aabc67cb9e8e76c6fab6727690a3a9c02a98da.tar.gz
mkhintfile-21aabc67cb9e8e76c6fab6727690a3a9c02a98da.zip
feat: treat dashed upstream version as equivalent to packaged underscore form
SlackBuild versions cannot contain '-' (it breaks PRGNAM parsing), so an upstream date like 2026-06-02 is packaged as 2026_06_02. mkhint was comparing them byte-for-byte and offering a spurious upgrade/downgrade. Add _normalize_version ('-' -> '_') and apply it to the upstream version in --check and --hintfile (no -v) before comparing and before storing, so equivalent versions compare equal and accepted updates are written in the underscore form. nvtake still uses nvchecker's raw keyfile value. Tests T48/T49 cover equivalence and normalized storage (105 passing). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/mkhint_test.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/mkhint_test.sh b/tests/mkhint_test.sh
index 102790d..4aa0c2d 100755
--- a/tests/mkhint_test.sh
+++ b/tests/mkhint_test.sh
@@ -937,6 +937,44 @@ code=$?
set -e
assert_exit_code "missing named hint exits 2" 2 "$code"
+# ── T48: --check upstream dashed date == packaged underscore date → current ────
+echo ""
+echo "T48: --check upstream 2026-06-02 vs hint 2026_06_02 → treated as current"
+rm -f "$MOCK_HINT"/*.hint "$MOCK_HINT"/*.bak 2>/dev/null
+cat > "$MOCK_BASE/new_ver.json" << 'EOF'
+{ "version": 2, "data": { "curl": { "version": "2026-06-02" } } }
+EOF
+cat > "$MOCK_HINT/curl.hint" << 'EOF'
+VERSION="2026_06_02"
+ARCH="x86_64"
+DOWNLOAD="https://curl.se/download/curl-2026_06_02.tar.gz"
+MD5SUM="abc123def456abc123def456abc123de"
+DOWNLOAD_x86_64=""
+MD5SUM_x86_64=""
+EOF
+out=$(run_mkhint -C curl < <(printf '\n') 2>&1)
+echo "$out" | grep -q "all up to date" \
+ && { echo " PASS: dashed upstream == underscore packaged"; (( PASS++ )); } \
+ || { echo " FAIL: offered an update for equivalent version"; echo "$out" | sed 's/^/ /'; (( FAIL++ )); ERRORS+=("T48 dash/underscore equivalence"); }
+
+# ── T49: --check accept dashed upstream update → hint stores underscore form ────
+echo ""
+echo "T49: --check accept 2026-07-01 → hint VERSION written as 2026_07_01"
+cat > "$MOCK_BASE/new_ver.json" << 'EOF'
+{ "version": 2, "data": { "curl": { "version": "2026-07-01" } } }
+EOF
+cat > "$MOCK_HINT/curl.hint" << 'EOF'
+VERSION="2026_06_02"
+ARCH="x86_64"
+DOWNLOAD="https://curl.se/download/curl-2026_06_02.tar.gz"
+MD5SUM="abc123def456abc123def456abc123de"
+DOWNLOAD_x86_64=""
+MD5SUM_x86_64=""
+EOF
+# accept update (Y), decline slackrepo (n)
+run_mkhint -C curl < <(printf 'Y\nn\n')
+assert_contains "hint stores normalized version" "$MOCK_HINT/curl.hint" 'VERSION="2026_07_01"'
+
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
teardown