[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ssh-deploy 8f358b1 102/133: Started on unit test for di
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ssh-deploy 8f358b1 102/133: Started on unit test for directory differences |
Date: |
Sat, 27 Mar 2021 14:48:52 -0400 (EDT) |
branch: externals/ssh-deploy
commit 8f358b1df7816e1fb7ccfc3a15c65ee9fbebe2eb
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Started on unit test for directory differences
---
ssh-deploy-test.el | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
diff --git a/ssh-deploy-test.el b/ssh-deploy-test.el
index 3fac61b..21c6e59 100644
--- a/ssh-deploy-test.el
+++ b/ssh-deploy-test.el
@@ -341,6 +341,84 @@
(delete-directory directory-a t)
(delete-directory directory-b t)))
+(defun ssh-deploy-test--directory-diff (async async-with-threads)
+ "Test directory differences asynchronously if ASYNC is above zero, with
threads if ASYNC-WITH-THREADS is above zero."
+
+ (message "\nTest Directory Difference\n")
+ (let ((directory-a (expand-file-name "test-a/"))
+ (directory-b (expand-file-name "test-b/")))
+
+ ;; Delete directories if they already exists
+ (when (file-directory-p directory-a)
+ (delete-directory directory-a t))
+ (when (file-directory-p directory-b)
+ (delete-directory directory-b t))
+
+ ;; Make directories for test
+ (make-directory-internal directory-a)
+ (make-directory-internal directory-b)
+
+ (let* ((file-1-filename "test.txt")
+ (file-2-filename "test2.txt")
+ (file-a-1 (file-truename (expand-file-name file-1-filename
directory-a)))
+ (file-a-2 (file-truename (expand-file-name file-2-filename
directory-a)))
+ (file-b-1 (file-truename (expand-file-name file-1-filename
directory-b)))
+ (file-b-2 (file-truename (expand-file-name file-2-filename
directory-b)))
+ (file-a-1-contents "Random text")
+ (file-a-2-contents "Randomized text")
+ (ssh-deploy-root-local (file-truename directory-a))
+ (ssh-deploy-root-remote (file-truename directory-b))
+ (ssh-deploy-on-explicit-save 1)
+ (ssh-deploy-debug 0)
+ (ssh-deploy-async async)
+ (ssh-deploy-exclude-list nil)
+ (ssh-deploy-async-with-threads async-with-threads))
+
+ ;; Just bypass the linter here
+ (when (and ssh-deploy-root-local
+ ssh-deploy-root-remote
+ ssh-deploy-on-explicit-save
+ ssh-deploy-debug
+ ssh-deploy-async
+ ssh-deploy-async-with-threads)
+
+ (ssh-deploy-add-after-save-hook)
+
+ ;; Create file 1
+ (find-file file-a-1)
+ (insert file-a-1-contents)
+ (save-buffer) ;; NOTE Should trigger upload action
+ (when (> async 0)
+ (sleep-for 1))
+ (kill-buffer)
+
+ ;; Verify that both files have equal contents
+ (should (equal t (ediff-same-file-contents file-a-1 file-b-1)))
+
+ ;; Create file 2
+ (find-file file-a-2)
+ (insert file-a-2-contents)
+ (save-buffer) ;; NOTE Should trigger upload action
+ (when (> async 0)
+ (sleep-for 1))
+ (kill-buffer)
+
+ ;; Verify that both files have equal contents
+ (should (equal t (ediff-same-file-contents file-a-2 file-b-2)))
+
+ (should (equal
+ (ssh-deploy--diff-directories-data directory-a directory-b
ssh-deploy-exclude-list)
+ (list directory-a directory-b ssh-deploy-exclude-list (list
file-1-filename file-2-filename) nil (list file-1-filename file-2-filename)
nil)))
+
+ ;; Delete test files
+ (delete-file file-b-2)
+ (delete-file file-b-1)
+ (delete-file file-a-1)
+ (delete-file file-a-2)))
+
+ (delete-directory directory-a t)
+ (delete-directory directory-b t)))
+
(defun ssh-deploy-test--get-revision-path ()
"Test this function."
(should (string= (expand-file-name "./_mydirectory_random-file.txt")
(ssh-deploy--get-revision-path "/mydirectory/random-file.txt" (expand-file-name
".")))))
@@ -381,6 +459,13 @@
(ssh-deploy-test--file-is-in-path)
(ssh-deploy-test--is-not-empty-string)
+ ;; Directory Differences
+ (ssh-deploy-test--directory-diff 0 0)
+ (when async-el
+ (ssh-deploy-test--directory-diff 1 0))
+ (when async-threads
+ (ssh-deploy-test--directory-diff 1 1))
+
;; Detect Remote Changes
(ssh-deploy-test--detect-remote-changes 0 0)
(when async-el
- [elpa] externals/ssh-deploy 1bb2f82 129/133: Added support for forced uploads on explicit save actions, (continued)
- [elpa] externals/ssh-deploy 1bb2f82 129/133: Added support for forced uploads on explicit save actions, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy cc91b56 132/133: Updated README and version, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy e73907d 063/133: Changed test command, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 4c3eee5 059/133: Fixed issue were checking verbose variable was expecting boolean instead of integer, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy a57ae0c 061/133: Updated use-package example to work with byte-compiled code, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 77f0a1d 070/133: Byte-compilation working for unit test without warning, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 54f664b 081/133: Added unit tests for async.el if it's loaded, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy e4d1403 086/133: Added async.el autoload for new change detection and pushed version, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 65d58c3 106/133: Added unit test for directory difference, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 7ad73a4 103/133: Unit test for directory difference passing, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 8f358b1 102/133: Started on unit test for directory differences,
Stefan Monnier <=
- [elpa] externals/ssh-deploy e2db9c7 117/133: Fixed unit test for directory differences where directories are symbolic, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy ded455b 126/133: More idiomatic code for status updates, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy e10221e 127/133: Using (string-prefix-p) instead of (string-match) for checking if path is in root, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy fce4ea3 133/133: Merge remote-tracking branch 'upstream/ssh-deploy/main' into externals/ssh-deploy, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 5b263c1 045/133: Some changes from ELPA merged, Stefan Monnier, 2021/03/27