branch: externals/boxy-headings commit f33ab079a90dfd60f6ec639d6514e7300d77d515 Merge: be3dac1 42fe06f Author: Tyler Grinn <ty...@tygr.info> Commit: Tyler Grinn <ty...@tygr.info>
Merge branch 'next' into 'main' v2.1.1 Fix typo that caused 'left' and 'right' to not be valid REL property values. See merge request tygrdev/boxy-headings!5 --- .elpaignore | 2 +- .gitlab-ci.yml | 1 + Eldev | 79 +++++++++++++++++++++++++++++++++++ boxy-headings.el | 7 ++-- tests/smoke.org | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 209 insertions(+), 5 deletions(-) diff --git a/.elpaignore b/.elpaignore index 7438c8e..7f2716a 100644 --- a/.elpaignore +++ b/.elpaignore @@ -5,4 +5,4 @@ deps .gitmodules Eldev README.org - +tests diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4714771..74e6f75 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,6 +13,7 @@ package: script: - eldev lint - eldev compile -W + - eldev test - eldev package - eldev md5 artifacts: diff --git a/Eldev b/Eldev index 4a89d75..7a22358 100644 --- a/Eldev +++ b/Eldev @@ -20,3 +20,82 @@ (append (directory-files eldev-dist-dir t "\\.tar\\'") (directory-files eldev-dist-dir t "\\.el\\'")))) + +(eldev-defcommand + boxy_headings-test (&rest _) + "Runs tests against all org files in tests folder." + :override t + (eldev-load-project-dependencies) + (require 'boxy-headings) + (let ((failures 0)) + (cl-flet* ((get-expected () + (save-excursion + (re-search-forward "#\\+begin_example") + (org-element-property :value (org-element-at-point)))) + (get-actual () + (with-current-buffer (get-buffer "*Boxy*") + (buffer-string))) + (print-result (title result) + (message " %s : %s" + (if result + "\033[0;32mPASS\033[0m" + "\033[0;31mFAIL\033[0m") + title) + (if (and (not result) (fboundp 'diff-buffers)) + (let ((expected (get-expected))) + (save-window-excursion + (with-temp-buffer + (insert expected) + (diff-buffers (get-buffer "*Boxy*") + (current-buffer) + nil t)) + (with-current-buffer (get-buffer "*Diff*") + (message "@@ -actual +expected @@") + (message + (string-join + (butlast + (butlast + (cdddr + (split-string + (buffer-string) + "\n")))) + "\n"))))))) + (set-result (result) + (if (not result) (cl-incf failures)) + (let ((inhibit-message t)) + (org-todo (if result "PASS" "FAIL"))))) + (mapc + (lambda (test) + (find-file test) + (message "\n%s:\n" (file-name-base test)) + (message "\n Testing headlines:\n") + (org-babel-map-src-blocks nil + (goto-char beg-block) + (let* ((title (org-entry-get nil "ITEM")) + (boxy-headings-margin-y (if (org-entry-get nil "MARGIN-Y") + (string-to-number (org-entry-get nil "MARGIN-Y" t)) + boxy-headings-margin-y)) + (boxy-headings-margin-x (if (org-entry-get nil "MARGIN-X" t) + (string-to-number (org-entry-get nil "MARGIN-X" t)) + boxy-headings-margin-x)) + (boxy-headings-padding-y (if (org-entry-get nil "PADDING-Y" t) + (string-to-number (org-entry-get nil "PADDING-Y" t)) + boxy-headings-padding-y)) + (boxy-headings-padding-x (if (org-entry-get nil "PADDING-X" t) + (string-to-number (org-entry-get nil "PADDING-X" t)) + boxy-headings-padding-x)) + (result (catch 'result + (save-window-excursion + (condition-case nil + (progn + (org-edit-special) + (save-window-excursion (boxy-headings)) + (org-edit-src-exit)) + (error (throw 'result nil)))) + (string= (get-expected) (get-actual))))) + (print-result title result) + (set-result result))) + (save-buffer) + (kill-buffer)) + (directory-files "tests" t "\\.org\\'")) + (and (> failures 0) (error "Test run had failures"))))) diff --git a/boxy-headings.el b/boxy-headings.el index 5c2adbe..e0193b0 100644 --- a/boxy-headings.el +++ b/boxy-headings.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2021 Free Software Foundation, Inc. ;; Author: Tyler Grinn <tylergr...@gmail.com> -;; Version: 2.1.0 +;; Version: 2.1.1 ;; File: boxy-headings.el ;; Package-Requires: ((emacs "26.1") (boxy "1.0") (org "9.3")) ;; Keywords: tools @@ -131,8 +131,8 @@ ("in front of" . ("in.+front")) ("behind" . ("behind")) ("below" . ("below")) - ("to the left of" . ("to the left of")) - ("to the right of" . ("to the right of"))) + ("to the left of" . ("left")) + ("to the right of" . ("right"))) "Mapping from a boxy relationship to a list of regexes. Each regex will be tested against the REL property of each @@ -331,7 +331,6 @@ The default relationship is 'in'." (lambda (rel) (seq-some (lambda (pattern) - (message "Testing pattern %s" pattern) (string-match-p pattern heading-rel)) (alist-get rel boxy-headings-rel-alist nil nil #'equal))) diff --git a/tests/smoke.org b/tests/smoke.org new file mode 100644 index 0000000..d843e96 --- /dev/null +++ b/tests/smoke.org @@ -0,0 +1,125 @@ +#+TITLE: Boxy headings smoke test +#+TODO: FAIL | PASS + +* PASS Smoke test + #+begin_src org + ,* Above + :PROPERTIES: + :REL: above + :END: + ,* Below + :PROPERTIES: + :REL: below + :END: + ,* Left + :PROPERTIES: + :REL: left + :END: + ,* Right + :PROPERTIES: + :REL: right + :END: + ,* In + ,* Behind + :PROPERTIES: + :REL: behind + :END: + ,* On top + :PROPERTIES: + :REL: on-top + :END: + ,* In front + :PROPERTIES: + :REL: in-front + :END: + #+end_src + #+begin_example + + ╭────────╮ ╭──────────╮ ╭─────────╮ + │ │ │ │ │ │ + │ Left │ │ On top │ │ Right │ + │ │ │ │ │ │ + ╰────────╯ ╭──┴──────────┴─────────────────────────╮ ╰─────────╯ + │ │ + │ *Org Src smoke.org[ org ]* │ + │ │ + │ ╭─────────╮ ╭──────╮ ╭╌╌╌╌╌╌╌╌╌╌╮ │ + │ │ │ │ │ ╎ ╎ │ + │ │ Above │ │ In │ ╎ Behind ╎ │ + │ │ │ │ │ ╎ ╎ │ + │ ╰─────────╯ ╰──────╯ ╰╌╌╌╌╌╌╌╌╌╌╯ │ + │ │ + │ ╭────────────╮ │ + │ │ │ │ + │ │ In front │ │ + │ │ │ │ + ╰──┴────────────┴───────────────────────╯ + + ╭─────────╮ + │ │ + │ Below │ + │ │ + ╰─────────╯ + #+end_example + +* PASS Compat test + Check that the old instructions for REL still work + #+begin_src org + ,* Above + :PROPERTIES: + :REL: above + :END: + ,* Below + :PROPERTIES: + :REL: below + :END: + ,* Left + :PROPERTIES: + :REL: to the left of + :END: + ,* Right + :PROPERTIES: + :REL: to the right of + :END: + ,* In + ,* Behind + :PROPERTIES: + :REL: behind + :END: + ,* On top + :PROPERTIES: + :REL: on top of + :END: + ,* In front + :PROPERTIES: + :REL: in front of + :END: + #+end_src + #+begin_example + + ╭────────╮ ╭──────────╮ ╭─────────╮ + │ │ │ │ │ │ + │ Left │ │ On top │ │ Right │ + │ │ │ │ │ │ + ╰────────╯ ╭──┴──────────┴─────────────────────────╮ ╰─────────╯ + │ │ + │ *Org Src smoke.org[ org ]* │ + │ │ + │ ╭─────────╮ ╭──────╮ ╭╌╌╌╌╌╌╌╌╌╌╮ │ + │ │ │ │ │ ╎ ╎ │ + │ │ Above │ │ In │ ╎ Behind ╎ │ + │ │ │ │ │ ╎ ╎ │ + │ ╰─────────╯ ╰──────╯ ╰╌╌╌╌╌╌╌╌╌╌╯ │ + │ │ + │ ╭────────────╮ │ + │ │ │ │ + │ │ In front │ │ + │ │ │ │ + ╰──┴────────────┴───────────────────────╯ + + ╭─────────╮ + │ │ + │ Below │ + │ │ + ╰─────────╯ + #+end_example