Subject: 27.0.50; tramp-tests issue with double slash
From: Ken Brown <[email-masked]>
To: [email-masked]
Date: Sun, 29 Jul 2018 11:54:10 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

The following parts of tramp-test04-substitute-in-file-name are failing
on Cygwin (and probably also on MS-Windows, but I can't easily test
that):

(should
    (string-equal
     (substitute-in-file-name "/method:host://foo") "/method:host:/foo"))
(should
    (string-equal (substitute-in-file-name "/method:host:/path///foo") 
"/foo"))
(should
    (string-equal (substitute-in-file-name "/method:host://~foo") "/~foo"))

Here are the corresponding evaluations:

(substitute-in-file-name "/method:host://foo")
"/method:host://foo"

(substitute-in-file-name "/method:host:/path///foo")
"//foo"

(substitute-in-file-name "/method:host://~foo")
"//~foo"

This is a consequence of the fact that Tramp calls
substitute-in-file-name on the local part of the file name:

(substitute-in-file-name "//foo")
"//foo"

(substitute-in-file-name "/path///foo")
"//foo"

(substitute-in-file-name "//~foo")
"//~foo"

"//" has a special meaning at the beginning of a file name on Cygwin and
MS-Windows; see the comment near the beginning of
search_embedded_absfilename.  So I don't think there's a real bug here.
Maybe the expected result of the test should simply be adjusted, as in
the attached patch.  Someone who builds on MS-Windows would have to
check this.

Ken

From 328766e02145fcfcdd54c124ff866ce8f2e15d59 Mon Sep 17 00:00:00 2001
From: Ken Brown <[email-masked]>
Date: Sun, 29 Jul 2018 11:45:26 -0400
Subject: [PATCH] Adjust expected results on a tramp test

* test/lisp/net/tramp-tests.el
(tramp-test04-substitute-in-file-name): Adjust the expected
results on Cygwin and MS-Windows, where "//" at the beginning
of a file name has a special meaning.  (Bug#99999)
---
 test/lisp/net/tramp-tests.el | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 5c5eff8798..a29df1682c 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -1781,9 +1781,15 @@ tramp--test-print-duration
   (should (string-equal (substitute-in-file-name "/method:host:///foo") "/foo"))
   (should
    (string-equal
-    (substitute-in-file-name "/method:host://foo") "/method:host:/foo"))
+    (substitute-in-file-name "/method:host://foo")
+    (if (memq system-type '(cygwin windows-nt))
+        "/method:host://foo"
+      "/method:host:/foo")))
   (should
-   (string-equal (substitute-in-file-name "/method:host:/path///foo") "/foo"))
+   (string-equal (substitute-in-file-name "/method:host:/path///foo")
+                 (if (memq system-type '(cygwin windows-nt))
+                     "//foo"
+                   "/foo")))
   (should
    (string-equal
     (substitute-in-file-name "/method:host:/path//foo") "/method:host:/foo"))
@@ -1804,7 +1810,10 @@ tramp--test-print-duration
     "/method:host:/:/path//foo"))
 
   (should
-   (string-equal (substitute-in-file-name "/method:host://~foo") "/~foo"))
+   (string-equal (substitute-in-file-name "/method:host://~foo")
+                 (if (memq system-type '(cygwin windows-nt))
+                     "//~foo"
+                   "/~foo")))
   (should
    (string-equal
     (substitute-in-file-name "/method:host:/~foo") "/method:host:/~foo"))
-- 
2.17.0