|
7 | 7 | Ported from test/bone-digest-test.clj (bb version)." |
8 | 8 | (:require [clojure.edn :as edn] |
9 | 9 | [clojure.string :as str] |
10 | | - [clojure.test :refer [deftest is testing use-fixtures]] |
| 10 | + [clojure.test :refer [are deftest is testing use-fixtures]] |
11 | 11 | [datalevin.core :as d] |
12 | 12 | [bone.commands :as commands] |
13 | 13 | [bone.common :as common] |
|
2097 | 2097 | (finally |
2098 | 2098 | (teardown! ctx)))))) |
2099 | 2099 |
|
| 2100 | +(deftest normalize-subject-widening |
| 2101 | + (testing "parenthesized version markers and punctuation don't split |
| 2102 | + otherwise-identical subjects (real corpus cases), but |
| 2103 | + distinct wording still does" |
| 2104 | + (let [norm #'digest/normalize-subject] |
| 2105 | + (are [a b] (= (norm a) (norm b)) |
| 2106 | + "Re: [PATCH] (v3) New LaTeX code export option: engraved" |
| 2107 | + "[PATCH] New LaTeX code export option: engraved" |
| 2108 | + "[PATCH v1] org-agenda-clock-goto: Jump to closest entry and respect, filtering" |
| 2109 | + "[PATCH v2] org-agenda-clock-goto: Jump to closest entry and respect filtering" |
| 2110 | + "[PATCH] ox-md.el export code blocks using grave accents." |
| 2111 | + "Re: [PATCH] ox-md.el export code blocks using grave accents" |
| 2112 | + "Re: [PATCH] org-protocol: decode \"+\" in query part as space (v2)" |
| 2113 | + "[PATCH] org-protocol: decode \"+\" in query part as space") |
| 2114 | + (are [a b] (not= (norm a) (norm b)) |
| 2115 | + "[PATCH] Speed up tangling" "[PATCH] Improve tangling" |
| 2116 | + ;; parenthesized text that is NOT a version marker is kept |
| 2117 | + "add tests for ob-haskell (ghci)" "add tests for ob-haskell" |
| 2118 | + ;; bare numbers are significant (series positions, counts) |
| 2119 | + "[PATCH] Fix part 2" "[PATCH] Fix part 3") |
| 2120 | + (is (nil? (norm "[PATCH]")) |
| 2121 | + "a subject with nothing but tags normalizes to nil, never to a matchable empty string")))) |
| 2122 | + |
| 2123 | +(deftest supersede-tolerates-version-marker-and-punctuation |
| 2124 | + (testing "an unnumbered re-send whose subject differs only by a |
| 2125 | + parenthesized version marker and punctuation still |
| 2126 | + supersedes the original (real cases: '(v3) New LaTeX code |
| 2127 | + export option' / 'respect, filtering')" |
| 2128 | + (let [{:keys [conn] :as ctx} (setup-db!)] |
| 2129 | + (try |
| 2130 | + (store-and-process! conn |
| 2131 | + (mk-email {:mid "<v1@test.org>" |
| 2132 | + :subject "[PATCH] widget: fix the thing, properly" |
| 2133 | + :from "user@test.org" |
| 2134 | + :date #inst "2026-06-08T19:15:00" |
| 2135 | + :body "Initial patch.\n"}) |
| 2136 | + "direct") |
| 2137 | + (store-and-process! conn |
| 2138 | + (assoc (mk-email {:mid "<v2@test.org>" |
| 2139 | + :subject "Re: [PATCH] (v2) widget: fix the thing properly" |
| 2140 | + :from "user@test.org" |
| 2141 | + :date #inst "2026-06-12T14:59:00" |
| 2142 | + :in-reply-to "<v1@test.org>" |
| 2143 | + :body "Updated version of the patch.\n"}) |
| 2144 | + :email/attachments [{:attachment/filename "0001-fix.patch"}]) |
| 2145 | + "direct") |
| 2146 | + (let [db (d/db conn) |
| 2147 | + v1 (get-report db "<v1@test.org>") |
| 2148 | + v2 (get-report db "<v2@test.org>")] |
| 2149 | + (is (some? v2) "v2 report was created") |
| 2150 | + (is (some? (:report/closed v1)) |
| 2151 | + "v1 closed despite the (v2) marker and comma in one subject") |
| 2152 | + (is (= :superseded (:report/close-reason v1))) |
| 2153 | + (is (nil? (:report/closed v2)) "v2 itself stays open")) |
| 2154 | + (finally |
| 2155 | + (teardown! ctx)))))) |
| 2156 | + |
| 2157 | +(deftest supersede-bare-patch-subject-falls-back-to-idents |
| 2158 | + (testing "a bare '[PATCH]' subject normalizes to nil, so it can't |
| 2159 | + subject-match anything (no more \"\" == \"\" collisions); |
| 2160 | + instead, matching patch identifiers on both sides stand in |
| 2161 | + for the subject (real case: 87fstreec8, tecosaur's |
| 2162 | + proportional image widths patch resent as 'Re: [PATCH]')" |
| 2163 | + (let [{:keys [conn] :as ctx} (setup-db!)] |
| 2164 | + (try |
| 2165 | + (store-and-process! conn |
| 2166 | + (assoc (mk-email {:mid "<a@test.org>" |
| 2167 | + :subject "[PATCH]" |
| 2168 | + :from "user@test.org" |
| 2169 | + :date #inst "2021-05-01T00:00:00" |
| 2170 | + :body "Patch A.\n"}) |
| 2171 | + :email/attachments |
| 2172 | + [(fp-attachment "0001-org-Display-proportional-image-widths.patch" |
| 2173 | + "[PATCH] org: Display proportional image widths")]) |
| 2174 | + "direct") |
| 2175 | + ;; B: also subject-less, direct reply, but a DIFFERENT patch. |
| 2176 | + (store-and-process! conn |
| 2177 | + (assoc (mk-email {:mid "<b@test.org>" |
| 2178 | + :subject "Re: [PATCH]" |
| 2179 | + :from "user@test.org" |
| 2180 | + :date #inst "2021-05-02T00:00:00" |
| 2181 | + :in-reply-to "<a@test.org>" |
| 2182 | + :body "Patch B, unrelated.\n"}) |
| 2183 | + :email/attachments |
| 2184 | + [(fp-attachment "0001-ox-html.el-remove-CDATA-strings.patch" |
| 2185 | + "[PATCH] ox-html.el: remove CDATA strings")]) |
| 2186 | + "direct") |
| 2187 | + (let [db (d/db conn) |
| 2188 | + a (get-report db "<a@test.org>")] |
| 2189 | + (is (nil? (:report/closed a)) |
| 2190 | + "A stays OPEN: no subject signal and B's idents differ")) |
| 2191 | + ;; C: subject-less re-send of the SAME patch -- idents stand in. |
| 2192 | + (store-and-process! conn |
| 2193 | + (assoc (mk-email {:mid "<c@test.org>" |
| 2194 | + :subject "Re: [PATCH]" |
| 2195 | + :from "user@test.org" |
| 2196 | + :date #inst "2021-05-03T00:00:00" |
| 2197 | + :in-reply-to "<a@test.org>" |
| 2198 | + :body "Patch A, updated.\n"}) |
| 2199 | + :email/attachments |
| 2200 | + [(fp-attachment "0001-org-Display-proportional-image-widths.patch" |
| 2201 | + "[PATCH] org: Display proportional image widths")]) |
| 2202 | + "direct") |
| 2203 | + (let [db (d/db conn) |
| 2204 | + a (get-report db "<a@test.org>")] |
| 2205 | + (is (some? (:report/closed a)) |
| 2206 | + "A closed: C carries the same patch, idents replace the missing subject") |
| 2207 | + (is (= :superseded (:report/close-reason a)))) |
| 2208 | + (finally |
| 2209 | + (teardown! ctx)))))) |
| 2210 | + |
2100 | 2211 | ;; --------------------------------------------------------------------------- |
2101 | 2212 | ;; report-entity :report/has-ics is scoped to announcements |
2102 | 2213 | ;; --------------------------------------------------------------------------- |
|
0 commit comments