Skip to content

Commit

Permalink
Tests: Fix filename tests for CI
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alphapapa committed Jun 27, 2024
1 parent a8608f4 commit 6111981
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions tests/test-org-ql.el
Original file line number Diff line number Diff line change
Expand Up @@ -2111,21 +2111,31 @@ with keyword arg NOW in PLIST."
(describe "Buffers/Files"
:var ((query '(and (todo "TODO") (regexp "heading")))
(one-filename (car temp-filenames)))
(it "One filename matches"
(expect (var-after-bookmark-set-and-jump 'org-ql-view-buffers-files one-filename query)
:to-equal one-filename))
(it "A list of filenames matches"
(expect (var-after-bookmark-set-and-jump 'org-ql-view-buffers-files temp-filenames query)
:to-equal temp-filenames))
;; NOTE: These actually bookmark the filenames backing the buffers.
(it "One buffer matches"
(expect (var-after-bookmark-set-and-jump 'org-ql-view-buffers-files
(find-file-noselect (car temp-filenames)) query)
:to-equal one-filename))
(it "A list of buffers matches"
(expect (var-after-bookmark-set-and-jump 'org-ql-view-buffers-files
(mapcar #'find-file-noselect temp-filenames) query)
:to-equal temp-filenames)))))
;; NOTE: Inexplicably, on GitHub CI, the filenames are being
;; abbreviated (i.e. "/home/FOO" is replaced with "~/FOO");
;; I can only guess it's something to do with the way the
;; Emacs instance is built in the Nix images we use there.
;; So we have to compare the filenames in abbreviated form.
(cl-labels ((filenames-equal-p (a b)
(seq-set-equal-p (mapcar #'abbreviate-file-name a)
(mapcar #'abbreviate-file-name b))))
(it "One filename matches"
(should (equal (abbreviate-file-name
(var-after-bookmark-set-and-jump 'org-ql-view-buffers-files one-filename query))
(abbreviate-file-name one-filename))))
(it "A list of filenames matches"
(should (filenames-equal-p (var-after-bookmark-set-and-jump 'org-ql-view-buffers-files temp-filenames query)
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 "warn about sexp queries"
Expand Down

0 comments on commit 6111981

Please sign in to comment.