[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-superstar fe061dce0c 043/162: added simple batch mode
From: |
Stefan Kangas |
Subject: |
[nongnu] elpa/org-superstar fe061dce0c 043/162: added simple batch mode based unit tests for font lock |
Date: |
Fri, 31 Dec 2021 19:35:23 -0500 (EST) |
branch: elpa/org-superstar
commit fe061dce0c9aa3d975a70716d1ca3679ad461933
Author: D. Williams <d.williams@posteo.net>
Commit: D. Williams <d.williams@posteo.net>
added simple batch mode based unit tests for font lock
---
tests/GNUmakefile | 29 +++++++++++++
tests/font-lock-test.el | 108 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 137 insertions(+)
diff --git a/tests/GNUmakefile b/tests/GNUmakefile
new file mode 100644
index 0000000000..da1c417b00
--- /dev/null
+++ b/tests/GNUmakefile
@@ -0,0 +1,29 @@
+######################################################################
+# GNU MAKEFILE #
+######################################################################
+
+# clear out suffix list
+.SUFFIXES:
+
+EMACS = emacs
+EFLAGS = -batch
+
+# needed modules for testing
+test_objects = ert minimal-setup.el composure-test.el\
+ font-lock-test.el ../org-superstar.el
+
+######################################################################
+### Rules
+######################################################################
+.PHONY: font-lock font-lock-inlinetask all
+# define main goal of make
+all:
+ -$(MAKE) font-lock
+ $(MAKE) font-lock-inlinetask
+
+font-lock:
+ $(EMACS) $(EFLAGS) $(patsubst %,-l %, $(test_objects)) \
+ -f ert-run-tests-batch-and-exit
+
+font-lock-inlinetask: override test_objects += org-inlinetask
+font-lock-inlinetask: font-lock
diff --git a/tests/font-lock-test.el b/tests/font-lock-test.el
new file mode 100644
index 0000000000..c0834e299c
--- /dev/null
+++ b/tests/font-lock-test.el
@@ -0,0 +1,108 @@
+;;; font-lock-test.el --- Test org-superstar-mode's fontification for various
settings -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2020 David Williams
+
+;; Author: David Williams <d.williams@posteo.net>
+;; Package-Requires: ((faceup "0.0.5"))
+
+;;; Commentary:
+
+;; The tests in this file are best used in batch mode. A simple
+;; "make font-lock" or "make font-lock-inlinetask" (for tests only
+;; making sense when org-inlinetask is loaded)
+
+;;; Code:
+
+(require 'cl-macs)
+(require 'subr-x)
+(require 'faceup)
+
+(defvar org-superstar/test-dir (faceup-this-file-directory)
+ "Base directory where sample files are located in.")
+
+(defvar org-superstar/quiet-test t
+ "If t, do not log individual calls to ‘compose-region’.")
+
+(defun org-superstar/get-path (filename)
+ "Provide the correct path to FILENAME."
+ (concat org-superstar/test-dir filename))
+
+(defun org-superstar/test-file (org-file ref-file)
+ "Test that ORG-FILE is fontified according to REF-FILE."
+ (faceup-test-font-lock-file
+ 'org-mode
+ (org-superstar/get-path org-file)
+ (org-superstar/get-path ref-file)))
+
+(faceup-defexplainer org-superstar/test-file)
+
+(ert-deftest org-superstar/test-font-lock-defaults ()
+ "Test default fontification facilities of ‘\\[org-superstar-mode]’."
+ (message "Looking for needed packages..")
+ (skip-unless (and (featurep 'faceup)
+ (not (featurep 'org-inlinetask))))
+ (unwind-protect
+ (let ((org-mode-hook
+ (list (lambda () (org-superstar-mode 1)))))
+ (message "Setting up listeners..")
+ (unless org-superstar/quiet-test
+ (org-superstar/start-listening))
+ (message "Testing item bullets (default)..")
+ (should (org-superstar/test-file
+ "sample-items.org" "items.faceup"))
+ (message "Testing deep headlines (default)..")
+ (should (org-superstar/test-file
+ "sample-inlinetask.org" "noinline.faceup"))
+ (message "Testing regular headlines (default)..")
+ (should (org-superstar/test-file
+ "sample-headlines.org" "headlines-leading.faceup"))
+ (message "Testing fake item bullets (default)..")
+ (should (org-superstar/test-file
+ "sample-nonitem.org" "nonitem.faceup")))
+ (org-superstar/dismiss-listening)))
+
+(ert-deftest org-superstar/test-font-lock-custom ()
+ "Test customized fontification facilities of ‘\\[org-superstar-mode]’."
+ (message "Looking for needed packages..")
+ (skip-unless (and (featurep 'faceup)
+ (not (featurep 'org-inlinetask))))
+ (unwind-protect
+ (let ((org-mode-hook
+ (list (lambda () (org-superstar-mode 1)))))
+ (message "Setting up listeners..")
+ (unless org-superstar/quiet-test
+ (org-superstar/start-listening))
+ (message "Testing disabled item bullets..")
+ (let ((org-superstar-prettify-item-bullets nil))
+ (should (org-superstar/test-file
+ "sample-items.org" "disabled-items.faceup")))
+ (let ((org-hide-leading-stars t))
+ (message "Testing headlines (hidden stars)..")
+ (should (org-superstar/test-file
+ "sample-headlines.org" "headlines-noleading.faceup"))))
+ (org-superstar/dismiss-listening)))
+
+(ert-deftest org-superstar/test-font-lock-inlinetask ()
+ "Test fontification of ‘\\[org-superstar-mode]’ with ‘org-inlinetask’."
+ (message "Looking for needed packages..")
+ (skip-unless (and (featurep 'faceup) (featurep 'org-inlinetask)))
+ (unwind-protect
+ (let ((org-mode-hook
+ (list (lambda () (org-superstar-mode 1)))))
+ (message "Load org-inlinetask..")
+ (require 'org-inlinetask)
+ (message "Setting up listeners..")
+ (unless org-superstar/quiet-test
+ (org-superstar/start-listening))
+ (message "Testing standard inlinetask..")
+ (should (org-superstar/test-file
+ "sample-inlinetask.org" "inline.faceup"))
+ (let ((org-hide-leading-stars t))
+ (message "Testing inline task with hidden stars..")
+ (should (org-superstar/test-file
+ "sample-inlinetask.org" "inline-noleading.faceup"))))
+ (org-superstar/dismiss-listening)))
+
+
+(provide 'font-lock-test)
+;;; font-lock-test.el ends here
- [nongnu] elpa/org-superstar 9ee98125bf 121/162: Working around GitHub README strangeness, (continued)
- [nongnu] elpa/org-superstar 9ee98125bf 121/162: Working around GitHub README strangeness, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 9c85b9eace 117/162: Create issue template: bug report, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 61896d5bcd 125/162: Updating README on volatile., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar c3955469d5 134/162: Updating feature list., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 8bfe6354d9 138/162: Updated documentation to address Issue #21., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar d0cb2f4b9f 150/162: Merge branch 'hide-all-todo-keywords' of andersjohansson, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar f14dd4dc8b 151/162: Fixed logic errors I introduced with last merge., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 03be6c0a30 162/162: Remove now redundant call to org-element-lineage, version bump., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 4a4ae121c1 061/162: Add further documentation regarding org-indent-mode., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 457b6cdb49 019/162: Updating README to include new features., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar fe061dce0c 043/162: added simple batch mode based unit tests for font lock,
Stefan Kangas <=
- [nongnu] elpa/org-superstar c70360d76b 028/162: Adding "test image" face-test.el, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 5614c01993 081/162: fixed typo in README, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar d4948eb213 032/162: Updated README, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 45719ffd10 022/162: added a marker for melpa review, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar b196dc10af 025/162: adding first draft of public testing facilities, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 086ab28506 075/162: Updating Roadmap, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 4965e70c75 036/162: added reference for default headline fontification, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar c58d1e2689 046/162: force org-superstar to clean up --font-lock-keywords, Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar a7d6b37ea2 062/162: Removing references to org-hide-leading-stars-before-indent-mode., Stefan Kangas, 2021/12/31
- [nongnu] elpa/org-superstar 6ef00c4eaf 034/162: renamed sample-titles to sample-headlines, Stefan Kangas, 2021/12/31