branch: master commit 69b005851bbca1480fa8e0e3884e6140ac8d77d7 Author: Ian Dunn <du...@gnu.org> Commit: Ian Dunn <du...@gnu.org>
Remove test dependency on dictionary file --- paced-tests.el | 136 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 71 insertions(+), 65 deletions(-) diff --git a/paced-tests.el b/paced-tests.el index 041f4d0..16c80f6 100644 --- a/paced-tests.el +++ b/paced-tests.el @@ -32,9 +32,9 @@ (defsubst paced-test-file (base-name) (expand-file-name base-name paced-test-dir)) -(defconst paced-first-test-file (paced-test-file "first.txt")) +(defconst paced-first-test-file (paced-test-file "first.txt")) (defconst paced-second-test-file (paced-test-file "second.cpp")) -(defconst paced-third-test-file (paced-test-file "third.org")) +(defconst paced-third-test-file (paced-test-file "third.org")) (defconst paced-test-dict-save-file (paced-test-file "paced-dictionary-case-sensitive")) (defconst paced-test-default-registered-map (make-hash-table :test 'equal)) @@ -59,10 +59,10 @@ (should-not (paced-mixed-case-word-p "has"))) (ert-deftest paced-create-dictionary () + ;; Delete the old save file + (when (file-exists-p paced-test-dict-save-file) + (delete-file paced-test-dict-save-file)) (let* ((paced--registered-dictionaries paced-test-default-registered-map) - (target-file-exists (file-exists-p paced-test-dict-save-file)) - (old-mod-time (and target-file-exists - (file-attribute-modification-time (file-attributes paced-test-dict-save-file)))) (new-dict (paced-make-dictionary "test-dict-case" paced-test-dict-save-file 'downcase))) @@ -70,19 +70,13 @@ (should (paced-dictionary-p new-dict)) (oset new-dict updated t) ;; Mark it as updated so it saves (paced-dictionary-save new-dict) - (should (file-exists-p paced-test-dict-save-file)) - ;; Either it didn't exist before, or the old mod time is before the new mod - ;; time. In other words, it updated. - (should (or (not target-file-exists) - (time-less-p old-mod-time - (file-attribute-modification-time (file-attributes paced-test-dict-save-file))))))) - -(ert-deftest paced-load-dictionary () + (should (file-exists-p paced-test-dict-save-file))) (let* ((paced--registered-dictionaries paced-test-default-registered-map)) + ;; Now verify that we can load it again (paced-load-dictionary-from-file paced-test-dict-save-file) (should (= (map-length paced--registered-dictionaries) 1)) (should (map-contains-key paced--registered-dictionaries "test-dict-case")) - (should (paced-dictionary-p (map-elt paced--registered-dictionaries "test-dict-case" nil))))) + (should (paced-dictionary-p (paced-named-dictionary "test-dict-case"))))) (defvar paced-test-enable-symbol nil) @@ -90,8 +84,10 @@ "Test case for `paced-dictionary-enable-alist' being an arbitrary symbol." (let* ((paced--registered-dictionaries paced-test-default-registered-map) (paced-global-dict-enable-alist '((paced-test-enable-symbol . "test-dict-case"))) - (new-buffer (find-file-noselect paced-first-test-file))) - (paced-load-dictionary-from-file paced-test-dict-save-file) + (new-buffer (find-file-noselect paced-first-test-file)) + (new-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (with-current-buffer new-buffer (setq paced-test-enable-symbol nil) (should-not (paced-current-dictionary)) @@ -105,8 +101,10 @@ (let* ((paced--registered-dictionaries paced-test-default-registered-map) (paced-global-dict-enable-alist '((text-mode . "test-dict-case"))) (buffer-one (find-file-noselect paced-first-test-file)) - (buffer-two (find-file-noselect paced-second-test-file))) - (paced-load-dictionary-from-file paced-test-dict-save-file) + (buffer-two (find-file-noselect paced-second-test-file)) + (new-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (with-current-buffer buffer-two (should-not (paced-current-dictionary))) (kill-buffer buffer-two) @@ -122,8 +120,10 @@ "Test case for `paced-dictionary-enable-alist' being a function symbol." (let* ((paced--registered-dictionaries paced-test-default-registered-map) (paced-global-dict-enable-alist '((paced-test-function-symbol . "test-dict-case"))) - (buffer-one (find-file-noselect paced-first-test-file))) - (paced-load-dictionary-from-file paced-test-dict-save-file) + (buffer-one (find-file-noselect paced-first-test-file)) + (new-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (with-current-buffer buffer-one (setq-local paced-test-enable-symbol nil) (should-not (paced-current-dictionary)) @@ -136,8 +136,10 @@ "Test case for `paced-dictionary-enable-alist' being a lambda form." (let* ((paced--registered-dictionaries paced-test-default-registered-map) (paced-global-dict-enable-alist '(((lambda nil paced-test-enable-symbol) . "test-dict-case"))) - (buffer-one (find-file-noselect paced-first-test-file))) - (paced-load-dictionary-from-file paced-test-dict-save-file) + (buffer-one (find-file-noselect paced-first-test-file)) + (new-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (with-current-buffer buffer-one (setq-local paced-test-enable-symbol nil) (should-not (paced-current-dictionary)) @@ -151,8 +153,10 @@ (let* ((paced--registered-dictionaries paced-test-default-registered-map) (paced-global-dict-enable-alist '(((and text-mode paced-test-enable-symbol) . "test-dict-case"))) (buffer-one (find-file-noselect paced-first-test-file)) - (buffer-two (find-file-noselect paced-second-test-file))) - (paced-load-dictionary-from-file paced-test-dict-save-file) + (buffer-two (find-file-noselect paced-second-test-file)) + (new-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (with-current-buffer buffer-two (setq-local paced-test-enable-symbol nil) (should-not (paced-current-dictionary)) @@ -172,8 +176,10 @@ (let* ((paced--registered-dictionaries paced-test-default-registered-map) (paced-global-dict-enable-alist '(((or text-mode paced-test-enable-symbol) . "test-dict-case"))) (buffer-one (find-file-noselect paced-first-test-file)) - (buffer-two (find-file-noselect paced-second-test-file))) - (paced-load-dictionary-from-file paced-test-dict-save-file) + (buffer-two (find-file-noselect paced-second-test-file)) + (new-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (with-current-buffer buffer-two (setq-local paced-test-enable-symbol nil) (should-not (paced-current-dictionary)) @@ -195,9 +201,9 @@ (let* ((paced--registered-dictionaries paced-test-default-registered-map) (paced-global-dict-enable-alist '((text-mode . "test-dict-case"))) (cmd (paced-file-population-command :file paced-first-test-file)) - test-dict) - (paced-load-dictionary-from-file paced-test-dict-save-file) - (setq test-dict (paced-named-dictionary "test-dict-case")) + (test-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (should (paced-dictionary-p test-dict)) (oset test-dict population-commands (list cmd)) (paced-dictionary-repopulate test-dict) @@ -216,9 +222,9 @@ (buffer "first.txt") (buffer-one (find-file-noselect paced-first-test-file)) (cmd (paced-buffer-population-command :buffer buffer)) - test-dict) - (paced-load-dictionary-from-file paced-test-dict-save-file) - (setq test-dict (paced-named-dictionary "test-dict-case")) + (test-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (should (paced-dictionary-p test-dict)) (oset test-dict population-commands (list cmd)) (paced-dictionary-repopulate test-dict) @@ -238,9 +244,9 @@ (pre-func (lambda () (insert (buffer-string)) t)) (cmd (paced-file-function-population-command :file paced-first-test-file :setup-func pre-func)) - test-dict) - (paced-load-dictionary-from-file paced-test-dict-save-file) - (setq test-dict (paced-named-dictionary "test-dict-case")) + (test-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (should (paced-dictionary-p test-dict)) (oset test-dict population-commands (list cmd)) (paced-dictionary-repopulate test-dict) @@ -259,9 +265,9 @@ (cmd (paced-directory-regexp-population-command :directory paced-test-dir :regexp ".*\\.txt" :recursive t)) - test-dict) - (paced-load-dictionary-from-file paced-test-dict-save-file) - (setq test-dict (paced-named-dictionary "test-dict-case")) + (test-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (should (paced-dictionary-p test-dict)) (oset test-dict population-commands (list cmd)) (paced-dictionary-repopulate test-dict) @@ -279,9 +285,9 @@ (paced-global-dict-enable-alist '((text-mode . "test-dict-case"))) (file-list (lambda () `(,paced-first-test-file))) (cmd (paced-file-list-population-command :generator file-list)) - test-dict) - (paced-load-dictionary-from-file paced-test-dict-save-file) - (setq test-dict (paced-named-dictionary "test-dict-case")) + (test-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (should (paced-dictionary-p test-dict)) (oset test-dict population-commands (list cmd)) (paced-dictionary-repopulate test-dict) @@ -298,9 +304,9 @@ (paced-global-dict-enable-alist '((text-mode . "test-dict-case"))) (cmd1 (paced-file-population-command :file paced-first-test-file)) (cmd2 (paced-file-population-command :file paced-third-test-file)) - test-dict) - (paced-load-dictionary-from-file paced-test-dict-save-file) - (setq test-dict (paced-named-dictionary "test-dict-case")) + (test-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (should (paced-dictionary-p test-dict)) (oset test-dict population-commands (list cmd1 cmd2)) (paced-dictionary-repopulate test-dict) @@ -322,9 +328,9 @@ (cmd1 (paced-file-population-command :file paced-first-test-file)) (cmd2 (paced-file-population-command :file paced-second-test-file :props `((paced-exclude-function quote ,exclude-command)))) - test-dict) - (paced-load-dictionary-from-file paced-test-dict-save-file) - (setq test-dict (paced-named-dictionary "test-dict-case")) + (test-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (should (paced-dictionary-p test-dict)) (oset test-dict population-commands (list cmd1 cmd2)) (paced-dictionary-repopulate test-dict) @@ -341,9 +347,9 @@ (let* ((paced--registered-dictionaries paced-test-default-registered-map) (paced-global-dict-enable-alist '((text-mode . "test-dict-case"))) (cmd (paced-file-population-command :file paced-first-test-file)) - test-dict) - (paced-load-dictionary-from-file paced-test-dict-save-file) - (setq test-dict (paced-named-dictionary "test-dict-case")) + (test-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (should (paced-dictionary-p test-dict)) (oset test-dict population-commands (list cmd)) (paced-dictionary-repopulate test-dict) @@ -359,9 +365,9 @@ (let* ((paced--registered-dictionaries paced-test-default-registered-map) (file "first.txt") (cmd (paced-file-population-command :file file)) - test-dict) - (paced-load-dictionary-from-file paced-test-dict-save-file) - (setq test-dict (paced-named-dictionary "test-dict-case")) + (test-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (should (paced-dictionary-p test-dict)) (oset test-dict population-commands (list cmd)) (paced-dictionary-repopulate test-dict) @@ -372,9 +378,9 @@ (let* ((paced--registered-dictionaries paced-test-default-registered-map) (buffer "first.txt") (cmd (paced-buffer-population-command :buffer buffer)) - test-dict) - (paced-load-dictionary-from-file paced-test-dict-save-file) - (setq test-dict (paced-named-dictionary "test-dict-case")) + (test-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (should (paced-dictionary-p test-dict)) (oset test-dict population-commands (list cmd)) (paced-dictionary-repopulate test-dict) @@ -385,9 +391,9 @@ (let* ((paced--registered-dictionaries paced-test-default-registered-map) (paced-global-dict-enable-alist '((text-mode . "test-dict-case"))) (cmd (paced-file-population-command :file paced-first-test-file)) - test-dict) - (paced-load-dictionary-from-file paced-test-dict-save-file) - (setq test-dict (paced-named-dictionary "test-dict-case")) + (test-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (should (paced-dictionary-p test-dict)) (oset test-dict population-commands (list cmd)) (paced-dictionary-repopulate test-dict) @@ -398,9 +404,9 @@ (let* ((paced--registered-dictionaries paced-test-default-registered-map) (paced-global-dict-enable-alist '((text-mode . "test-dict-case"))) (cmd (paced-file-population-command :file paced-first-test-file)) - test-dict) - (paced-load-dictionary-from-file paced-test-dict-save-file) - (setq test-dict (paced-named-dictionary "test-dict-case")) + (test-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (should (paced-dictionary-p test-dict)) (oset test-dict population-commands (list cmd)) (paced-dictionary-repopulate test-dict) @@ -417,9 +423,9 @@ (let* ((paced--registered-dictionaries paced-test-default-registered-map) (paced-global-dict-enable-alist '((text-mode . "test-dict-case"))) (cmd (paced-file-population-command :file paced-first-test-file)) - test-dict) - (paced-load-dictionary-from-file paced-test-dict-save-file) - (setq test-dict (paced-named-dictionary "test-dict-case")) + (test-dict (paced-make-dictionary "test-dict-case" + paced-test-dict-save-file + 'downcase))) (should (paced-dictionary-p test-dict)) (oset test-dict population-commands (list cmd)) (paced-dictionary-repopulate test-dict)