[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-real 8ab3459 083/160: Added test framework
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-real 8ab3459 083/160: Added test framework |
Date: |
Wed, 6 Oct 2021 16:58:20 -0400 (EDT) |
branch: externals/org-real
commit 8ab345997a6f7d56405557678470982ee5bf690b
Author: Tyler Grinn <tylergrinn@gmail.com>
Commit: Tyler Grinn <tylergrinn@gmail.com>
Added test framework
---
.gitlab-ci.yml | 10 +-
Eldev | 68 ++++++++-
tests.org => demo/example.org | 0
garage.org => demo/garage.org | 0
prepositions.org => demo/prepositions.org | 0
projects.org => demo/projects.org | 0
examples | 68 ---------
org-real.el | 7 +-
tests/edge-cases.org | 226 ++++++++++++++++++++++++++++++
9 files changed, 302 insertions(+), 77 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 95db3a4..ea1c6fb 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -7,11 +7,13 @@ package:
image: silex/emacs:27
before_script:
- curl -fsSL https://raw.github.com/doublep/eldev/master/webinstall/eldev
| sh
+ - export PATH=$PATH:/root/.eldev/bin
script:
- - /root/.eldev/bin/eldev -dtT lint
- - /root/.eldev/bin/eldev -dtT compile -W
- - /root/.eldev/bin/eldev -dtT package
- - /root/.eldev/bin/eldev -dtT md5
+ - eldev lint
+ - eldev compile -W
+ - eldev test
+ - eldev package
+ - eldev md5
artifacts:
paths:
- dist/
diff --git a/Eldev b/Eldev
index 84e9700..7469bfd 100644
--- a/Eldev
+++ b/Eldev
@@ -1,8 +1,8 @@
; -*- mode: emacs-lisp; lexical-binding: t -*-
(eldev-defcommand
- org_real-md5 (&rest parameters)
- "Create md5 checksum of tar files in dist folder"
+ org_real-md5 (&rest _)
+ "Create md5 checksum of .tar and .el files in dist folder."
(mapc
(lambda (file)
(write-region
@@ -12,3 +12,67 @@
(append
(directory-files eldev-dist-dir t "\\.tar\\'")
(directory-files eldev-dist-dir t "\\.el\\'"))))
+
+(eldev-defcommand
+ org_real-test (&rest _)
+ "Runs tests against all org files in tests folder."
+ :override t
+ (require 'cl-lib)
+ (require 'org-element)
+ (load-file "org-real.el")
+ (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 "Org Real")
+ (buffer-string)))
+ (print-result (title result)
+ (message " %s : %s"
+ (if result
+ "\033[0;32mPASS\033[0m"
+ "\033[0;31mFAIL\033[0m")
+ title))
+ (set-result (result)
+ (if (not result) (cl-incf failures))
+ (let ((inhibit-message t))
+ (org-todo (if result "PASS" "FAIL")))))
+ (mapc
+ (lambda (test)
+ (with-temp-file test
+ (message "%s:" (file-name-base test))
+ (insert-file-contents test)
+ (org-mode)
+
+ (message " Opening links:")
+ (org-element-map (org-element-parse-buffer) 'link
+ (lambda (link)
+ (goto-char (org-element-property :begin link))
+ (let ((title (and (org-in-regexp org-link-bracket-re)
+ (match-string 2)))
+ (result (catch 'result
+ (save-window-excursion
+ (condition-case nil
+ (org-open-at-point)
+ (error (throw 'result nil)))
+ (string= (get-expected) (get-actual))))))
+ (print-result title result)
+ (set-result result))))
+
+ (message " Merging links:")
+ (org-babel-map-src-blocks nil
+ (goto-char beg-block)
+ (let ((title (org-entry-get nil "ITEM"))
+ (result (catch 'result
+ (save-window-excursion
+ (condition-case nil
+ (progn
+ (org-edit-special)
+ (org-real-world))
+ (error (throw 'result nil))))
+ (string= (get-expected) (get-actual)))))
+ (print-result title result)
+ (set-result result)))))
+ (directory-files "tests" t "\\.org\\'"))
+ (and (> failures 0) (error "Test run had failures")))))
diff --git a/tests.org b/demo/example.org
similarity index 100%
rename from tests.org
rename to demo/example.org
diff --git a/garage.org b/demo/garage.org
similarity index 100%
rename from garage.org
rename to demo/garage.org
diff --git a/prepositions.org b/demo/prepositions.org
similarity index 100%
rename from prepositions.org
rename to demo/prepositions.org
diff --git a/projects.org b/demo/projects.org
similarity index 100%
rename from projects.org
rename to demo/projects.org
diff --git a/examples b/examples
deleted file mode 100644
index a6efbf4..0000000
--- a/examples
+++ /dev/null
@@ -1,68 +0,0 @@
-
- The toothbrush is in the bathroom cabinet on the third shelf
- to the left of the razors.
-
- ┌────────────────────────────────────────┐
- │
- │ bathroom cabinet │
- │ │
- │ ┌──────────────────────────────────┐ │
- │ │ │ │
- │ │ third shelf │ │
- │ │ │ │
- │ │ ┌──────────────┐ ┌──────────┐ │ │
- │ │ │ │ │ │ │ │
- │ │ │ toothbrush │ │ razors │ │ │
- │ │ │ │ │ │ │ │
- │ │ └──────────────┘ └──────────┘ │ │
- │ │ │ │
- │ └──────────────────────────────────┘ │
- │ │
- └────────────────────────────────────────┘
-
- The bike is behind the shed.
-
- ┌──────────────┐
- │ │
- │ shed │
- │ │
- │ ┌╌╌╌╌╌╌╌╌┐ │
- │ ╎ ╎ │
- │ ╎ bike ╎ │
- │ ╎ ╎ │
- │ └╌╌╌╌╌╌╌╌┘ │
- │ │
- └──────────────┘
-
- The mosquito spray is in front of the sunscreen in the closet
-
- ┌──────────────────────────────┐
- │ │
- │ closet │
- │ │
- │ ┌────────────────────────┐ │
- │ │ │ │
- │ │ sunscreen │ │
- │ │ │ │
- │ │ ┌──────────────────┐ │ │
- │ │ │ │ │ │
- │ │ │ mosquito spray │ │ │
- │ │ │ │ │ │
- │ └──┴──────────────────┴──┘ │
- │ │
- └──────────────────────────────┘
-
-The spare key is above the door frame
-
- ┌─────────────┐
- │ │
- │ spare key │
- │ │
- └─────────────┘
- ┌──────────────┐
- │ │
- │ door frame │
- │ │
- └──────────────┘
-
-
diff --git a/org-real.el b/org-real.el
index 58315e2..82ddb85 100644
--- a/org-real.el
+++ b/org-real.el
@@ -270,7 +270,8 @@ The following commands are available:
\\{org-real-mode-map}"
:group 'org-mode
- (toggle-truncate-lines t))
+ (let ((inhibit-message t))
+ (toggle-truncate-lines t)))
(mapc
(lambda (key) (define-key org-real-mode-map (kbd (car key)) (cdr key)))
@@ -631,7 +632,7 @@ ORIG is `org-insert-link', ARGS are the arguments passed to
it."
(cl-defmethod org-real--make-instance ((_ (subclass org-real-box))
containers
&optional skip-primary)
- "Create an instance of `org-real-box' from CONTAINERS.
+ "Create an instance of an org real box from CONTAINERS.
CONTAINERS is a list of plists containing at least a :name
property and optionally a :rel property. If SKIP-PRIMARY is
@@ -1550,7 +1551,7 @@ set to the :loc slot of each box."
(defun org-real--parse-headlines ()
- "Create an org-real-box from the current buffer's headlines."
+ "Create an org real box from the current buffer's headlines."
(let ((headlines (cddr (org-element-parse-buffer 'headline)))
(world (org-real-box :level 1)))
(mapc
diff --git a/tests/edge-cases.org b/tests/edge-cases.org
new file mode 100644
index 0000000..6b657d1
--- /dev/null
+++ b/tests/edge-cases.org
@@ -0,0 +1,226 @@
+#+TODO: FAIL | PASS
+
+* Opening links
+
+** FAIL [[real://1-2/1-1?rel=on top of/1-0?rel=above][Is above an on top]]
+ #+begin_example
+
+ The 1-0 is above the 1-1 on top of the 1-2.
+
+ ┌───────┐
+ │ │
+ │ 1-0 │
+ │ │
+ └───────┘
+
+ ┌───────┐
+ │ │
+ │ 1-1 │
+ │ │
+ ┌──┴───────┴──┐
+ │ │
+ │ 1-2 │
+ │ │
+ └─────────────┘
+
+
+
+
+ #+end_example
+
+** FAIL [[real://6-4/6-3?rel=on top of/6-2?rel=on top of/6-1?rel=above][Is
above an on top of an on top]]
+ #+begin_example
+
+ The 6-1 is above the 6-2 on top of the 6-3 on top of the 6-4.
+
+ ┌───────┐
+ │ │
+ │ 6-1 │
+ │ │
+ └───────┘
+
+ ┌───────┐
+ │ │
+ │ 6-2 │
+ │ │
+ ┌──┴───────┴──┐
+ │ │
+ │ 6-3 │
+ │ │
+ ┌──┴─────────────┴──┐
+ │ │
+ │ 6-4 │
+ │ │
+ └───────────────────┘
+
+
+
+
+
+ #+end_example
+
+** PASS [[real://7-3/7-2?rel=on top of/7-1?rel=below][Is below an on top]]
+ #+begin_example
+
+ The 7-1 is below the 7-2 on top of the 7-3.
+
+ ┌───────┐
+ │ │
+ │ 7-2 │
+ │ │
+ ┌──┴───────┴──┐
+ │ │
+ │ 7-3 │
+ │ │
+ │ ┌───────┐ │
+ │ │ │ │
+ │ │ 7-1 │ │
+ │ │ │ │
+ │ └───────┘ │
+ └─────────────┘
+
+
+
+
+ #+end_example
+
+** FAIL [[real://2-4/2-3?rel=on top of/2-2?rel=on top of/2-1?rel=below][Is
below an on top of an on top]]
+ #+begin_example
+ Not created yet
+ #+end_example
+
+** PASS [[real://3-3?rel=in/3-2?rel=in front of/3-1?rel=above][Is above an in
front]]
+ #+begin_example
+
+ The 3-1 is above the 3-2 in front of the 3-3.
+
+ ┌─────────────┐
+ │ │
+ │ 3-3 │
+ │ │
+ │ ┌───────┐ │
+ │ │ │ │
+ │ │ 3-1 │ │
+ │ │ │ │
+ │ └───────┘ │
+ │ │
+ │ ┌───────┐ │
+ │ │ │ │
+ │ │ 3-2 │ │
+ │ │ │ │
+ └──┴───────┴──┘
+
+
+
+
+ #+end_example
+
+** PASS [[real://5-4/5-3?rel=in front of/5-2?rel=in front of/5-1?rel=above][Is
above an in front of an in front]]
+ #+begin_example
+
+ The 5-1 is above the 5-2 in front of the 5-3 in front of the 5-4.
+
+ ┌───────────────────┐
+ │ │
+ │ 5-4 │
+ │ │
+ │ ┌─────────────┐ │
+ │ │ │ │
+ │ │ 5-3 │ │
+ │ │ │ │
+ │ │ ┌───────┐ │ │
+ │ │ │ │ │ │
+ │ │ │ 5-1 │ │ │
+ │ │ │ │ │ │
+ │ │ └───────┘ │ │
+ │ │ │ │
+ │ │ ┌───────┐ │ │
+ │ │ │ │ │ │
+ │ │ │ 5-2 │ │ │
+ │ │ │ │ │ │
+ └──┴──┴───────┴──┴──┘
+
+
+
+
+ #+end_example
+
+** FAIL [[real://4-3/4-2?rel=in front of/4-1?rel=below][Is below an in front]]
+ #+begin_example
+
+ The 4-1 is below the 4-2 in front of the 4-3.
+
+ ┌─────────────┐
+ │ │
+ │ 4-3 │
+ │ │
+ │ ┌───────┐ │
+ │ │ │ │
+ │ │ 4-2 │ │
+ │ │ │ │
+ └──┴───────┴──┘
+
+ ┌───────┐
+ │ │
+ │ 4-1 │
+ │ │
+ └───────┘
+
+
+
+
+ #+end_example
+
+** FAIL [[real://8-4/8-3?rel=in front of/8-2?rel=in front of/8-1?rel=below][Is
below an in front of an in front]]
+ #+begin_example
+
+ The 8-1 is below the 8-2 in front of the 8-3 in front of the 8-4.
+
+ ┌───────────────────┐
+ │ │
+ │ 8-4 │
+ │ │
+ │ ┌─────────────┐ │
+ │ │ │ │
+ │ │ 8-3 │ │
+ │ │ │ │
+ │ │ ┌───────┐ │ │
+ │ │ │ │ │ │
+ │ │ │ 8-2 │ │ │
+ │ │ │ │ │ │
+ └──┴──┴───────┴──┴──┘
+
+ ┌───────┐
+ │ │
+ │ 8-1 │
+ │ │
+ └───────┘
+
+
+
+
+
+ #+end_example
+* Merging links
+
+** PASS Merges two boxes
+ #+begin_src org
+ - [[real://thing3/thing2?rel=on top of/thing1?rel=to the right of]]
+ - [[real://thing3/thing2?rel=on top of]]
+ #+end_src
+ #+begin_example
+
+ ┌──────────┐ ┌──────────┐
+ │ │ │ │
+ │ thing2 │ │ thing1 │
+ │ │ │ │
+ ┌──┴──────────┴──┴──────────┴──┐
+ │ │
+ │ thing3 │
+ │ │
+ └──────────────────────────────┘
+
+
+
+
+ #+end_example
- [elpa] externals/org-real c513e06 016/160: Updated readme, (continued)
- [elpa] externals/org-real c513e06 016/160: Updated readme, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 7f33978 027/160: Added apply function for rearranging other links, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 371024e 035/160: Satisfying ELC compiler, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 3e325b3 021/160: Simplified merge function, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real abb5aed 061/160: More edge cases, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 1160749 066/160: v0.2.0, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 256060a 064/160: Updated readme, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real a5736f1 070/160: Created buttons that link back to the location of the link, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 4c81b19 071/160: org-real-headlines; Added more keys to Org Real mode, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real e46eb9c 075/160: Added ability to cycle children of a box, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 8ab3459 083/160: Added test framework,
ELPA Syncer <=
- [elpa] externals/org-real f6417b0 076/160: Added ability to collapse and expand boxes, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 92499a7 080/160: Updated readme, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 88c947d 088/160: # `org-real-headlines`, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real f74239f 089/160: Show diffs if test failed, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 881e4af 093/160: Merge branch 'next' into 'main', ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 6a7fbe8 100/160: Added org mode keybindings suggestions, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real ca52aef 110/160: Updated customizations; color scheme, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real f1614bf 111/160: Refactoring; killing org real buffer if it exists before recreating, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 7767388 114/160: Removed popup.el dependency, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 0e8bd16 104/160: Relationship defaults to "in" if omitted in link, ELPA Syncer, 2021/10/06