From 175cd7fdca1710c49470bba50ce487fac051be50 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Mon, 31 Aug 2026 22:52:20 -0400 Subject: [PATCH] Gate on clojure.jdbc's own test suite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This library's job is to run the published clojure.jdbc unmodified on a java.sql shim. Only upstream's tests can say whether it still does: the suite in clj-test is ours, so it agrees with our own idea of the API and kept passing while five real gaps sat behind it — the ones #15 fixed once upstream's suite was pointed at the shim for the first time. The tests come from upstream's tree at the sha deps.edn already pins, read out of deps.edn rather than repeated in the script, so a bump to the clojure.jdbc pin moves this gate with it instead of leaving it on an older tree that still passes. Copying the test files in here would drift the other way: they would go on agreeing with whatever the shim had become. Upstream ships its tests outside :paths, so they cannot be reached by an alias in our deps.edn. The script assembles a throwaway project with db as a :local/root and the checkout's test/ on the source roots. The namespaces are the sqlite-only set upstream nominates in its own tests-jolt.edn; jdbc.postgres-test needs a live postgres and hikari-cp, and db's own suite covers the postgres driver. Verified both ways: green as it stands (25 tests, 78 assertions), and exit 1 naming the regression when PreparedStatement's getConnection is removed. --- .github/workflows/tests.yml | 8 ++++++ ci/clojure-jdbc-conformance.sh | 48 ++++++++++++++++++++++++++++++++ conformance/jdbc_conformance.clj | 27 ++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100755 ci/clojure-jdbc-conformance.sh create mode 100644 conformance/jdbc_conformance.clj diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 19a5389..2fbd2c7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,3 +29,11 @@ jobs: echo "$HOME/.jolt" >> "$GITHUB_PATH" - name: Test run: JOLT_TEST_PG_URI=postgres://postgres:postgres@127.0.0.1:5432/jolt_test JOLT_PWD="$PWD" jolt -M:test + + # clojure.jdbc's OWN suite, from its tree at the sha deps.edn pins. This + # library's job is to run the published clojure.jdbc unmodified, and only + # upstream's tests can say whether it still does — the suite here is ours + # and agrees with our own idea of the API. It ran for the first time in + # #15 and found five gaps. + - name: clojure.jdbc conformance + run: ./ci/clojure-jdbc-conformance.sh diff --git a/ci/clojure-jdbc-conformance.sh b/ci/clojure-jdbc-conformance.sh new file mode 100755 index 0000000..7c3ffbf --- /dev/null +++ b/ci/clojure-jdbc-conformance.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Run clojure.jdbc's own test suite against db.jdbc-shim. +# +# The tests come from upstream's tree at the sha deps.edn already pins, so this +# gate and the library under test can never disagree about which clojure.jdbc is +# meant. Vendoring the test files here would drift: they would keep passing +# against whatever the shim had become. +# +# Upstream ships its tests outside :paths, so they cannot be reached by adding +# an alias to db's own deps.edn. A throwaway project is assembled instead, with +# db as a :local/root and the checkout's test/ directory on the source roots. +set -eu + +db_root=$(cd "$(dirname "$0")/.." && pwd) +work=${TMPDIR:-/tmp}/jdbc-conformance.$$ +trap 'rm -rf "$work"' EXIT +mkdir -p "$work/checkout" "$work/project" + +# The coordinates come out of deps.edn rather than being repeated here: a bump +# to the clojure.jdbc pin must move this gate with it, not leave it testing an +# older tree that still passes. +read_dep() { + jolt -e "(let [d (:deps (read-string (slurp \"$db_root/deps.edn\"))) + e (val (first (filter (fn [[k _]] (= (name k) \"clojure.jdbc\")) d)))] + (println ($1 e)))" +} +url=$(read_dep :git/url) +sha=$(read_dep :git/sha) +[ -n "$url" ] && [ -n "$sha" ] || { echo "could not read the clojure.jdbc pin from deps.edn" >&2; exit 1; } +echo "clojure.jdbc conformance: $url @ $sha" + +# Fetch the one commit rather than cloning the history. +cd "$work/checkout" +git init -q . +git remote add origin "$url" +git fetch -q --depth 1 origin "$sha" +git checkout -q FETCH_HEAD +[ -d test ] || { echo "no test/ directory at $sha" >&2; exit 1; } + +cat > "$work/project/deps.edn" <