summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob L. Kreuze <zerodaysfordays@sdf.lonestar.org>2019-10-07 08:32:05 -0400
committerJakob L. Kreuze <zerodaysfordays@sdf.lonestar.org>2019-10-07 08:32:05 -0400
commit0e890a41fa680a45b4b4aad2c28f9d6dca999cee (patch)
tree73b204cf5293c8a6ecb06075b147775da1218222
parent6a9fa6a35498e53e8c57282e3b08dedc896d880d (diff)
Move `ert' tests to their own file.
-rw-r--r--dired-rmjunk.el33
-rw-r--r--t/dired-rmjunk-test.el59
2 files changed, 59 insertions, 33 deletions
diff --git a/dired-rmjunk.el b/dired-rmjunk.el
index c3bc929..c1806f2 100644
--- a/dired-rmjunk.el
+++ b/dired-rmjunk.el
@@ -127,14 +127,6 @@ does not contain a directory component."
(if split-offset
(cl-subseq path 0 (1+ split-offset)))))
-(ert-deftest dired-rmjunk-test-dir-name ()
- (should (equal (dired-rmjunk--dir-name ".FRD/links.txt")
- ".FRD/"))
- (should (equal (dired-rmjunk--dir-name ".local/share/recently-used.xbel")
- ".local/share/"))
- (should (equal (dired-rmjunk--dir-name ".asy")
- nil)))
-
(defun dired-rmjunk--file-name (path)
"Return the file-name portion of PATH."
(let ((split-offset (cl-position ?\/ path :from-end t)))
@@ -143,14 +135,6 @@ does not contain a directory component."
;; If there's no directory component, `path' IS the file-name!
path)))
-(ert-deftest dired-rmjunk-test-file-name ()
- (should (equal (dired-rmjunk--file-name ".FRD/links.txt")
- "links.txt"))
- (should (equal (dired-rmjunk--file-name ".local/share/recently-used.xbel")
- "recently-used.xbel"))
- (should (equal (dired-rmjunk--file-name ".asy")
- ".asy")))
-
(defun dired-rmjunk--directories-in-patterns (&optional patterns)
(let ((patterns (or patterns dired-rmjunk-patterns)))
(cl-remove-duplicates
@@ -158,22 +142,5 @@ does not contain a directory component."
(map 'list #'dired-rmjunk--dir-name patterns))
:test #'string=)))
-(ert-deftest dired-rmjunk-test-directories-in-patterns ()
- (should (equal (dired-rmjunk--directories-in-patterns
- '(".local/share/recently-used.xbel"
- "Desktop"
- ".thumbnails"))
- '(".local/share/")))
- (should (equal (dired-rmjunk--directories-in-patterns
- '(".distlib"
- ".bazaar"
- ".bzr.log"))
- nil))
- (should (equal (dired-rmjunk--directories-in-patterns
- '(".local/share/gegl-0.2"
- ".FRD/app.log"
- ".FRD/links.txt"))
- '(".local/share/" ".FRD/"))))
-
(provide 'dired-rmjunk)
;;; dired-rmjunk.el ends here
diff --git a/t/dired-rmjunk-test.el b/t/dired-rmjunk-test.el
new file mode 100644
index 0000000..644a17e
--- /dev/null
+++ b/t/dired-rmjunk-test.el
@@ -0,0 +1,59 @@
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This is the test suite for `dired-rmjunk', separated from `dired-rmjunk.el'
+;; so that loading `ert' isn't a requirement to use the tool.
+
+;; The suite can be run with the following shell command:
+
+;; emacs -Q --batch --directory ./ --directory ./t --load t/dired-rmjunk-test.el --funcall ert-run-tests-batch-and-exit
+
+;;; Code:
+
+(require 'dired-rmjunk)
+(require 'ert)
+
+(ert-deftest dired-rmjunk-test-dir-name ()
+ (should (equal (dired-rmjunk--dir-name ".FRD/links.txt")
+ ".FRD/"))
+ (should (equal (dired-rmjunk--dir-name ".local/share/recently-used.xbel")
+ ".local/share/"))
+ (should (equal (dired-rmjunk--dir-name ".asy")
+ nil)))
+
+(ert-deftest dired-rmjunk-test-file-name ()
+ (should (equal (dired-rmjunk--file-name ".FRD/links.txt")
+ "links.txt"))
+ (should (equal (dired-rmjunk--file-name ".local/share/recently-used.xbel")
+ "recently-used.xbel"))
+ (should (equal (dired-rmjunk--file-name ".asy")
+ ".asy")))
+
+(ert-deftest dired-rmjunk-test-directories-in-patterns ()
+ (should (equal (dired-rmjunk--directories-in-patterns
+ '(".local/share/recently-used.xbel"
+ "Desktop"
+ ".thumbnails"))
+ '(".local/share/")))
+ (should (equal (dired-rmjunk--directories-in-patterns
+ '(".distlib"
+ ".bazaar"
+ ".bzr.log"))
+ nil))
+ (should (equal (dired-rmjunk--directories-in-patterns
+ '(".local/share/gegl-0.2"
+ ".FRD/app.log"
+ ".FRD/links.txt"))
+ '(".local/share/" ".FRD/"))))