summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2017-02-23 01:00:34 +0530
committerArun Isaac2017-02-23 01:00:34 +0530
commit7018c0841e34e6884682c06549b99d0b678a0d5d (patch)
treef856f8884130b752e6078f536b81e11aacc6ac22
parentae597156bddec210732006f772289f677243c7fe (diff)
downloadexiftool.el-7018c0841e34e6884682c06549b99d0b678a0d5d.tar.gz
exiftool.el-7018c0841e34e6884682c06549b99d0b678a0d5d.tar.lz
exiftool.el-7018c0841e34e6884682c06549b99d0b678a0d5d.zip
Implement temporary test file copying in a macro.
* el-exiftool-tests.el (with-temp-test-file): New macro.
(read-write-test): Rewrite test using `with-temp-test-file'.
-rw-r--r--el-exiftool-tests.el18
1 files changed, 11 insertions, 7 deletions
diff --git a/el-exiftool-tests.el b/el-exiftool-tests.el
index 0025cf4..e16ad17 100644
--- a/el-exiftool-tests.el
+++ b/el-exiftool-tests.el
@@ -31,16 +31,20 @@
 (require 'el-exiftool)
 (require 'ert)
 
+(defmacro with-temp-test-file (test-filename temp-filename &rest body)
+  (declare (indent defun))
+  `(let ((,temp-filename (make-temp-file "el-exiftool-"
+					 nil (concat "-" ,test-filename))))
+     (copy-file ,test-filename ,temp-filename t)
+     ,@body
+     (delete-file ,temp-filename)))
+
 (ert-deftest read-write-test ()
-  (let ((test-filename "test1.png"))
-    (let ((temp-filename (make-temp-file "el-exiftool-"
-					 nil (concat "-" test-filename)))
-	  (tag-value-alist '(("Marked" . "True"))))
-      (copy-file test-filename temp-filename t)
+  (with-temp-test-file "test1.png" temp-filename
+    (let ((tag-value-alist '(("Marked" . "True"))))
       (apply 'el-exiftool-write temp-filename tag-value-alist)
       (should (equal (el-exiftool-read temp-filename (caar tag-value-alist))
-		     tag-value-alist))
-      (delete-file temp-filename))))
+		     tag-value-alist)))))
 
 (provide 'el-exiftool-tests)