From 7018c0841e34e6884682c06549b99d0b678a0d5d Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 23 Feb 2017 01:00:34 +0530 Subject: 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'. --- el-exiftool-tests.el | 18 +++++++++++------- 1 file 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) -- cgit v1.2.3