branch: externals/tramp-hlo
commit c74cb27b978e36939da26aa5f4f7a85d9ae3ab39
Author: Joe Sadusk <[email protected]>
Commit: Joe Sadusk <[email protected]>
Fix up tests and fix issues found from tests
---
tramp-hlo-tests.el | 24 +++++++++++++++---------
tramp-hlo.el | 29 ++++++++++++++++-------------
2 files changed, 31 insertions(+), 22 deletions(-)
diff --git a/tramp-hlo-tests.el b/tramp-hlo-tests.el
index 9f03eb2206..e80cd833a3 100644
--- a/tramp-hlo-tests.el
+++ b/tramp-hlo-tests.el
@@ -35,6 +35,15 @@
;;; Code:
+
+;; Add load-path for batch mode
+(if (and load-file-name noninteractive)
+ (progn
+ (add-to-list 'load-path (file-name-directory load-file-name))
+ (add-to-list 'load-path (file-name-concat (file-name-directory
load-file-name) ".." "tramp"))
+ )
+ )
+(require 'tramp)
(require 'tramp-hlo)
(require 'ert-x)
@@ -114,14 +123,13 @@ The result must be equal."
;; Use absolute directory.
(tramp-hlo--run-test 'dir-locals--all-files tmpdir)
- (tramp-hlo--run-test 'dir-locals--all-files tmpdir 'base-el-only)
+
;; Use relative directory.
(let ((default-directory tmpdir))
- (tramp-hlo--run-test 'dir-locals--all-files "./")
- (tramp-hlo--run-test 'dir-locals--all-files "./" 'base-el-only)))
+ (tramp-hlo--run-test 'dir-locals--all-files "./"))
- ;; Try directory with special characters. See tramp-tests.el for
- ;; more examples.
+ ;; Try directory with special characters. See tramp-tests.el for
+ ;; more examples.
(dolist (prefix '(" foo\tbar baz\t" "&foo&bar&baz&" "$foo$bar$$baz$"))
(ert-with-temp-directory tmpdir
:prefix (expand-file-name prefix ert-remote-temporary-file-directory)
@@ -129,8 +137,7 @@ The result must be equal."
(make-empty-file
(expand-file-name (string-replace ".el" "-2.el" dir-locals-file)
tmpdir))
- (tramp-hlo--run-test 'dir-locals--all-files tmpdir)
- (tramp-hlo--run-test 'dir-locals--all-files tmpdir 'base-el-only)))
+ (tramp-hlo--run-test 'dir-locals--all-files tmpdir)))
;; Use another `dir-locals-file'.
(ert-with-temp-directory tmpdir
@@ -140,8 +147,7 @@ The result must be equal."
(make-empty-file
(expand-file-name (string-replace ".el" "-2.el" dir-locals-file)
tmpdir))
- (tramp-hlo--run-test 'dir-locals--all-files tmpdir)
- (tramp-hlo--run-test 'dir-locals--all-files tmpdir 'base-el-only))))
+ (tramp-hlo--run-test 'dir-locals--all-files tmpdir)))))
;; TODO: Add more scenarii.
(ert-deftest tramp-hlo-test-dir-locals-find-file ()
diff --git a/tramp-hlo.el b/tramp-hlo.el
index b369f96753..7eff2dc03c 100644
--- a/tramp-hlo.el
+++ b/tramp-hlo.el
@@ -42,6 +42,7 @@ FILES=$@
if [ ! -d \"$DIR\" ]; then
echo nil
else
+ DIR=$(realpath \"$DIR\")
cd \"$DIR\"
echo \\(
for FILE in $FILES; do
@@ -85,7 +86,7 @@ FOUND=\"\"
while [ ! -z \"$TEST\" ] && [ -z \"$FOUND\" ]; do
if [ -d \"$TEST\" ]; then
for NAME in $NAMES; do
- if [ -f \"$TEST/$NAME\" ]; then
+ if [ -e \"$TEST/$NAME\" ]; then
echo \"\\\"$TEST/$NAME\\\"\"
FOUND=1
fi
@@ -106,7 +107,7 @@ echo \\)
"
"Script to find several dominating files on a remote host."
)
-;STAT_FORMAT=\"${STAT_FORMAT#?}\"
+
(defconst tramp-hlo-dir-locals-find-file-cache-update-script
"
@@ -179,7 +180,7 @@ else
# Add found files to the plist
if [ ! -z \"$FOUND\" ]; then
- echo \":locals (\\\"$DOMINATING_DIR\\\" $FOUND )\"
+ echo \":locals (\\\"$DOMINATING_DIR/\\\" $FOUND )\"
fi
# Test cached dirs for updated mtime
@@ -214,7 +215,7 @@ fi
)
-(defun tramp-hlo-dir-locals--all-files (directory &optional base-el-only)
+(defun tramp-hlo-dir-locals--all-files (directory)
"Tramp optimized version of `dir-locals--all-files'.
Return a list of all readable dir-locals files in the directory
represented by VEC.
@@ -223,7 +224,9 @@ values specified in the last file should take precedence
over
those in the first.
The optional argument BASE-EL-ONLY will only consider the base dir locals
file."
- (with-parsed-tramp-file-name directory vec
+ (with-parsed-tramp-file-name
+ (if (file-name-absolute-p directory) directory (file-name-concat
default-directory directory))
+ vec
(let* ((localdir (directory-file-name (tramp-file-name-localname vec)))
(file-1 dir-locals-file)
(file-2 (when (string-match "\\.el\\'" file-1)
@@ -234,12 +237,8 @@ The optional argument BASE-EL-ONLY will only consider the
base dir locals file."
(mapcar (lambda (name) (tramp-make-tramp-file-name vec name))
(tramp-send-command-and-read
vec
- (if base-el-only
- (format "test_files_in_dir %s %s"
- localdir file-1)
- (format "test_files_in_dir %s %s %s"
- localdir file-1 file-2)
- )
+ (format "test_files_in_dir %s %s %s"
+ (tramp-shell-quote-argument localdir) file-1 file-2)
)
)
)
@@ -301,7 +300,9 @@ Instead of a string, NAME can also be a predicate taking
one argument
\(a directory) and returning a non-nil value if that directory is the one for
which we're looking. The predicate will be called with every file/directory
the function needs to examine, starting with FILE."
- (with-parsed-tramp-file-name file vec
+ (with-parsed-tramp-file-name
+ (if (file-name-absolute-p file) file (file-name-concat default-directory
file))
+ vec
(if (functionp name)
(tramp-hlo-locate-dominating-file-pred vec name)
(let* ((names (if (listp name) name (list name)))
@@ -338,7 +339,9 @@ This function returns a plist with the fields:
- `:cache' containing the most appropriate cache directory under FILE with a
dotted pair list of dir-locals file and mtime
`:locals' and `:cache' are optional fields, and are missing if not found."
- (with-parsed-tramp-file-name file vec
+ (with-parsed-tramp-file-name
+ (if (file-name-absolute-p file) file (file-name-concat default-directory
file))
+ vec
(tramp-maybe-send-script
vec
tramp-hlo-dir-locals-find-file-cache-update-script