emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ssh-deploy d992624 087/133: More work on asynchronous u


From: Stefan Monnier
Subject: [elpa] externals/ssh-deploy d992624 087/133: More work on asynchronous unit test of detecting remote changes
Date: Sat, 27 Mar 2021 14:48:49 -0400 (EDT)

branch: externals/ssh-deploy
commit d99262456789e2615d018961ecbf7f5b33d1b7a6
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    More work on asynchronous unit test of detecting remote changes
---
 ssh-deploy-test.el | 52 ++++++++++++++++++++++++++++++++++++++++------------
 ssh-deploy.el      | 10 ++++++----
 2 files changed, 46 insertions(+), 16 deletions(-)

diff --git a/ssh-deploy-test.el b/ssh-deploy-test.el
index 0c12dab..61b8026 100644
--- a/ssh-deploy-test.el
+++ b/ssh-deploy-test.el
@@ -46,9 +46,11 @@
 (autoload 'ssh-deploy-upload-handler "ssh-deploy")
 (autoload 'ssh-deploy--remote-changes-data "ssh-deploy")
 (autoload 'ssh-deploy-download-handler "ssh-deploy")
+(autoload 'ssh-deploy--async-process "ssh-deploy")
 
 (defun ssh-deploy-test--download (async async-with-threads)
   "Test downloads asynchronously if ASYNC is above zero, with threads if 
ASYNC-WITH-THREADS is above zero."
+  (message "\nTest Download\n")
   (let ((directory-a (expand-file-name "test-a/"))
         (directory-b (expand-file-name "test-b/")))
 
@@ -101,6 +103,7 @@
 
 (defun ssh-deploy-test--rename-and-delete (async async-with-threads)
   "Test downloads asynchronous if ASYNC is above zero, with threads if 
ASYNC-WITH-THREADS is above zero."
+  (message "\nTest Rename and delete\n")
   (let ((directory-a (expand-file-name "test-a/"))
         (directory-b (expand-file-name "test-b/"))
         (filename-old "testfile.txt")
@@ -180,7 +183,7 @@
 
 (defun ssh-deploy-test--upload (async async-with-threads)
   "Test uploads asynchronously if ASYNC is above zero, with threads if 
ASYNC-WITH-THREADS is above zero."
-
+  (message "\nTest Upload\n")
   (let ((directory-a (expand-file-name "test-a/"))
         (directory-b (expand-file-name "test-b/")))
 
@@ -253,6 +256,7 @@
 (defun ssh-deploy-test--detect-remote-changes (async async-with-threads)
   "Test uploads asynchronously if ASYNC is above zero, with threads if 
ASYNC-WITH-THREADS is above zero."
 
+  (message "\nTest Detect Remote Changes\n")
   (let ((directory-a (expand-file-name "test-a/"))
         (directory-b (expand-file-name "test-b/")))
 
@@ -304,7 +308,14 @@
         (should (equal nil (ediff-same-file-contents file-a file-b)))
 
         ;; Remote file should signal change now
-        (should (equal 5 (nth 0 (ssh-deploy--remote-changes-data file-a))))
+        (if (> async 0)
+            (progn
+              (ssh-deploy--async-process
+               (lambda() (ssh-deploy--remote-changes-data file-a))
+               (lambda(response) (should (equal 5 (nth 0 response))))
+               async-with-threads)
+              (sleep-for 1))
+          (should (equal 5 (nth 0 (ssh-deploy--remote-changes-data file-a)))))
 
         ;; Open file-a and download remote
         (find-file file-a)
@@ -314,7 +325,14 @@
         (kill-buffer)
 
         ;; Remote file should not signal change now
-        (should (equal 4 (nth 0 (ssh-deploy--remote-changes-data file-a))))
+        (if (> async 0)
+            (progn
+              (ssh-deploy--async-process
+               (lambda() (ssh-deploy--remote-changes-data file-a))
+               (lambda(response) (should (equal 4 (nth 0 response))))
+               async-with-threads)
+              (sleep-for 1))
+          (should (equal 4 (nth 0 (ssh-deploy--remote-changes-data file-a)))))
 
         ;; Delete both test files
         (delete-file file-b)
@@ -343,10 +361,15 @@
   "Run test for plug-in."
   (let ((ssh-deploy-verbose 1)
         (ssh-deploy-debug 1)
-        (debug-on-error t))
+        (debug-on-error t)
+        (async-el (fboundp 'async-start))
+        (revision-folder (expand-file-name "revisions")))
     (when (and ssh-deploy-verbose
                ssh-deploy-debug)
-      (if (fboundp 'async-start)
+
+      (setq ssh-deploy-revision-folder revision-folder)
+      
+      (if async-el
           (message "\nNOTE: Running tests for async.el as well since it's 
loaded\n")
         (message "\nNOTE: Skipping tests for async.el since it's not 
loaded\n"))
 
@@ -354,25 +377,30 @@
       (ssh-deploy-test--file-is-in-path)
       (ssh-deploy-test--is-not-empty-string)
 
+      (ssh-deploy-test--detect-remote-changes 0 0)
+      (when async-el
+        (ssh-deploy-test--detect-remote-changes 1 0))
+      (ssh-deploy-test--detect-remote-changes 1 1)
+
       (ssh-deploy-test--upload 0 0)
-      (when (fboundp 'async-start)
+      (when async-el
         (ssh-deploy-test--upload 1 0))
       (ssh-deploy-test--upload 1 1)
 
       (ssh-deploy-test--download 0 0)
-      (when (fboundp 'async-start)
+      (when async-el
         (ssh-deploy-test--download 1 0))
       (ssh-deploy-test--download 1 1)
 
       (ssh-deploy-test--rename-and-delete 0 0)
-      (when (fboundp 'async-start)
+      (when async-el
         (ssh-deploy-test--rename-and-delete 1 0))
       (ssh-deploy-test--rename-and-delete 1 1)
 
-      (ssh-deploy-test--detect-remote-changes 0 0)
-      (when (fboundp 'async-start)
-        (ssh-deploy-test--detect-remote-changes 1 0))
-      (ssh-deploy-test--detect-remote-changes 1 1))))
+      (delete-directory revision-folder t)
+
+
+      )))
 
 (ssh-deploy-test)
 
diff --git a/ssh-deploy.el b/ssh-deploy.el
index d503ef7..91f74e8 100644
--- a/ssh-deploy.el
+++ b/ssh-deploy.el
@@ -315,7 +315,9 @@
                  (let ((ssh-deploy-async 0)
                        (ssh-deploy-async-with-threads 0)
                        (ssh-deploy-on-explicit-save 0)
-                       (ssh-deploy-automatically-detect-remote-changes 0))
+                       (ssh-deploy-automatically-detect-remote-changes 0)
+                       (ssh-deploy-revision-folder ssh-deploy-revision-folder)
+                       (ssh-deploy-exclude-list ssh-deploy-exclude-list))
                    (when ftp-netrc
                      ;; Pass ange-ftp setting to asynchronous process
                      (defvar ange-ftp-netrc-filename ftp-netrc))
@@ -741,8 +743,8 @@
      ;; File is a directory ignore
      (when (> verbose 0) (message (nth 1 response))))
     (3
-     ;; Remote file doesn't exist)
-     (when (> verbose 0) (message (nth 1 response))))
+     ;; Remote file does not exist
+     (when (message (nth 1 response))))
     (4
      ;; Remote file has not changed
      (when (> verbose 0) (message (nth 1 response))))
@@ -750,7 +752,7 @@
      ;; Remote file has changed in comparison with local revision
      (display-warning 'ssh-deploy (nth 1 response) :warning))
     (6
-     ;; Remote file has changed not in comparison with local file
+     ;; Remote file has not changed in comparison with local file
      (copy-file (nth 2 response) (nth 3 response) t t t t)
      (when (> verbose 0) (message (nth 1 response))))
     (7



reply via email to

[Prev in Thread] Current Thread [Next in Thread]