fix(journelly): use real cl-lib function names; re-enable ERT tests
journelly-parse-entry called cl-lib-find-if, cl-lib-position, cl-lib-subseq and cl-lib-remove-if, which do not exist and signal void-function at runtime. Rename them to the actual cl-lib names (cl-find-if, cl-position, cl-subseq, cl-remove-if) and re-enable the two ERT tests covering the parser. Both tests pass: (ert "test-journelly-*")
This commit is contained in:
@@ -13,14 +13,14 @@
|
|||||||
"Parse a journelly entry and return a journelly-entry struct."
|
"Parse a journelly entry and return a journelly-entry struct."
|
||||||
(let* ((lines (split-string entry-text "\n" t)) ; t omits null strings
|
(let* ((lines (split-string entry-text "\n" t)) ; t omits null strings
|
||||||
(heading (car lines))
|
(heading (car lines))
|
||||||
(url-line (cl-lib-find-if (lambda (l) (string-match-p "https?://" l)) lines))
|
(url-line (cl-find-if (lambda (l) (string-match-p "https?://" l)) lines))
|
||||||
(url-pos (cl-lib-position url-line lines :test 'equal))
|
(url-pos (cl-position url-line lines :test 'equal))
|
||||||
;; Title is the non-empty line before the URL
|
;; Title is the non-empty line before the URL
|
||||||
(title-line (when url-pos
|
(title-line (when url-pos
|
||||||
(cl-lib-find-if (lambda (l) (not (string-match-p "^[[:space:]]*$" l)))
|
(cl-find-if (lambda (l) (not (string-match-p "^[[:space:]]*$" l)))
|
||||||
(reverse (cl-lib-subseq lines 0 url-pos)))))
|
(reverse (cl-subseq lines 0 url-pos)))))
|
||||||
;; Content is everything except heading, title, and URL
|
;; Content is everything except heading, title, and URL
|
||||||
(content-lines (cl-lib-remove-if (lambda (l)
|
(content-lines (cl-remove-if (lambda (l)
|
||||||
(or (equal l heading)
|
(or (equal l heading)
|
||||||
(equal l title-line)
|
(equal l title-line)
|
||||||
(equal l url-line)))
|
(equal l url-line)))
|
||||||
@@ -66,32 +66,32 @@ and then lets you review before finalizing."
|
|||||||
(my/journelly-add-properties url heading)))
|
(my/journelly-add-properties url heading)))
|
||||||
|
|
||||||
|
|
||||||
;; (ert-deftest test-journelly-parse-basic ()
|
(ert-deftest test-journelly-parse-basic ()
|
||||||
;; (let* ((entry " * [2025-10-08 Wed 22:39] @ -
|
(let* ((entry " * [2025-10-08 Wed 22:39] @ -
|
||||||
;; Paul is #XP
|
Paul is #XP
|
||||||
;; Do software engineering professionals still read? - survey results
|
Do software engineering professionals still read? - survey results
|
||||||
;; https://paulgrenyer.blogspot.com/2025/10/do-software-engineering-professionals.html?m=1")
|
https://paulgrenyer.blogspot.com/2025/10/do-software-engineering-professionals.html?m=1")
|
||||||
;; (parsed (journelly-parse-entry entry)))
|
(parsed (journelly-parse-entry entry)))
|
||||||
;; (should (equal (journelly-entry-heading parsed)
|
(should (equal (journelly-entry-heading parsed)
|
||||||
;; " * [2025-10-08 Wed 22:39] @ -"))
|
" * [2025-10-08 Wed 22:39] @ -"))
|
||||||
;; (should (equal (journelly-entry-title parsed)
|
(should (equal (journelly-entry-title parsed)
|
||||||
;; "Do software engineering professionals still read? - survey results"))
|
"Do software engineering professionals still read? - survey results"))
|
||||||
;; (should (equal (journelly-entry-url parsed)
|
(should (equal (journelly-entry-url parsed)
|
||||||
;; "https://paulgrenyer.blogspot.com/2025/10/do-software-engineering-professionals.html?m=1"))
|
"https://paulgrenyer.blogspot.com/2025/10/do-software-engineering-professionals.html?m=1"))
|
||||||
;; (should (equal (journelly-entry-content parsed)
|
(should (equal (journelly-entry-content parsed)
|
||||||
;; "Paul is #XP"))))
|
"Paul is #XP"))))
|
||||||
|
|
||||||
;; (ert-deftest test-journelly-parse-with-extra-text-after-url ()
|
(ert-deftest test-journelly-parse-with-extra-text-after-url ()
|
||||||
;; (let* ((entry " * [2025-10-08 Wed 22:39] @ -
|
(let* ((entry " * [2025-10-08 Wed 22:39] @ -
|
||||||
;; Some intro text
|
Some intro text
|
||||||
;; Article Title
|
Article Title
|
||||||
;; https://example.com
|
https://example.com
|
||||||
;; Some notes after the URL")
|
Some notes after the URL")
|
||||||
;; (parsed (journelly-parse-entry entry)))
|
(parsed (journelly-parse-entry entry)))
|
||||||
;; (should (equal (journelly-entry-title parsed) "Article Title"))
|
(should (equal (journelly-entry-title parsed) "Article Title"))
|
||||||
;; (should (equal (journelly-entry-url parsed) "https://example.com"))
|
(should (equal (journelly-entry-url parsed) "https://example.com"))
|
||||||
;; (should (string-match-p "Some intro text" (journelly-entry-content parsed)))
|
(should (string-match-p "Some intro text" (journelly-entry-content parsed)))
|
||||||
;; (should (string-match-p "Some notes after the URL" (journelly-entry-content parsed)))))
|
(should (string-match-p "Some notes after the URL" (journelly-entry-content parsed)))))
|
||||||
|
|
||||||
|
|
||||||
;; Run tests manually with: (ert "test-journelly-*")
|
;; Run tests manually with: (ert "test-journelly-*")
|
||||||
|
|||||||
Reference in New Issue
Block a user