[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/boxy-headings accd873 2/4: Added tests
From: |
ELPA Syncer |
Subject: |
[elpa] externals/boxy-headings accd873 2/4: Added tests |
Date: |
Sat, 16 Oct 2021 11:57:08 -0400 (EDT) |
branch: externals/boxy-headings
commit accd873d31484cd498e963f5a1f80b4032645768
Author: Tyler Grinn <tylergrinn@gmail.com>
Commit: Tyler Grinn <tylergrinn@gmail.com>
Added tests
---
.elpaignore | 2 +-
.gitlab-ci.yml | 1 +
Eldev | 79 +++++++++++++++++++++++++++++++++++
tests/smoke.org | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 206 insertions(+), 1 deletion(-)
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/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