diff options
| author | Danilo M. <danix@danix.xyz> | 2026-07-07 18:23:03 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-07-07 18:23:03 +0200 |
| commit | 375b2b74e3ff11a7029ec8de7ca8cb8167b2f6a1 (patch) | |
| tree | f1341bb7029ef9c7ac12c75d50737c4621384e6e /tests/mkhint_test.sh | |
| parent | 6b7ca94be115b7678074b3880b8f127d17c5267e (diff) | |
| download | mkhintfile-375b2b74e3ff11a7029ec8de7ca8cb8167b2f6a1.tar.gz mkhintfile-375b2b74e3ff11a7029ec8de7ca8cb8167b2f6a1.zip | |
feat: match_dep_url maps a hint download line to a manifest URL
Repo-path match first, exact basename-stem fallback for blob hosts. Blob
host repo (owner/deps) is excluded from repo-path matching so it resolves
by stem.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'tests/mkhint_test.sh')
| -rwxr-xr-x | tests/mkhint_test.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/mkhint_test.sh b/tests/mkhint_test.sh index 9830f3b..908b738 100755 --- a/tests/mkhint_test.sh +++ b/tests/mkhint_test.sh @@ -1473,6 +1473,44 @@ echo "$bm_out" | grep -qx 'https://github.com/libuv/libuv/archive/v1.52.1.tar.gz && { echo " PASS: parse_manifest URLs only"; (( PASS++ )); } \ || { echo " FAIL: parse_manifest: $bm_out"; (( FAIL++ )); ERRORS+=("T-BM1"); } +# ── T-BM2: match_dep_url repo-path hit ─────────────────────────────────────── +echo "" +echo "T-BM2: match_dep_url matches by owner/repo path" +BM_SRC='source <(sed -n "/# ── bundled-dep manifest handling/,/# ── end bundled-dep/p" '"$SCRIPT"')' +manifest_urls='https://github.com/tree-sitter/tree-sitter/archive/v0.26.8.tar.gz +https://github.com/luvit/luv/archive/1.53.0-0.tar.gz' +r=$(bash -c "$BM_SRC; match_dep_url 'https://github.com/tree-sitter/tree-sitter/archive/v0.26.7/tree-sitter-0.26.7.tar.gz' \"\$1\"" _ "$manifest_urls") +[[ "$r" == 'https://github.com/tree-sitter/tree-sitter/archive/v0.26.8.tar.gz' ]] \ + && { echo " PASS: repo-path match"; (( PASS++ )); } \ + || { echo " FAIL: repo-path match got '$r'"; (( FAIL++ )); ERRORS+=("T-BM2"); } + +# ── T-BM3: match_dep_url stem fallback for blob host ───────────────────────── +echo "" +echo "T-BM3: match_dep_url stem fallback (neovim/deps/raw blob → lpeg)" +manifest_urls='https://github.com/neovim/deps/raw/deadbeef1234567/opt/lpeg-1.1.0.tar.gz' +r=$(bash -c "$BM_SRC; match_dep_url 'https://www.inf.puc-rio.br/~roberto/lpeg/lpeg-1.1.0.tar.gz' \"\$1\"" _ "$manifest_urls") +[[ "$r" == 'https://github.com/neovim/deps/raw/deadbeef1234567/opt/lpeg-1.1.0.tar.gz' ]] \ + && { echo " PASS: stem fallback match"; (( PASS++ )); } \ + || { echo " FAIL: stem fallback got '$r'"; (( FAIL++ )); ERRORS+=("T-BM3"); } + +# ── T-BM4: match_dep_url no false prefix match ─────────────────────────────── +echo "" +echo "T-BM4: match_dep_url does not match tree-sitter to tree-sitter-c" +manifest_urls='https://github.com/tree-sitter/tree-sitter-c/archive/v0.24.1.tar.gz' +r=$(bash -c "$BM_SRC; match_dep_url 'https://example.com/foo/tree-sitter-0.26.7.tar.gz' \"\$1\"" _ "$manifest_urls") || true +[[ -z "$r" ]] \ + && { echo " PASS: no false prefix match"; (( PASS++ )); } \ + || { echo " FAIL: false match got '$r'"; (( FAIL++ )); ERRORS+=("T-BM4"); } + +# ── T-BM5: match_dep_url no match → empty ──────────────────────────────────── +echo "" +echo "T-BM5: match_dep_url returns empty on no match" +manifest_urls='https://github.com/foo/bar/archive/v1.0.tar.gz' +r=$(bash -c "$BM_SRC; match_dep_url 'https://github.com/baz/qux/archive/v2.0.tar.gz' \"\$1\"" _ "$manifest_urls") || true +[[ -z "$r" ]] \ + && { echo " PASS: empty on no match"; (( PASS++ )); } \ + || { echo " FAIL: expected empty got '$r'"; (( FAIL++ )); ERRORS+=("T-BM5"); } + # ─── SUMMARY ────────────────────────────────────────────────────────────────── teardown |
