summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2023-05-10 14:36:32 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2023-05-10 14:48:34 +0200
commitdf620591e8cd5d2733659e9c43e97779b0cb8ec5 (patch)
tree936661186e011437e86b69d4cf2f310118e64670 /test
parent7791907c3852e6ec197352e1c3d3dd8487cc04f5 (diff)
downloademacs-df620591e8cd5d2733659e9c43e97779b0cb8ec5.tar.gz
Clean up files created by arc-mode-tests
* test/lisp/arc-mode-tests.el (arc-mode-test-zip-ensure-ext): Remove created files at the end of the test.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/arc-mode-tests.el38
1 files changed, 25 insertions, 13 deletions
diff --git a/test/lisp/arc-mode-tests.el b/test/lisp/arc-mode-tests.el
index b6e06a563fe..c42fd8d432c 100644
--- a/test/lisp/arc-mode-tests.el
+++ b/test/lisp/arc-mode-tests.el
@@ -50,17 +50,20 @@
"Regression test for bug#61326."
(skip-unless (executable-find "zip"))
(let* ((default-directory arc-mode-tests-data-directory)
+ (created-files nil)
(base-zip-1 "base-1.zip")
(base-zip-2 "base-2.zip")
(content-1 '("1" "2"))
(content-2 '("3" "4"))
(make-file (lambda (name)
+ (push name created-files)
(with-temp-buffer
(insert name)
(write-file name))))
(make-zip
(lambda (zip files)
(delete-file zip nil)
+ (push zip created-files)
(funcall (archive--act-files '("zip") files) zip)))
(update-fn
(lambda (zip-nonempty)
@@ -92,26 +95,35 @@
(lambda (zip mod-fn)
(let ((zip-base (concat zip ".zip"))
(tag (gensym)))
+ (push zip created-files)
(copy-file base-zip-1 zip t)
+ (push zip-base created-files)
(copy-file base-zip-2 zip-base t)
(file-has-changed-p zip tag)
(file-has-changed-p zip-base tag)
(funcall mod-fn zip)
(should-not (file-has-changed-p zip-base tag))
(should (file-has-changed-p zip tag))))))
- ;; setup: make two zip files with different contents
- (mapc make-file (append content-1 content-2))
- (mapc (lambda (args) (apply make-zip args))
- (list (list base-zip-1 content-1)
- (list base-zip-2 content-2)))
- ;; test 1: with "test-update" and "test-update.zip", update
- ;; "test-update": (1) ensure only "test-update" is modified, (2)
- ;; ensure the contents of the new member is expected.
- (funcall test-modify "test-update" update-fn)
- ;; test 2: with "test-delete" and "test-delete.zip", delete entry
- ;; from "test-delete": (1) ensure only "test-delete" is modified,
- ;; (2) ensure the file list is reduced as expected.
- (funcall test-modify "test-delete" delete-fn)))
+ (unwind-protect
+ (progn
+ ;; setup: make two zip files with different contents
+ (mapc make-file (append content-1 content-2))
+ (funcall make-zip base-zip-1 content-1)
+ (funcall make-zip base-zip-2 content-2)
+
+ ;; test 1: with "test-update" and "test-update.zip", update
+ ;; "test-update": (1) ensure only "test-update" is modified, (2)
+ ;; ensure the contents of the new member is expected.
+ (funcall test-modify "test-update" update-fn)
+
+ ;; test 2: with "test-delete" and "test-delete.zip", delete entry
+ ;; from "test-delete": (1) ensure only "test-delete" is modified,
+ ;; (2) ensure the file list is reduced as expected.
+ (funcall test-modify "test-delete" delete-fn))
+
+ ;; Clean up created files.
+ (dolist (file created-files)
+ (ignore-errors (delete-file file))))))
(provide 'arc-mode-tests)