Tests: Fix filename tests for CI

As the comment says, in CI the filenames are being abbreviated, which
I can't explain (it has not always been this way).  So we compare them
in abbreviated form.
This commit is contained in:
Adam Porter 2024-06-27 08:03:04 -05:00
parent a8608f408b
commit 611198155d

View file

@ -2111,21 +2111,31 @@ with keyword arg NOW in PLIST."
(describe "Buffers/Files" (describe "Buffers/Files"
:var ((query '(and (todo "TODO") (regexp "heading"))) :var ((query '(and (todo "TODO") (regexp "heading")))
(one-filename (car temp-filenames))) (one-filename (car temp-filenames)))
(it "One filename matches" ;; NOTE: Inexplicably, on GitHub CI, the filenames are being
(expect (var-after-bookmark-set-and-jump 'org-ql-view-buffers-files one-filename query) ;; abbreviated (i.e. "/home/FOO" is replaced with "~/FOO");
:to-equal one-filename)) ;; I can only guess it's something to do with the way the
(it "A list of filenames matches" ;; Emacs instance is built in the Nix images we use there.
(expect (var-after-bookmark-set-and-jump 'org-ql-view-buffers-files temp-filenames query) ;; So we have to compare the filenames in abbreviated form.
:to-equal temp-filenames)) (cl-labels ((filenames-equal-p (a b)
;; NOTE: These actually bookmark the filenames backing the buffers. (seq-set-equal-p (mapcar #'abbreviate-file-name a)
(it "One buffer matches" (mapcar #'abbreviate-file-name b))))
(expect (var-after-bookmark-set-and-jump 'org-ql-view-buffers-files (it "One filename matches"
(find-file-noselect (car temp-filenames)) query) (should (equal (abbreviate-file-name
:to-equal one-filename)) (var-after-bookmark-set-and-jump 'org-ql-view-buffers-files one-filename query))
(it "A list of buffers matches" (abbreviate-file-name one-filename))))
(expect (var-after-bookmark-set-and-jump 'org-ql-view-buffers-files (it "A list of filenames matches"
(mapcar #'find-file-noselect temp-filenames) query) (should (filenames-equal-p (var-after-bookmark-set-and-jump 'org-ql-view-buffers-files temp-filenames query)
:to-equal temp-filenames))))) temp-filenames)))
;; NOTE: These actually bookmark the filenames backing the buffers.
(it "One buffer matches"
(should (equal (abbreviate-file-name
(var-after-bookmark-set-and-jump 'org-ql-view-buffers-files
(find-file-noselect (car temp-filenames)) query))
(abbreviate-file-name one-filename))))
(it "A list of buffers matches"
(should (filenames-equal-p (var-after-bookmark-set-and-jump 'org-ql-view-buffers-files
(mapcar #'find-file-noselect temp-filenames) query)
temp-filenames)))))))
(describe "Dynamic blocks" (describe "Dynamic blocks"
(describe "warn about sexp queries" (describe "warn about sexp queries"