"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)
(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)