forked from emacs-exordium/exordium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
;;; init-require.t-dummy.el --- Dummy feature for init-require.t | ||
|
||
;;; Commentary: | ||
;; | ||
|
||
;;; Code: | ||
|
||
(provide 'init-require.t-dummy) | ||
|
||
;;; init-require.t-dummy.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
;;; init-require.t.el --- Tests for exordium-require -*- lexical-binding: t -*- | ||
|
||
;;; Commentary: | ||
;; | ||
;; To run all tests: | ||
;; M-x eval-buffer | ||
;; M-x ert | ||
|
||
;;; Code: | ||
|
||
(eval-when-compile | ||
(unless (featurep 'init-require) | ||
(load (file-name-concat (locate-user-emacs-file "modules") "init-require")))) | ||
(use-package use-package | ||
:autoload (use-package-statistics-convert | ||
use-package-reset-statistics)) | ||
|
||
|
||
(ert-deftest exordium-require-basic-call () | ||
(use-package-reset-statistics) | ||
(ignore-errors (unload-feature 'init-require.t-dummy)) | ||
(let* ((byte-compile-current-file nil) | ||
(use-package-compute-statistics nil)) | ||
(should (eq 'init-require.t-dummy | ||
(eval '(exordium-require 'init-require.t-dummy))))) | ||
(should (featurep 'init-require.t-dummy)) | ||
(should-error (use-package-statistics-convert 'init-require.t-dummy))) | ||
|
||
|
||
(macroexpand '(ert-deftest exordium-require-while-byte-compile () | ||
(use-package-reset-statistics) | ||
(ignore-errors (unload-feature 'init-require.t-dummy)) | ||
(let* ((byte-compile-current-file t) | ||
(use-package-compute-statistics nil)) | ||
(should (eq 'init-require.t-dummy | ||
(eval '(exordium-require 'init-require.t-dummy))))) | ||
(should (featurep 'init-require.t-dummy)) | ||
(should-error (use-package-statistics-convert 'init-require.t-dummy)))) | ||
|
||
(ert-deftest exordium-require-with-stats () | ||
(use-package-reset-statistics) | ||
(ignore-errors (unload-feature 'init-require.t-dummy)) | ||
(let* ((byte-compile-current-file nil) | ||
(use-package-compute-statistics t)) | ||
(should (eq 'init-require.t-dummy | ||
(eval '(exordium-require 'init-require.t-dummy))))) | ||
(should (featurep 'init-require.t-dummy)) | ||
(should (use-package-statistics-convert 'init-require.t-dummy))) | ||
|
||
(ert-deftest exordium-require-with-stats-while-byte-compile () | ||
(use-package-reset-statistics) | ||
(ignore-errors (unload-feature 'init-require.t-dummy)) | ||
(let* ((byte-compile-current-file t) | ||
(use-package-compute-statistics t)) | ||
(should (eq 'init-require.t-dummy | ||
(eval '(exordium-require 'init-require.t-dummy))))) | ||
(should (featurep 'init-require.t-dummy)) | ||
(should (use-package-statistics-convert 'init-require.t-dummy))) | ||
|
||
(ert-deftest exordium-require-with-location () | ||
;; delay `exordium-require' macro expansion to test execution | ||
(ignore-errors (unload-feature 'init-require.t-dummy)) | ||
(should (eq 'init-require.t-dummy | ||
(eval '(exordium-require 'init-require.t-dummy "modules")))) | ||
(should (featurep 'init-require.t-dummy))) | ||
|
||
|
||
(ert-deftest exordium-require-swallow-error-when-called-with-non-existing-feature () | ||
(ignore-errors (unload-feature 'no-such-feature)) | ||
(let* ((debug-on-error nil)) | ||
(should-not (eq 'no-such-feature | ||
(eval '(exordium-require 'no-such-feature))))) | ||
(should-not (featurep 'no-such-feature))) | ||
|
||
(ert-deftest exordium-require-signals-error-with-non-existing-feature-while-debug () | ||
"TODO: the `should-error' is not catching a file-missing signaled from `load'." | ||
:expected-result :failed | ||
(ignore-errors (unload-feature 'no-such-feature)) | ||
(let* ((debug-on-error t)) | ||
(should-error (eval '(exordium-require 'no-such-feature)))) | ||
(should-not (featurep 'no-such-feature))) | ||
|
||
(ert-deftest exordium-require-swallow-error-when-called-with-non-existing-location () | ||
(ignore-errors (unload-feature 'init-require.t-dummy)) | ||
(let* ((debug-on-error nil)) | ||
(should-not (eq 'init-require.t-dummy | ||
(eval '(exordium-require 'init-require.t-dummy "themes"))))) | ||
(should-not (featurep 'init-require.t-dummy))) | ||
|
||
(ert-deftest exordium-require-signals-error-with-non-existing-location-while-debug () | ||
"TODO: the `should-error' is not catching a file-missing signaled from `load'." | ||
:expected-result :failed | ||
(ignore-errors (unload-feature 'init-require.t-dummy)) | ||
(let* ((debug-on-error t)) | ||
(should-error (eval '(exordium-require 'init-require.t-dummy "themes")))) | ||
(should-not (featurep 'init-require.t-dummy))) | ||
|
||
|
||
(ert-deftest exordium-require-signals-error-with-wrong-feature-type () | ||
(should-error (eval '(exordium-require nil))) | ||
(should-error (eval '(exordium-require t))) | ||
(should-error (eval '(exordium-require 42))) | ||
(should-error (eval '(exordium-require ? ))) | ||
(should-error (eval '(exordium-require init-require.t-dummy))) | ||
(should-error (eval '(exordium-require "init-require.t-dummy"))) | ||
(should-error (eval '(exordium-require | ||
(if t 'init-require.t-dummy | ||
init-require.t-dummy))))) | ||
|
||
(ert-deftest exordium-require-signals-error-with-wrong-location-type () | ||
(should-error (eval '(exordium-require 'init-require.t-dummy t))) | ||
(should-error (eval '(exordium-require 'init-require.t-dummy 42))) | ||
(should-error (eval '(exordium-require 'init-require.t-dummy ? ))) | ||
(should-error (eval '(exordium-require 'init-require.t-dummy 'modules))) | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
(if t "modules" "themes"))))) | ||
|
||
|
||
(ert-deftest exordium-require-signals-error-with-wrong-defines-type () | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
"modules" | ||
:defines (nil)))) | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
"modules" | ||
:defines (t)))) | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
"modules" | ||
:defines (42)))) | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
"modules" | ||
:defines ("var")))) | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
"modules" | ||
:defines ('var)))) | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
"modules" | ||
:defines ((if t 'var 'var)))))) | ||
|
||
(ert-deftest exordium-require-signals-error-with-wrong-functions-type () | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
"modules" | ||
:functions (nil)))) | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
"modules" | ||
:functions (t)))) | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
"modules" | ||
:functions (42)))) | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
"modules" | ||
:functions ("fn")))) | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
"modules" | ||
:functions ('fn)))) | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
"modules" | ||
:functions (nil . (arg))))) | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
"modules" | ||
:functions (t . (arg))))) | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
"modules" | ||
:functions (42 . (arg))))) | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
"modules" | ||
:functions ("fn" . (arg))))) | ||
(should-error (eval '(exordium-require | ||
'init-require.t-dummy | ||
"modules" | ||
:functions ('fn . (arg)))))) | ||
|
||
(provide 'init-require.t) | ||
|
||
;;; init-require.t.el ends here |