Skip to content

Commit

Permalink
Add tests for autoloading
Browse files Browse the repository at this point in the history
Add tests to check if key autoloaded functions can be called without
triggering errors in a fresh Emacs session.
  • Loading branch information
jun0 committed Dec 7, 2023
1 parent 29e589f commit 0151ff0
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 0 deletions.
65 changes: 65 additions & 0 deletions test/autoload-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
(load "test/helpers/setup.el")
(require 'buttercup)
(describe
"autoloaded entry point"

(it "org-gtd-engage"
(expect
(ogt--recursive-eldev-test "autoload-tests/org-gtd-engage-test.el")
:to-equal 0))

(it "org-gtd-show-all-next"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-show-all-next-test.el")
:to-equal 0))

(it "org-gtd-archive-completed-items"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-archive-completed-items-test.el")
:to-equal 0))

(it "org-gtd-capture"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-capture-test.el")
:to-equal 0))

(it "org-gtd-inbox-path"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-inbox-path-test.el")
:to-equal 0))

(it "org-gtd-clarify-mode"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-clarify-mode-test.el")
:to-equal 0))

(it "org-gtd-review-area-of-focus"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-review-area-of-focus-test.el")
:to-equal 0))

(it "org-gtd-review-stuck-projects"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-review-stuck-projects-test.el")
:to-equal 0))

(it "org-gtd-process-inbox"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-process-inbox-test.el")
:to-equal 0))

(it "org-gtd-mode"
(expect
(ogt--recursive-eldev-test
"autoload-tests/org-gtd-mode-test.el")
:to-equal 0))

)
5 changes: 5 additions & 0 deletions test/autoload-tests/org-gtd-archive-completed-items-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(require 'org-gtd-autoloads)

(org-gtd-archive-completed-items)
8 changes: 8 additions & 0 deletions test/autoload-tests/org-gtd-capture-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(require 'org-gtd-autoloads)

(require 'with-simulated-input)
(with-simulated-input "i"
(org-gtd-capture))

5 changes: 5 additions & 0 deletions test/autoload-tests/org-gtd-clarify-mode-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(require 'org-gtd-autoloads)

(org-gtd-clarify-mode)
5 changes: 5 additions & 0 deletions test/autoload-tests/org-gtd-engage-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(require 'org-gtd-autoloads)

(org-gtd-engage)
5 changes: 5 additions & 0 deletions test/autoload-tests/org-gtd-inbox-path-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(require 'org-gtd-autoloads)

(org-gtd-inbox-path)
5 changes: 5 additions & 0 deletions test/autoload-tests/org-gtd-mode-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(require 'org-gtd-autoloads)

(org-gtd-mode)
5 changes: 5 additions & 0 deletions test/autoload-tests/org-gtd-process-inbox-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(require 'org-gtd-autoloads)

(org-gtd-process-inbox)
6 changes: 6 additions & 0 deletions test/autoload-tests/org-gtd-review-area-of-focus-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(require 'org-gtd-autoloads)

(org-gtd-review-area-of-focus
(car org-gtd-areas-of-focus))
5 changes: 5 additions & 0 deletions test/autoload-tests/org-gtd-review-stuck-projects-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(require 'org-gtd-autoloads)

(org-gtd-review-stuck-projects)
5 changes: 5 additions & 0 deletions test/autoload-tests/org-gtd-show-all-next-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(require 'buttercup)
(setq org-gtd-update-ack "3.0.0")
(require 'org-gtd-autoloads)

(org-gtd-show-all-next)
14 changes: 14 additions & 0 deletions test/helpers/setup.el
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,17 @@
(with-current-buffer buffer
(revert-buffer t t)))
(kill-buffer buffer))

(defun ogt--recursive-eldev-test (file)
(unless (file-readable-p (file-name-concat "test" file))
(error "Cannot find or read file %s" file))
(with-temp-buffer
(prog1 (call-process
eldev-shell-command
nil
t
nil
"test"
"-f"
file)
(princ (buffer-substring 1 (point-max))))))

0 comments on commit 0151ff0

Please sign in to comment.