2017-03-23 14:58:04 +01:00
|
|
|
|
;;; tramp-tests.el --- Tests of remote file access -*- lexical-binding:t -*-
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2019-01-01 00:59:58 +00:00
|
|
|
|
;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Author: Michael Albinus <michael.albinus@gmx.de>
|
|
|
|
|
|
|
|
|
|
;; This program is free software: you can redistribute it and/or
|
|
|
|
|
;; modify it under the terms of the GNU General Public License as
|
|
|
|
|
;; published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
;; License, or (at your option) any later version.
|
|
|
|
|
;;
|
|
|
|
|
;; This program is distributed in the hope that it will be useful, but
|
|
|
|
|
;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
;; General Public License for more details.
|
|
|
|
|
;;
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
|
;; along with this program. If not, see `https://www.gnu.org/licenses/'.
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2014-04-24 10:21:58 +02:00
|
|
|
|
;; Some of the tests require access to a remote host files. Since
|
|
|
|
|
;; this could be problematic, a mock-up connection method "mock" is
|
|
|
|
|
;; used. Emulating a remote connection, it simply calls "sh -i".
|
2014-04-25 12:35:01 +02:00
|
|
|
|
;; Tramp's file name handlers still run, so this test is sufficient
|
2014-04-24 10:21:58 +02:00
|
|
|
|
;; except for connection establishing.
|
|
|
|
|
|
|
|
|
|
;; If you want to test a real Tramp connection, set
|
|
|
|
|
;; $REMOTE_TEMPORARY_FILE_DIRECTORY to a suitable value in order to
|
|
|
|
|
;; overwrite the default value. If you want to skip tests accessing a
|
|
|
|
|
;; remote host, set this environment variable to "/dev/null" or
|
|
|
|
|
;; whatever is appropriate on your system.
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
;; For slow remote connections, `tramp-test43-asynchronous-requests'
|
2017-12-16 10:47:06 +01:00
|
|
|
|
;; might be too heavy. Setting $REMOTE_PARALLEL_PROCESSES to a proper
|
|
|
|
|
;; value less than 10 could help.
|
|
|
|
|
|
2013-11-08 10:31:15 +01:00
|
|
|
|
;; A whole test run can be performed calling the command `tramp-test-all'.
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2019-05-09 14:23:07 +02:00
|
|
|
|
(require 'cl-lib)
|
2017-03-23 14:58:04 +01:00
|
|
|
|
(require 'dired)
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(require 'ert)
|
2018-01-04 12:48:07 +01:00
|
|
|
|
(require 'ert-x)
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(require 'tramp)
|
2014-02-11 09:31:39 +01:00
|
|
|
|
(require 'vc)
|
|
|
|
|
(require 'vc-bzr)
|
|
|
|
|
(require 'vc-git)
|
|
|
|
|
(require 'vc-hg)
|
|
|
|
|
|
|
|
|
|
(declare-function tramp-find-executable "tramp-sh")
|
|
|
|
|
(declare-function tramp-get-remote-path "tramp-sh")
|
2015-03-04 11:46:06 +01:00
|
|
|
|
(declare-function tramp-get-remote-perl "tramp-sh")
|
2018-05-02 12:31:51 +02:00
|
|
|
|
(declare-function tramp-get-remote-stat "tramp-sh")
|
2019-06-10 17:53:15 +02:00
|
|
|
|
(declare-function tramp-list-tramp-buffers "tramp-cmds")
|
2018-05-02 12:31:51 +02:00
|
|
|
|
(declare-function tramp-method-out-of-band-p "tramp-sh")
|
|
|
|
|
(declare-function tramp-smb-get-localname "tramp-smb")
|
2019-08-05 13:09:26 +02:00
|
|
|
|
(declare-function tramp-time-diff "tramp")
|
2017-03-23 14:58:04 +01:00
|
|
|
|
(defvar auto-save-file-name-transforms)
|
Reduce autoloaded objects in Tramp
* lisp/net/tramp-adb.el (tramp-adb-program)
(tramp-adb-connect-if-not-connected, tramp-adb-prompt):
Remove autoload cookie.
* lisp/net/tramp-cache.el (tramp-connection-properties)
(tramp-persistency-file-name): Remove autoload cookie.
* lisp/net/tramp-ftp.el (tramp-ftp-enable-ange-ftp):
Use `tramp-autoload' cookie.
* lisp/net/tramp-gvfs.el (tramp-gvfs-zeroconf-domain):
Remove autoload cookie.
* lisp/net/tramp-rclone.el (tramp-rclone-program): Remove autoload
cookie.
(tramp-set-completion-function): Use `tramp--with-startup'.
* lisp/net/tramp-sh.el (tramp-inline-compress-start-size)
(tramp-copy-size-limit, tramp-histfile-override)
(tramp-use-ssh-controlmaster-options, tramp-remote-path)
(tramp-remote-process-environment, tramp-sh-extra-args):
Remove autoload cookie.
(tramp-stat-marker, tramp-stat-quoted-marker): Move to tramp.el.
* lisp/net/tramp-smb.el (tramp-smb-program)
(tramp-smb-acl-program, tramp-smb-conf)
(tramp-smb-winexe-program, tramp-smb-winexe-shell-command)
(tramp-smb-winexe-shell-command-switch): Remove autoload cookie.
* lisp/net/tramp-sudoedit.el (server, tramp-sh): Do not require.
* lisp/net/tramp.el (tramp--startup-hook): Define.
(tramp-stat-marker, tramp-stat-quoted-marker): New defconsts,
taken from tramp-sh.el.
* test/lisp/net/tramp-archive-tests.el (tramp-copy-size-limit)
(tramp-persistency-file-name): Declare.
* test/lisp/net/tramp-tests.el (tramp-connection-properties)
(tramp-display-escape-sequence-regexp)
(tramp-inline-compress-start-size, tramp-remote-path): Declare.
2018-12-17 11:50:06 +01:00
|
|
|
|
(defvar tramp-connection-properties)
|
2014-03-07 15:11:37 +01:00
|
|
|
|
(defvar tramp-copy-size-limit)
|
Reduce autoloaded objects in Tramp
* lisp/net/tramp-adb.el (tramp-adb-program)
(tramp-adb-connect-if-not-connected, tramp-adb-prompt):
Remove autoload cookie.
* lisp/net/tramp-cache.el (tramp-connection-properties)
(tramp-persistency-file-name): Remove autoload cookie.
* lisp/net/tramp-ftp.el (tramp-ftp-enable-ange-ftp):
Use `tramp-autoload' cookie.
* lisp/net/tramp-gvfs.el (tramp-gvfs-zeroconf-domain):
Remove autoload cookie.
* lisp/net/tramp-rclone.el (tramp-rclone-program): Remove autoload
cookie.
(tramp-set-completion-function): Use `tramp--with-startup'.
* lisp/net/tramp-sh.el (tramp-inline-compress-start-size)
(tramp-copy-size-limit, tramp-histfile-override)
(tramp-use-ssh-controlmaster-options, tramp-remote-path)
(tramp-remote-process-environment, tramp-sh-extra-args):
Remove autoload cookie.
(tramp-stat-marker, tramp-stat-quoted-marker): Move to tramp.el.
* lisp/net/tramp-smb.el (tramp-smb-program)
(tramp-smb-acl-program, tramp-smb-conf)
(tramp-smb-winexe-program, tramp-smb-winexe-shell-command)
(tramp-smb-winexe-shell-command-switch): Remove autoload cookie.
* lisp/net/tramp-sudoedit.el (server, tramp-sh): Do not require.
* lisp/net/tramp.el (tramp--startup-hook): Define.
(tramp-stat-marker, tramp-stat-quoted-marker): New defconsts,
taken from tramp-sh.el.
* test/lisp/net/tramp-archive-tests.el (tramp-copy-size-limit)
(tramp-persistency-file-name): Declare.
* test/lisp/net/tramp-tests.el (tramp-connection-properties)
(tramp-display-escape-sequence-regexp)
(tramp-inline-compress-start-size, tramp-remote-path): Declare.
2018-12-17 11:50:06 +01:00
|
|
|
|
(defvar tramp-display-escape-sequence-regexp)
|
|
|
|
|
(defvar tramp-inline-compress-start-size)
|
2015-07-23 21:49:40 +02:00
|
|
|
|
(defvar tramp-persistency-file-name)
|
Reduce autoloaded objects in Tramp
* lisp/net/tramp-adb.el (tramp-adb-program)
(tramp-adb-connect-if-not-connected, tramp-adb-prompt):
Remove autoload cookie.
* lisp/net/tramp-cache.el (tramp-connection-properties)
(tramp-persistency-file-name): Remove autoload cookie.
* lisp/net/tramp-ftp.el (tramp-ftp-enable-ange-ftp):
Use `tramp-autoload' cookie.
* lisp/net/tramp-gvfs.el (tramp-gvfs-zeroconf-domain):
Remove autoload cookie.
* lisp/net/tramp-rclone.el (tramp-rclone-program): Remove autoload
cookie.
(tramp-set-completion-function): Use `tramp--with-startup'.
* lisp/net/tramp-sh.el (tramp-inline-compress-start-size)
(tramp-copy-size-limit, tramp-histfile-override)
(tramp-use-ssh-controlmaster-options, tramp-remote-path)
(tramp-remote-process-environment, tramp-sh-extra-args):
Remove autoload cookie.
(tramp-stat-marker, tramp-stat-quoted-marker): Move to tramp.el.
* lisp/net/tramp-smb.el (tramp-smb-program)
(tramp-smb-acl-program, tramp-smb-conf)
(tramp-smb-winexe-program, tramp-smb-winexe-shell-command)
(tramp-smb-winexe-shell-command-switch): Remove autoload cookie.
* lisp/net/tramp-sudoedit.el (server, tramp-sh): Do not require.
* lisp/net/tramp.el (tramp--startup-hook): Define.
(tramp-stat-marker, tramp-stat-quoted-marker): New defconsts,
taken from tramp-sh.el.
* test/lisp/net/tramp-archive-tests.el (tramp-copy-size-limit)
(tramp-persistency-file-name): Declare.
* test/lisp/net/tramp-tests.el (tramp-connection-properties)
(tramp-display-escape-sequence-regexp)
(tramp-inline-compress-start-size, tramp-remote-path): Declare.
2018-12-17 11:50:06 +01:00
|
|
|
|
(defvar tramp-remote-path)
|
2014-06-02 11:53:43 +02:00
|
|
|
|
(defvar tramp-remote-process-environment)
|
Add new Tramp connection method "owncloud"
* doc/misc/tramp.texi (all): Use @acronym{GNOME} thoroughly.
(Using GNOME Online Accounts based methods): Rename from
"Using Google Drive". Add `owncloud'.
(GVFS based methods): Add `owncloud'.
* etc/NEWS: Add Tramp connection method "owncloud".
* lisp/net/tramp-gvfs.el (tramp-gvfs-methods): Add "owncloud".
Remove goa methods if not supported.
(tramp-goa-methods, tramp-goa-service, tramp-goa-path)
(tramp-goa-path-accounts, tramp-goa-interface-documents)
(tramp-goa-interface-printers, tramp-goa-interface-files)
(tramp-goa-interface-contacts, tramp-goa-interface-calendar)
(tramp-goa-interface-oauth2based)
(tramp-goa-interface-account, tramp-goa-identity-regexp)
(tramp-goa-interface-mail, tramp-goa-interface-chat)
(tramp-goa-interface-photos, tramp-goa-path-manager)
(tramp-goa-interface-documents)
(tramp-gvfs-owncloud-default-prefix)
(tramp-gvfs-owncloud-default-prefix-regexp): New defconst.
(tramp-goa-name): New defstruct.
(tramp-gvfs-stringify-dbus-message): Handle all consp messages.
(tramp-dbus-function, tramp-gvfs-get-remote-prefix)
(tramp-get-goa-accounts): New defun.
(with-tramp-dbus-call-method): Use it.
(with-tramp-dbus-get-all-properties): New defmacro.
(tramp-gvfs-url-file-name)
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p, tramp-gvfs-mount-spec):
Map between "owncloud" and "davs".
(tramp-gvfs-maybe-open-connection): Set "vector" connection property.
* test/lisp/net/tramp-tests.el (tramp-gvfs-handler-askquestion):
Suppress run in tests.
(tramp--test-owncloud-p): New defun.
(tramp-test11-copy-file, tramp-test12-rename-file): Use it.
2018-01-05 21:04:39 +01:00
|
|
|
|
|
|
|
|
|
;; Beautify batch mode.
|
|
|
|
|
(when noninteractive
|
|
|
|
|
;; Suppress nasty messages.
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(fset #'shell-command-sentinel #'ignore)
|
Add new Tramp connection method "owncloud"
* doc/misc/tramp.texi (all): Use @acronym{GNOME} thoroughly.
(Using GNOME Online Accounts based methods): Rename from
"Using Google Drive". Add `owncloud'.
(GVFS based methods): Add `owncloud'.
* etc/NEWS: Add Tramp connection method "owncloud".
* lisp/net/tramp-gvfs.el (tramp-gvfs-methods): Add "owncloud".
Remove goa methods if not supported.
(tramp-goa-methods, tramp-goa-service, tramp-goa-path)
(tramp-goa-path-accounts, tramp-goa-interface-documents)
(tramp-goa-interface-printers, tramp-goa-interface-files)
(tramp-goa-interface-contacts, tramp-goa-interface-calendar)
(tramp-goa-interface-oauth2based)
(tramp-goa-interface-account, tramp-goa-identity-regexp)
(tramp-goa-interface-mail, tramp-goa-interface-chat)
(tramp-goa-interface-photos, tramp-goa-path-manager)
(tramp-goa-interface-documents)
(tramp-gvfs-owncloud-default-prefix)
(tramp-gvfs-owncloud-default-prefix-regexp): New defconst.
(tramp-goa-name): New defstruct.
(tramp-gvfs-stringify-dbus-message): Handle all consp messages.
(tramp-dbus-function, tramp-gvfs-get-remote-prefix)
(tramp-get-goa-accounts): New defun.
(with-tramp-dbus-call-method): Use it.
(with-tramp-dbus-get-all-properties): New defmacro.
(tramp-gvfs-url-file-name)
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p, tramp-gvfs-mount-spec):
Map between "owncloud" and "davs".
(tramp-gvfs-maybe-open-connection): Set "vector" connection property.
* test/lisp/net/tramp-tests.el (tramp-gvfs-handler-askquestion):
Suppress run in tests.
(tramp--test-owncloud-p): New defun.
(tramp-test11-copy-file, tramp-test12-rename-file): Use it.
2018-01-05 21:04:39 +01:00
|
|
|
|
;; We do not want to be interrupted.
|
|
|
|
|
(eval-after-load 'tramp-gvfs
|
|
|
|
|
'(fset 'tramp-gvfs-handler-askquestion
|
|
|
|
|
(lambda (_message _choices) '(t nil 0)))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; There is no default value on w32 systems, which could work out of the box.
|
|
|
|
|
(defconst tramp-test-temporary-file-directory
|
2013-11-11 16:22:57 +01:00
|
|
|
|
(cond
|
2013-11-27 15:23:32 +01:00
|
|
|
|
((getenv "REMOTE_TEMPORARY_FILE_DIRECTORY"))
|
2013-11-11 16:22:57 +01:00
|
|
|
|
((eq system-type 'windows-nt) null-device)
|
2014-04-24 10:21:58 +02:00
|
|
|
|
(t (add-to-list
|
|
|
|
|
'tramp-methods
|
|
|
|
|
'("mock"
|
|
|
|
|
(tramp-login-program "sh")
|
|
|
|
|
(tramp-login-args (("-i")))
|
|
|
|
|
(tramp-remote-shell "/bin/sh")
|
|
|
|
|
(tramp-remote-shell-args ("-c"))
|
|
|
|
|
(tramp-connection-timeout 10)))
|
2017-05-23 09:25:03 +02:00
|
|
|
|
(add-to-list
|
|
|
|
|
'tramp-default-host-alist
|
|
|
|
|
`("\\`mock\\'" nil ,(system-name)))
|
2017-06-30 18:38:32 +02:00
|
|
|
|
;; Emacs' Makefile sets $HOME to a nonexistent value. Needed in
|
|
|
|
|
;; batch mode only, therefore.
|
|
|
|
|
(unless (and (null noninteractive) (file-directory-p "~/"))
|
|
|
|
|
(setenv "HOME" temporary-file-directory))
|
2014-04-24 10:21:58 +02:00
|
|
|
|
(format "/mock::%s" temporary-file-directory)))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
"Temporary directory for Tramp tests.")
|
|
|
|
|
|
2018-05-02 12:31:51 +02:00
|
|
|
|
(setq auth-source-save-behavior nil
|
|
|
|
|
password-cache-expiry nil
|
2019-10-18 19:45:07 +02:00
|
|
|
|
remote-file-name-inhibit-cache nil
|
2017-06-14 14:17:22 +02:00
|
|
|
|
tramp-cache-read-persistent-data t ;; For auth-sources.
|
2014-04-18 20:58:13 +02:00
|
|
|
|
tramp-copy-size-limit nil
|
2015-07-23 21:49:40 +02:00
|
|
|
|
tramp-message-show-message nil
|
2019-10-18 19:45:07 +02:00
|
|
|
|
tramp-persistency-file-name nil
|
|
|
|
|
tramp-verbose 0)
|
2013-11-11 16:22:57 +01:00
|
|
|
|
|
2017-07-18 12:53:46 -04:00
|
|
|
|
;; This should happen on hydra only.
|
|
|
|
|
(when (getenv "EMACS_HYDRA_CI")
|
2013-11-08 10:31:15 +01:00
|
|
|
|
(add-to-list 'tramp-remote-path 'tramp-own-remote-path))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
(defvar tramp--test-enabled-checked nil
|
|
|
|
|
"Cached result of `tramp--test-enabled'.
|
|
|
|
|
If the function did run, the value is a cons cell, the `cdr'
|
|
|
|
|
being the result.")
|
|
|
|
|
|
|
|
|
|
(defun tramp--test-enabled ()
|
|
|
|
|
"Whether remote file access is enabled."
|
|
|
|
|
(unless (consp tramp--test-enabled-checked)
|
|
|
|
|
(setq
|
|
|
|
|
tramp--test-enabled-checked
|
|
|
|
|
(cons
|
|
|
|
|
t (ignore-errors
|
|
|
|
|
(and
|
|
|
|
|
(file-remote-p tramp-test-temporary-file-directory)
|
|
|
|
|
(file-directory-p tramp-test-temporary-file-directory)
|
|
|
|
|
(file-writable-p tramp-test-temporary-file-directory))))))
|
2014-02-27 13:07:10 +01:00
|
|
|
|
|
2014-02-28 09:47:43 +01:00
|
|
|
|
(when (cdr tramp--test-enabled-checked)
|
2014-03-07 15:11:37 +01:00
|
|
|
|
;; Cleanup connection.
|
2014-06-15 17:56:58 +02:00
|
|
|
|
(ignore-errors
|
|
|
|
|
(tramp-cleanup-connection
|
|
|
|
|
(tramp-dissect-file-name tramp-test-temporary-file-directory)
|
|
|
|
|
nil 'keep-password)))
|
2014-02-27 13:07:10 +01:00
|
|
|
|
|
2013-11-05 15:46:57 +01:00
|
|
|
|
;; Return result.
|
|
|
|
|
(cdr tramp--test-enabled-checked))
|
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(defsubst tramp--test-expensive-test ()
|
|
|
|
|
"Whether expensive tests are run."
|
|
|
|
|
(ert-select-tests
|
|
|
|
|
(ert--stats-selector ert--current-run-stats)
|
2018-03-23 17:39:29 +01:00
|
|
|
|
(list (make-ert-test :name (ert-test-name (ert-running-test))
|
|
|
|
|
:body nil :tags '(:expensive-test)))))
|
2018-03-17 15:10:46 +01:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(defun tramp--test-make-temp-name (&optional local quoted)
|
2017-07-31 14:32:24 +02:00
|
|
|
|
"Return a temporary file name for test.
|
|
|
|
|
If LOCAL is non-nil, a local file name is returned.
|
|
|
|
|
If QUOTED is non-nil, the local part of the file name is quoted.
|
|
|
|
|
The temporary file is not created."
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-quote #'identity)
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(expand-file-name
|
|
|
|
|
(make-temp-name "tramp-test")
|
|
|
|
|
(if local temporary-file-directory tramp-test-temporary-file-directory))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2017-07-17 14:12:20 +02:00
|
|
|
|
;; Don't print messages in nested `tramp--test-instrument-test-case' calls.
|
|
|
|
|
(defvar tramp--test-instrument-test-case-p nil
|
|
|
|
|
"Whether `tramp--test-instrument-test-case' run.
|
2017-06-29 18:22:38 +02:00
|
|
|
|
This shall used dynamically bound only.")
|
|
|
|
|
|
2017-07-17 14:12:20 +02:00
|
|
|
|
(defmacro tramp--test-instrument-test-case (verbose &rest body)
|
2014-02-20 15:08:00 +01:00
|
|
|
|
"Run BODY with `tramp-verbose' equal VERBOSE.
|
2019-01-23 15:23:57 +01:00
|
|
|
|
Print the content of the Tramp connection and debug buffers, if
|
|
|
|
|
`tramp-verbose' is greater than 3. `should-error' is not handled
|
|
|
|
|
properly. BODY shall not contain a timeout."
|
2014-02-27 13:07:10 +01:00
|
|
|
|
(declare (indent 1) (debug (natnump body)))
|
2017-06-29 18:22:38 +02:00
|
|
|
|
`(let ((tramp-verbose (max (or ,verbose 0) (or tramp-verbose 0)))
|
|
|
|
|
(tramp-message-show-message t)
|
2015-07-21 14:59:18 +02:00
|
|
|
|
(debug-ignored-errors
|
2019-06-30 11:23:06 +02:00
|
|
|
|
(append
|
|
|
|
|
'("^make-symbolic-link not supported$"
|
|
|
|
|
"^error with add-name-to-file")
|
|
|
|
|
debug-ignored-errors))
|
2017-06-29 18:22:38 +02:00
|
|
|
|
inhibit-message)
|
2014-06-29 20:32:35 +02:00
|
|
|
|
(unwind-protect
|
2017-07-17 14:12:20 +02:00
|
|
|
|
(let ((tramp--test-instrument-test-case-p t)) ,@body)
|
2017-06-29 18:22:38 +02:00
|
|
|
|
;; Unwind forms.
|
2017-07-17 14:12:20 +02:00
|
|
|
|
(when (and (null tramp--test-instrument-test-case-p) (> tramp-verbose 3))
|
2019-06-04 12:51:45 +02:00
|
|
|
|
(dolist (buf (tramp-list-tramp-buffers))
|
|
|
|
|
(with-current-buffer buf
|
2019-06-24 17:36:00 +02:00
|
|
|
|
(message ";; %s\n%s" buf (buffer-string))))))))
|
2014-02-20 15:08:00 +01:00
|
|
|
|
|
2017-06-29 18:22:38 +02:00
|
|
|
|
(defsubst tramp--test-message (fmt-string &rest arguments)
|
|
|
|
|
"Emit a message into ERT *Messages*."
|
2017-07-17 14:12:20 +02:00
|
|
|
|
(tramp--test-instrument-test-case 0
|
2017-06-29 18:22:38 +02:00
|
|
|
|
(apply
|
2019-02-28 10:33:05 +01:00
|
|
|
|
#'tramp-message
|
2017-06-29 18:22:38 +02:00
|
|
|
|
(tramp-dissect-file-name tramp-test-temporary-file-directory) 0
|
|
|
|
|
fmt-string arguments)))
|
|
|
|
|
|
|
|
|
|
(defsubst tramp--test-backtrace ()
|
|
|
|
|
"Dump a backtrace into ERT *Messages*."
|
2017-07-17 14:12:20 +02:00
|
|
|
|
(tramp--test-instrument-test-case 10
|
2017-06-29 18:22:38 +02:00
|
|
|
|
(tramp-backtrace
|
|
|
|
|
(tramp-dissect-file-name tramp-test-temporary-file-directory))))
|
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(defmacro tramp--test-print-duration (message &rest body)
|
|
|
|
|
"Run BODY and print a message with duration, prompted by MESSAGE."
|
|
|
|
|
(declare (indent 1) (debug (stringp body)))
|
|
|
|
|
`(let ((start (current-time)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn ,@body)
|
|
|
|
|
(tramp--test-message
|
|
|
|
|
"%s %f sec"
|
|
|
|
|
,message (float-time (time-subtract (current-time) start))))))
|
|
|
|
|
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(ert-deftest tramp-test00-availability ()
|
|
|
|
|
"Test availability of Tramp functions."
|
|
|
|
|
:expected-result (if (tramp--test-enabled) :passed :failed)
|
2017-06-29 18:22:38 +02:00
|
|
|
|
(tramp--test-message
|
|
|
|
|
"Remote directory: `%s'" tramp-test-temporary-file-directory)
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(should (ignore-errors
|
|
|
|
|
(and
|
|
|
|
|
(file-remote-p tramp-test-temporary-file-directory)
|
|
|
|
|
(file-directory-p tramp-test-temporary-file-directory)
|
|
|
|
|
(file-writable-p tramp-test-temporary-file-directory)))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test01-file-name-syntax ()
|
|
|
|
|
"Check remote file name syntax."
|
|
|
|
|
;; Simple cases.
|
|
|
|
|
(should (tramp-tramp-file-p "/method::"))
|
|
|
|
|
(should (tramp-tramp-file-p "/method:host:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/method:user@:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/method:user@host:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/method:user@email@host:"))
|
|
|
|
|
|
|
|
|
|
;; Using a port.
|
|
|
|
|
(should (tramp-tramp-file-p "/method:host#1234:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/method:user@host#1234:"))
|
|
|
|
|
|
|
|
|
|
;; Using an IPv4 address.
|
|
|
|
|
(should (tramp-tramp-file-p "/method:1.2.3.4:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/method:user@1.2.3.4:"))
|
|
|
|
|
|
|
|
|
|
;; Using an IPv6 address.
|
|
|
|
|
(should (tramp-tramp-file-p "/method:[::1]:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/method:user@[::1]:"))
|
|
|
|
|
|
2019-03-05 09:36:33 +01:00
|
|
|
|
;; Using an IPv4 mapped IPv6 address.
|
2019-03-06 12:06:09 +01:00
|
|
|
|
(should (tramp-tramp-file-p "/method:[::ffff:1.2.3.4]:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/method:user@[::ffff:1.2.3.4]:"))
|
2019-03-05 09:36:33 +01:00
|
|
|
|
|
2013-11-05 15:46:57 +01:00
|
|
|
|
;; Local file name part.
|
|
|
|
|
(should (tramp-tramp-file-p "/method:::"))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(should (tramp-tramp-file-p "/method::/:"))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(should (tramp-tramp-file-p "/method::/path/to/file"))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(should (tramp-tramp-file-p "/method::/:/path/to/file"))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(should (tramp-tramp-file-p "/method::file"))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(should (tramp-tramp-file-p "/method::/:file"))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Multihop.
|
|
|
|
|
(should (tramp-tramp-file-p "/method1:|method2::"))
|
|
|
|
|
(should (tramp-tramp-file-p "/method1:host1|method2:host2:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/method1:user1@host1|method2:user2@host2:"))
|
|
|
|
|
(should (tramp-tramp-file-p
|
|
|
|
|
"/method1:user1@host1|method2:user2@host2|method3:user3@host3:"))
|
|
|
|
|
|
|
|
|
|
;; No strings.
|
|
|
|
|
(should-not (tramp-tramp-file-p nil))
|
|
|
|
|
(should-not (tramp-tramp-file-p 'symbol))
|
2018-05-02 12:31:51 +02:00
|
|
|
|
;; No newline or linefeed.
|
|
|
|
|
(should-not (tramp-tramp-file-p "/method::file\nname"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/method::file\rname"))
|
2017-03-13 18:05:59 +01:00
|
|
|
|
;; Ange-ftp syntax.
|
|
|
|
|
(should-not (tramp-tramp-file-p "/host:"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/user@host:"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/1.2.3.4:"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/[]:"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/[::1]:"))
|
2019-03-06 12:06:09 +01:00
|
|
|
|
(should-not (tramp-tramp-file-p "/[::ffff:1.2.3.4]:"))
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(should-not (tramp-tramp-file-p "/host:/:"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/host1|host2:"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/user1@host1|user2@host2:"))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Quote with "/:" suppresses file name handlers.
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(should-not (tramp-tramp-file-p "/::"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/:@:"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/:[]:"))
|
2018-05-21 19:48:15 +02:00
|
|
|
|
;; When `tramp-mode' is nil, Tramp is not activated.
|
|
|
|
|
(let (tramp-mode)
|
|
|
|
|
(should-not (tramp-tramp-file-p "/method:user@host:")))
|
|
|
|
|
;; `tramp-ignored-file-name-regexp' suppresses Tramp.
|
|
|
|
|
(let ((tramp-ignored-file-name-regexp "^/method:user@host:"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/method:user@host:")))
|
2017-03-13 18:05:59 +01:00
|
|
|
|
;; Methods shall be at least two characters on MS Windows, except
|
|
|
|
|
;; the default method.
|
2016-11-09 15:34:40 +01:00
|
|
|
|
(let ((system-type 'windows-nt))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/c:/path/to/file"))
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(should-not (tramp-tramp-file-p "/c::/path/to/file"))
|
|
|
|
|
(should (tramp-tramp-file-p "/-::/path/to/file")))
|
2016-11-09 15:34:40 +01:00
|
|
|
|
(let ((system-type 'gnu/linux))
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(should (tramp-tramp-file-p "/-:h:/path/to/file"))
|
2016-11-09 15:34:40 +01:00
|
|
|
|
(should (tramp-tramp-file-p "/m::/path/to/file"))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2017-04-10 17:22:13 +02:00
|
|
|
|
(ert-deftest tramp-test01-file-name-syntax-simplified ()
|
|
|
|
|
"Check simplified file name syntax."
|
|
|
|
|
:tags '(:expensive-test)
|
|
|
|
|
(let ((syntax tramp-syntax))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(tramp-change-syntax 'simplified)
|
|
|
|
|
;; Simple cases.
|
|
|
|
|
(should (tramp-tramp-file-p "/host:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/user@:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/user@host:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/user@email@host:"))
|
|
|
|
|
|
|
|
|
|
;; Using a port.
|
|
|
|
|
(should (tramp-tramp-file-p "/host#1234:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/user@host#1234:"))
|
|
|
|
|
|
|
|
|
|
;; Using an IPv4 address.
|
|
|
|
|
(should (tramp-tramp-file-p "/1.2.3.4:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/user@1.2.3.4:"))
|
|
|
|
|
|
|
|
|
|
;; Using an IPv6 address.
|
|
|
|
|
(should (tramp-tramp-file-p "/[::1]:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/user@[::1]:"))
|
|
|
|
|
|
2019-03-05 09:36:33 +01:00
|
|
|
|
;; Using an IPv4 mapped IPv6 address.
|
2019-03-06 12:06:09 +01:00
|
|
|
|
(should (tramp-tramp-file-p "/[::ffff:1.2.3.4]:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/user@[::ffff:1.2.3.4]:"))
|
2019-03-05 09:36:33 +01:00
|
|
|
|
|
2017-04-10 17:22:13 +02:00
|
|
|
|
;; Local file name part.
|
|
|
|
|
(should (tramp-tramp-file-p "/host::"))
|
|
|
|
|
(should (tramp-tramp-file-p "/host:/:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/host:/path/to/file"))
|
|
|
|
|
(should (tramp-tramp-file-p "/host:/:/path/to/file"))
|
|
|
|
|
(should (tramp-tramp-file-p "/host:file"))
|
|
|
|
|
(should (tramp-tramp-file-p "/host:/:file"))
|
|
|
|
|
|
|
|
|
|
;; Multihop.
|
|
|
|
|
(should (tramp-tramp-file-p "/host1|host2:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/user1@host1|user2@host2:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/user1@host1|user2@host2|user3@host3:"))
|
|
|
|
|
|
|
|
|
|
;; No strings.
|
|
|
|
|
(should-not (tramp-tramp-file-p nil))
|
|
|
|
|
(should-not (tramp-tramp-file-p 'symbol))
|
|
|
|
|
;; Quote with "/:" suppresses file name handlers.
|
|
|
|
|
(should-not (tramp-tramp-file-p "/::"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/:@:"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/:[]:")))
|
|
|
|
|
|
|
|
|
|
;; Exit.
|
|
|
|
|
(tramp-change-syntax syntax))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test01-file-name-syntax-separate ()
|
|
|
|
|
"Check separate file name syntax."
|
|
|
|
|
:tags '(:expensive-test)
|
|
|
|
|
(let ((syntax tramp-syntax))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(tramp-change-syntax 'separate)
|
|
|
|
|
;; Simple cases.
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/]"))
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/host]"))
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/user@]"))
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/user@host]"))
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/user@email@host]"))
|
|
|
|
|
|
|
|
|
|
;; Using a port.
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/host#1234]"))
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/user@host#1234]"))
|
|
|
|
|
|
|
|
|
|
;; Using an IPv4 address.
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/1.2.3.4]"))
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/user@1.2.3.4]"))
|
|
|
|
|
|
|
|
|
|
;; Using an IPv6 address.
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/::1]"))
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/user@::1]"))
|
|
|
|
|
|
2019-03-05 09:36:33 +01:00
|
|
|
|
;; Using an IPv4 mapped IPv6 address.
|
2019-03-06 12:06:09 +01:00
|
|
|
|
(should (tramp-tramp-file-p "/[method/::ffff:1.2.3.4]"))
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/user@::ffff:1.2.3.4]"))
|
2019-03-05 09:36:33 +01:00
|
|
|
|
|
2017-04-10 17:22:13 +02:00
|
|
|
|
;; Local file name part.
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/]"))
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/]/:"))
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/]/path/to/file"))
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/]/:/path/to/file"))
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/]file"))
|
|
|
|
|
(should (tramp-tramp-file-p "/[method/]/:file"))
|
|
|
|
|
|
|
|
|
|
;; Multihop.
|
|
|
|
|
(should (tramp-tramp-file-p "/[method1/|method2/]"))
|
|
|
|
|
(should (tramp-tramp-file-p "/[method1/host1|method2/host2]"))
|
|
|
|
|
(should
|
|
|
|
|
(tramp-tramp-file-p
|
|
|
|
|
"/[method1/user1@host1|method2/user2@host2]"))
|
|
|
|
|
(should
|
|
|
|
|
(tramp-tramp-file-p
|
|
|
|
|
"/[method1/user1@host1|method2/user2@host2|method3/user3@host3]"))
|
|
|
|
|
|
|
|
|
|
;; No strings.
|
|
|
|
|
(should-not (tramp-tramp-file-p nil))
|
|
|
|
|
(should-not (tramp-tramp-file-p 'symbol))
|
|
|
|
|
;; Ange-ftp syntax.
|
|
|
|
|
(should-not (tramp-tramp-file-p "/host:"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/user@host:"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/1.2.3.4:"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/host:/:"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/host1|host2:"))
|
|
|
|
|
(should-not (tramp-tramp-file-p "/user1@host1|user2@host2:"))
|
|
|
|
|
;; Quote with "/:" suppresses file name handlers.
|
|
|
|
|
(should-not (tramp-tramp-file-p "/:[]")))
|
|
|
|
|
|
|
|
|
|
;; Exit.
|
|
|
|
|
(tramp-change-syntax syntax))))
|
|
|
|
|
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(ert-deftest tramp-test02-file-name-dissect ()
|
|
|
|
|
"Check remote file name components."
|
|
|
|
|
(let ((tramp-default-method "default-method")
|
|
|
|
|
(tramp-default-user "default-user")
|
2018-01-21 00:14:33 +01:00
|
|
|
|
(tramp-default-host "default-host")
|
|
|
|
|
tramp-default-method-alist
|
|
|
|
|
tramp-default-user-alist
|
2018-12-06 15:25:22 +01:00
|
|
|
|
tramp-default-host-alist
|
2019-06-04 12:51:45 +02:00
|
|
|
|
;; Suppress method name check.
|
|
|
|
|
(non-essential t)
|
2018-12-06 15:25:22 +01:00
|
|
|
|
;; Suppress check for multihops.
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(tramp-cache-data (make-hash-table :test #'equal))
|
2018-12-06 15:25:22 +01:00
|
|
|
|
(tramp-connection-properties '((nil "login-program" t))))
|
2019-06-04 12:51:45 +02:00
|
|
|
|
;; An unknown method shall raise an error.
|
|
|
|
|
(let (non-essential)
|
|
|
|
|
(should-error
|
|
|
|
|
(expand-file-name "/method:user@host:")
|
|
|
|
|
:type 'user-error))
|
|
|
|
|
|
2013-11-05 15:46:57 +01:00
|
|
|
|
;; Expand `tramp-default-user' and `tramp-default-host'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method::")
|
|
|
|
|
(format "/%s:%s@%s:" "method" "default-user" "default-host")))
|
|
|
|
|
(should (string-equal (file-remote-p "/method::" 'method) "method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method::" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method::" 'host) "default-host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method::" 'localname) ""))
|
2015-07-29 21:07:01 +02:00
|
|
|
|
(should (string-equal (file-remote-p "/method::" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(file-remote-p "/-:host:")
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(format "/%s:%s@%s:" "default-method" "default-user" "host")))
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(should (string-equal (file-remote-p "/-:host:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:host:" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:host:" 'host) "host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:host:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:host:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-host'.
|
|
|
|
|
(should (string-equal
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(file-remote-p "/-:user@:")
|
|
|
|
|
(format "/%s:%s@%s:" "default-method" "user" "default-host")))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@:" 'user) "user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@:" 'host) "default-host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method'.
|
|
|
|
|
(should (string-equal
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(file-remote-p "/-:user@host:")
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(format "/%s:%s@%s:" "default-method" "user" "host")))
|
|
|
|
|
(should (string-equal
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(file-remote-p "/-:user@host:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@host:" 'user) "user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@host:" 'host) "host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@host:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@host:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:host:")
|
|
|
|
|
(format "/%s:%s@%s:" "method" "default-user" "host")))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:host:" 'method) "method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:host:" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:host:" 'host) "host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:host:" 'localname) ""))
|
2015-07-29 21:07:01 +02:00
|
|
|
|
(should (string-equal (file-remote-p "/method:host:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-host'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@:")
|
|
|
|
|
(format "/%s:%s@%s:" "method" "user" "default-host")))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:user@:" 'method) "method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:user@:" 'user) "user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:user@:" 'host)
|
|
|
|
|
"default-host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:user@:" 'localname) ""))
|
2015-07-29 21:07:01 +02:00
|
|
|
|
(should (string-equal (file-remote-p "/method:user@:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; No expansion.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@host:")
|
|
|
|
|
(format "/%s:%s@%s:" "method" "user" "host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@host:" 'method) "method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:user@host:" 'user) "user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:user@host:" 'host) "host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:user@host:" 'localname) ""))
|
2015-07-29 21:07:01 +02:00
|
|
|
|
(should (string-equal (file-remote-p "/method:user@host:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; No expansion.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@email@host:")
|
|
|
|
|
(format "/%s:%s@%s:" "method" "user@email" "host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@email@host:" 'method) "method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@email@host:" 'user) "user@email"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@email@host:" 'host) "host"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@email@host:" 'localname) ""))
|
2015-07-29 21:07:01 +02:00
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@email@host:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(file-remote-p "/-:host#1234:")
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(format "/%s:%s@%s:" "default-method" "default-user" "host#1234")))
|
|
|
|
|
(should (string-equal
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(file-remote-p "/-:host#1234:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:host#1234:" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:host#1234:" 'host) "host#1234"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:host#1234:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:host#1234:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method'.
|
|
|
|
|
(should (string-equal
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(file-remote-p "/-:user@host#1234:")
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(format "/%s:%s@%s:" "default-method" "user" "host#1234")))
|
|
|
|
|
(should (string-equal
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(file-remote-p "/-:user@host#1234:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@host#1234:" 'user) "user"))
|
2019-06-04 12:51:45 +02:00
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/-:user@host#1234:" 'host) "host#1234"))
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(should (string-equal (file-remote-p "/-:user@host#1234:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@host#1234:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:host#1234:")
|
|
|
|
|
(format "/%s:%s@%s:" "method" "default-user" "host#1234")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:host#1234:" 'method) "method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:host#1234:" 'user) "default-user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:host#1234:" 'host) "host#1234"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:host#1234:" 'localname) ""))
|
2015-07-29 21:07:01 +02:00
|
|
|
|
(should (string-equal (file-remote-p "/method:host#1234:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; No expansion.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@host#1234:")
|
|
|
|
|
(format "/%s:%s@%s:" "method" "user" "host#1234")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@host#1234:" 'method) "method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@host#1234:" 'user) "user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@host#1234:" 'host) "host#1234"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@host#1234:" 'localname) ""))
|
2015-07-29 21:07:01 +02:00
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@host#1234:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(file-remote-p "/-:1.2.3.4:")
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(format "/%s:%s@%s:" "default-method" "default-user" "1.2.3.4")))
|
2019-06-04 12:51:45 +02:00
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/-:1.2.3.4:" 'method) "default-method"))
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(should (string-equal (file-remote-p "/-:1.2.3.4:" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:1.2.3.4:" 'host) "1.2.3.4"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:1.2.3.4:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:1.2.3.4:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method'.
|
|
|
|
|
(should (string-equal
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(file-remote-p "/-:user@1.2.3.4:")
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(format "/%s:%s@%s:" "default-method" "user" "1.2.3.4")))
|
|
|
|
|
(should (string-equal
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(file-remote-p "/-:user@1.2.3.4:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@1.2.3.4:" 'user) "user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@1.2.3.4:" 'host) "1.2.3.4"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@1.2.3.4:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@1.2.3.4:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:1.2.3.4:")
|
|
|
|
|
(format "/%s:%s@%s:" "method" "default-user" "1.2.3.4")))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:1.2.3.4:" 'method) "method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:1.2.3.4:" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:1.2.3.4:" 'host) "1.2.3.4"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:1.2.3.4:" 'localname) ""))
|
2015-07-29 21:07:01 +02:00
|
|
|
|
(should (string-equal (file-remote-p "/method:1.2.3.4:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; No expansion.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@1.2.3.4:")
|
|
|
|
|
(format "/%s:%s@%s:" "method" "user" "1.2.3.4")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@1.2.3.4:" 'method) "method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:user@1.2.3.4:" 'user) "user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@1.2.3.4:" 'host) "1.2.3.4"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@1.2.3.4:" 'localname) ""))
|
2015-07-29 21:07:01 +02:00
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@1.2.3.4:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2013-11-13 16:36:12 +01:00
|
|
|
|
;; Expand `tramp-default-method', `tramp-default-user' and
|
|
|
|
|
;; `tramp-default-host'.
|
|
|
|
|
(should (string-equal
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(file-remote-p "/-:[]:")
|
2013-11-13 16:36:12 +01:00
|
|
|
|
(format
|
|
|
|
|
"/%s:%s@%s:" "default-method" "default-user" "default-host")))
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(should (string-equal (file-remote-p "/-:[]:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:[]:" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:[]:" 'host) "default-host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:[]:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:[]:" 'hop) nil))
|
2013-11-13 16:36:12 +01:00
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(let ((tramp-default-host "::1"))
|
|
|
|
|
(should (string-equal
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(file-remote-p "/-:[]:")
|
2013-11-13 16:36:12 +01:00
|
|
|
|
(format "/%s:%s@%s:" "default-method" "default-user" "[::1]")))
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(should (string-equal (file-remote-p "/-:[]:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:[]:" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:[]:" 'host) "::1"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:[]:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:[]:" 'hop) nil)))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(file-remote-p "/-:[::1]:")
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(format "/%s:%s@%s:" "default-method" "default-user" "[::1]")))
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(should (string-equal (file-remote-p "/-:[::1]:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:[::1]:" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:[::1]:" 'host) "::1"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:[::1]:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:[::1]:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method'.
|
|
|
|
|
(should (string-equal
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(file-remote-p "/-:user@[::1]:")
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(format "/%s:%s@%s:" "default-method" "user" "[::1]")))
|
|
|
|
|
(should (string-equal
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(file-remote-p "/-:user@[::1]:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@[::1]:" 'user) "user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@[::1]:" 'host) "::1"))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@[::1]:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/-:user@[::1]:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:[::1]:")
|
|
|
|
|
(format "/%s:%s@%s:" "method" "default-user" "[::1]")))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:[::1]:" 'method) "method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:[::1]:" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:[::1]:" 'host) "::1"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:[::1]:" 'localname) ""))
|
2015-07-29 21:07:01 +02:00
|
|
|
|
(should (string-equal (file-remote-p "/method:[::1]:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; No expansion.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@[::1]:")
|
|
|
|
|
(format "/%s:%s@%s:" "method" "user" "[::1]")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@[::1]:" 'method) "method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:user@[::1]:" 'user) "user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:user@[::1]:" 'host) "::1"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method:user@[::1]:" 'localname) ""))
|
2015-07-29 21:07:01 +02:00
|
|
|
|
(should (string-equal (file-remote-p "/method:user@[::1]:" 'hop) nil))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
;; Local file name part.
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(should (string-equal (file-remote-p "/-:host:/:" 'localname) "/:"))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(should (string-equal (file-remote-p "/method:::" 'localname) ":"))
|
|
|
|
|
(should (string-equal (file-remote-p "/method:: " 'localname) " "))
|
|
|
|
|
(should (string-equal (file-remote-p "/method::file" 'localname) "file"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/method::/path/to/file" 'localname)
|
|
|
|
|
"/path/to/file"))
|
|
|
|
|
|
|
|
|
|
;; Multihop.
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p "/method1:user1@host1|method2:user2@host2:/path/to/file")
|
2015-07-29 21:07:01 +02:00
|
|
|
|
(format "/%s:%s@%s|%s:%s@%s:"
|
|
|
|
|
"method1" "user1" "host1" "method2" "user2" "host2")))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/method1:user1@host1|method2:user2@host2:/path/to/file" 'method)
|
|
|
|
|
"method2"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/method1:user1@host1|method2:user2@host2:/path/to/file" 'user)
|
|
|
|
|
"user2"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/method1:user1@host1|method2:user2@host2:/path/to/file" 'host)
|
|
|
|
|
"host2"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/method1:user1@host1|method2:user2@host2:/path/to/file" 'localname)
|
|
|
|
|
"/path/to/file"))
|
2015-07-29 21:07:01 +02:00
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/method1:user1@host1|method2:user2@host2:/path/to/file" 'hop)
|
|
|
|
|
(format "%s:%s@%s|"
|
|
|
|
|
"method1" "user1" "host1")))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(concat
|
|
|
|
|
"/method1:user1@host1"
|
|
|
|
|
"|method2:user2@host2"
|
|
|
|
|
"|method3:user3@host3:/path/to/file"))
|
2015-07-29 21:07:01 +02:00
|
|
|
|
(format "/%s:%s@%s|%s:%s@%s|%s:%s@%s:"
|
|
|
|
|
"method1" "user1" "host1"
|
|
|
|
|
"method2" "user2" "host2"
|
|
|
|
|
"method3" "user3" "host3")))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(concat
|
|
|
|
|
"/method1:user1@host1"
|
|
|
|
|
"|method2:user2@host2"
|
|
|
|
|
"|method3:user3@host3:/path/to/file")
|
2013-11-05 15:46:57 +01:00
|
|
|
|
'method)
|
|
|
|
|
"method3"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(concat
|
|
|
|
|
"/method1:user1@host1"
|
|
|
|
|
"|method2:user2@host2"
|
|
|
|
|
"|method3:user3@host3:/path/to/file")
|
2013-11-05 15:46:57 +01:00
|
|
|
|
'user)
|
|
|
|
|
"user3"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(concat
|
|
|
|
|
"/method1:user1@host1"
|
|
|
|
|
"|method2:user2@host2"
|
|
|
|
|
"|method3:user3@host3:/path/to/file")
|
2013-11-05 15:46:57 +01:00
|
|
|
|
'host)
|
|
|
|
|
"host3"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(concat
|
|
|
|
|
"/method1:user1@host1"
|
|
|
|
|
"|method2:user2@host2"
|
|
|
|
|
"|method3:user3@host3:/path/to/file")
|
2013-11-05 15:46:57 +01:00
|
|
|
|
'localname)
|
2015-07-29 21:07:01 +02:00
|
|
|
|
"/path/to/file"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(concat
|
|
|
|
|
"/method1:user1@host1"
|
|
|
|
|
"|method2:user2@host2"
|
|
|
|
|
"|method3:user3@host3:/path/to/file")
|
2015-07-29 21:07:01 +02:00
|
|
|
|
'hop)
|
|
|
|
|
(format "%s:%s@%s|%s:%s@%s|"
|
2018-01-21 00:14:33 +01:00
|
|
|
|
"method1" "user1" "host1" "method2" "user2" "host2")))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method-alist'.
|
|
|
|
|
(add-to-list 'tramp-default-method-alist '("host1" "user1" "method1"))
|
|
|
|
|
(add-to-list 'tramp-default-method-alist '("host2" "user2" "method2"))
|
|
|
|
|
(add-to-list 'tramp-default-method-alist '("host3" "user3" "method3"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/-:user1@host1"
|
|
|
|
|
"|-:user2@host2"
|
|
|
|
|
"|-:user3@host3:/path/to/file"))
|
|
|
|
|
(format "/%s:%s@%s|%s:%s@%s|%s:%s@%s:"
|
2018-10-20 13:38:31 +02:00
|
|
|
|
"method1" "user1" "host1"
|
|
|
|
|
"method2" "user2" "host2"
|
2018-01-21 00:14:33 +01:00
|
|
|
|
"method3" "user3" "host3")))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-user-alist'.
|
|
|
|
|
(add-to-list 'tramp-default-user-alist '("method1" "host1" "user1"))
|
|
|
|
|
(add-to-list 'tramp-default-user-alist '("method2" "host2" "user2"))
|
|
|
|
|
(add-to-list 'tramp-default-user-alist '("method3" "host3" "user3"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/method1:host1"
|
|
|
|
|
"|method2:host2"
|
|
|
|
|
"|method3:host3:/path/to/file"))
|
2018-10-20 13:38:31 +02:00
|
|
|
|
(format "/%s:%s@%s|%s:%s@%s|%s:%s@%s:"
|
|
|
|
|
"method1" "user1" "host1"
|
|
|
|
|
"method2" "user2" "host2"
|
2018-01-21 00:14:33 +01:00
|
|
|
|
"method3" "user3" "host3")))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-host-alist'.
|
|
|
|
|
(add-to-list 'tramp-default-host-alist '("method1" "user1" "host1"))
|
|
|
|
|
(add-to-list 'tramp-default-host-alist '("method2" "user2" "host2"))
|
|
|
|
|
(add-to-list 'tramp-default-host-alist '("method3" "user3" "host3"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/method1:user1@"
|
|
|
|
|
"|method2:user2@"
|
|
|
|
|
"|method3:user3@:/path/to/file"))
|
2018-10-20 13:38:31 +02:00
|
|
|
|
(format "/%s:%s@%s|%s:%s@%s|%s:%s@%s:"
|
|
|
|
|
"method1" "user1" "host1"
|
|
|
|
|
"method2" "user2" "host2"
|
|
|
|
|
"method3" "user3" "host3")))
|
|
|
|
|
|
|
|
|
|
;; Ad-hoc user name and host name expansion.
|
|
|
|
|
(setq tramp-default-method-alist nil
|
|
|
|
|
tramp-default-user-alist nil
|
|
|
|
|
tramp-default-host-alist nil)
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/method1:user1@host1"
|
|
|
|
|
"|method2:user2@"
|
|
|
|
|
"|method3:user3@:/path/to/file"))
|
|
|
|
|
(format "/%s:%s@%s|%s:%s@%s|%s:%s@%s:"
|
|
|
|
|
"method1" "user1" "host1"
|
|
|
|
|
"method2" "user2" "host1"
|
|
|
|
|
"method3" "user3" "host1")))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/method1:%u@%h"
|
2018-11-06 15:48:05 +01:00
|
|
|
|
"|method2:user2@host2"
|
|
|
|
|
"|method3:%u@%h"
|
|
|
|
|
"|method4:user4%domain4@host4#1234:/path/to/file"))
|
|
|
|
|
(format "/%s:%s@%s|%s:%s@%s|%s:%s@%s|%s:%s@%s:"
|
|
|
|
|
"method1" "user2" "host2"
|
|
|
|
|
"method2" "user2" "host2"
|
|
|
|
|
"method3" "user4" "host4"
|
|
|
|
|
"method4" "user4%domain4" "host4#1234")))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2017-04-10 17:22:13 +02:00
|
|
|
|
(ert-deftest tramp-test02-file-name-dissect-simplified ()
|
|
|
|
|
"Check simplified file name components."
|
|
|
|
|
:tags '(:expensive-test)
|
|
|
|
|
(let ((tramp-default-method "default-method")
|
|
|
|
|
(tramp-default-user "default-user")
|
|
|
|
|
(tramp-default-host "default-host")
|
2018-01-21 00:14:33 +01:00
|
|
|
|
tramp-default-user-alist
|
|
|
|
|
tramp-default-host-alist
|
2019-06-04 12:51:45 +02:00
|
|
|
|
;; Suppress method name check.
|
|
|
|
|
(non-essential t)
|
2018-12-06 15:25:22 +01:00
|
|
|
|
;; Suppress check for multihops.
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(tramp-cache-data (make-hash-table :test #'equal))
|
2018-12-06 15:25:22 +01:00
|
|
|
|
(tramp-connection-properties '((nil "login-program" t)))
|
2017-04-10 17:22:13 +02:00
|
|
|
|
(syntax tramp-syntax))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(tramp-change-syntax 'simplified)
|
2019-06-04 12:51:45 +02:00
|
|
|
|
;; An unknown default method shall raise an error.
|
|
|
|
|
(let (non-essential)
|
|
|
|
|
(should-error
|
|
|
|
|
(expand-file-name "/user@host:")
|
|
|
|
|
:type 'user-error))
|
|
|
|
|
|
2017-04-10 17:22:13 +02:00
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/host:")
|
|
|
|
|
(format "/%s@%s:" "default-user" "host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/host:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/host:" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/host:" 'host) "host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/host:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/host:" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-host'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@:")
|
|
|
|
|
(format "/%s@%s:" "user" "default-host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/user@:" 'user) "user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/user@:" 'host) "default-host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/user@:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/user@:" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@host:")
|
|
|
|
|
(format "/%s@%s:" "user" "host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@host:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/user@host:" 'user) "user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/user@host:" 'host) "host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/user@host:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/user@host:" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; No expansion.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@email@host:")
|
|
|
|
|
(format "/%s@%s:" "user@email" "host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/user@email@host:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@email@host:" 'user) "user@email"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@email@host:" 'host) "host"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@email@host:" 'localname) ""))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@email@host:" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/host#1234:")
|
|
|
|
|
(format "/%s@%s:" "default-user" "host#1234")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/host#1234:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/host#1234:" 'user) "default-user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/host#1234:" 'host) "host#1234"))
|
|
|
|
|
(should (string-equal (file-remote-p "/host#1234:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/host#1234:" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@host#1234:")
|
|
|
|
|
(format "/%s@%s:" "user" "host#1234")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@host#1234:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@host#1234:" 'user) "user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@host#1234:" 'host) "host#1234"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@host#1234:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/user@host#1234:" 'hop) nil))
|
|
|
|
|
|
2017-04-16 16:51:24 +02:00
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
2017-04-10 17:22:13 +02:00
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/1.2.3.4:")
|
|
|
|
|
(format "/%s@%s:" "default-user" "1.2.3.4")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/1.2.3.4:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/1.2.3.4:" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/1.2.3.4:" 'host) "1.2.3.4"))
|
|
|
|
|
(should (string-equal (file-remote-p "/1.2.3.4:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/1.2.3.4:" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@1.2.3.4:")
|
|
|
|
|
(format "/%s@%s:" "user" "1.2.3.4")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@1.2.3.4:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/user@1.2.3.4:" 'user) "user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@1.2.3.4:" 'host) "1.2.3.4"))
|
|
|
|
|
(should (string-equal (file-remote-p "/user@1.2.3.4:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/user@1.2.3.4:" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method', `tramp-default-user' and
|
|
|
|
|
;; `tramp-default-host'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[]:")
|
|
|
|
|
(format
|
|
|
|
|
"/%s@%s:" "default-user" "default-host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[]:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[]:" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[]:" 'host) "default-host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[]:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[]:" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(let ((tramp-default-host "::1"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[]:")
|
|
|
|
|
(format "/%s@%s:" "default-user" "[::1]")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[]:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[]:" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[]:" 'host) "::1"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[]:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[]:" 'hop) nil)))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[::1]:")
|
|
|
|
|
(format "/%s@%s:" "default-user" "[::1]")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[::1]:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[::1]:" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[::1]:" 'host) "::1"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[::1]:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[::1]:" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@[::1]:")
|
|
|
|
|
(format "/%s@%s:" "user" "[::1]")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/user@[::1]:" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/user@[::1]:" 'user) "user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/user@[::1]:" 'host) "::1"))
|
|
|
|
|
(should (string-equal (file-remote-p "/user@[::1]:" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/user@[::1]:" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Local file name part.
|
|
|
|
|
(should (string-equal (file-remote-p "/host:/:" 'localname) "/:"))
|
|
|
|
|
(should (string-equal (file-remote-p "/host::" 'localname) ":"))
|
|
|
|
|
(should (string-equal (file-remote-p "/host: " 'localname) " "))
|
|
|
|
|
(should (string-equal (file-remote-p "/host:file" 'localname) "file"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/host:/path/to/file" 'localname)
|
|
|
|
|
"/path/to/file"))
|
|
|
|
|
|
|
|
|
|
;; Multihop.
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p "/user1@host1|user2@host2:/path/to/file")
|
|
|
|
|
(format "/%s@%s|%s@%s:" "user1" "host1" "user2" "host2")))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/user1@host1|user2@host2:/path/to/file" 'method)
|
|
|
|
|
"default-method"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/user1@host1|user2@host2:/path/to/file" 'user)
|
|
|
|
|
"user2"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/user1@host1|user2@host2:/path/to/file" 'host)
|
|
|
|
|
"host2"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/user1@host1|user2@host2:/path/to/file" 'localname)
|
|
|
|
|
"/path/to/file"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/user1@host1|user2@host2:/path/to/file" 'hop)
|
|
|
|
|
(format "%s@%s|" "user1" "host1")))
|
|
|
|
|
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/user1@host1"
|
|
|
|
|
"|user2@host2"
|
|
|
|
|
"|user3@host3:/path/to/file"))
|
|
|
|
|
(format "/%s@%s|%s@%s|%s@%s:"
|
|
|
|
|
"user1" "host1"
|
|
|
|
|
"user2" "host2"
|
|
|
|
|
"user3" "host3")))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/user1@host1"
|
|
|
|
|
"|user2@host2"
|
|
|
|
|
"|user3@host3:/path/to/file")
|
|
|
|
|
'method)
|
|
|
|
|
"default-method"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/user1@host1"
|
|
|
|
|
"|user2@host2"
|
|
|
|
|
"|user3@host3:/path/to/file")
|
|
|
|
|
'user)
|
|
|
|
|
"user3"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/user1@host1"
|
|
|
|
|
"|user2@host2"
|
|
|
|
|
"|user3@host3:/path/to/file")
|
|
|
|
|
'host)
|
|
|
|
|
"host3"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/user1@host1"
|
|
|
|
|
"|user2@host2"
|
|
|
|
|
"|user3@host3:/path/to/file")
|
|
|
|
|
'localname)
|
|
|
|
|
"/path/to/file"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/user1@host1"
|
|
|
|
|
"|user2@host2"
|
|
|
|
|
"|user3@host3:/path/to/file")
|
|
|
|
|
'hop)
|
|
|
|
|
(format "%s@%s|%s@%s|"
|
2018-01-21 00:14:33 +01:00
|
|
|
|
"user1" "host1" "user2" "host2")))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-user-alist'.
|
|
|
|
|
(add-to-list 'tramp-default-user-alist '(nil "host1" "user1"))
|
|
|
|
|
(add-to-list 'tramp-default-user-alist '(nil "host2" "user2"))
|
|
|
|
|
(add-to-list 'tramp-default-user-alist '(nil "host3" "user3"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/host1"
|
|
|
|
|
"|host2"
|
|
|
|
|
"|host3:/path/to/file"))
|
2018-10-20 13:38:31 +02:00
|
|
|
|
(format "/%s@%s|%s@%s|%s@%s:"
|
|
|
|
|
"user1" "host1"
|
|
|
|
|
"user2" "host2"
|
2018-01-21 00:14:33 +01:00
|
|
|
|
"user3" "host3")))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-host-alist'.
|
|
|
|
|
(add-to-list 'tramp-default-host-alist '(nil "user1" "host1"))
|
|
|
|
|
(add-to-list 'tramp-default-host-alist '(nil "user2" "host2"))
|
|
|
|
|
(add-to-list 'tramp-default-host-alist '(nil "user3" "host3"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/user1@"
|
|
|
|
|
"|user2@"
|
|
|
|
|
"|user3@:/path/to/file"))
|
2018-10-20 13:38:31 +02:00
|
|
|
|
(format "/%s@%s|%s@%s|%s@%s:"
|
|
|
|
|
"user1" "host1"
|
|
|
|
|
"user2" "host2"
|
|
|
|
|
"user3" "host3")))
|
|
|
|
|
|
|
|
|
|
;; Ad-hoc user name and host name expansion.
|
|
|
|
|
(setq tramp-default-user-alist nil
|
|
|
|
|
tramp-default-host-alist nil)
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/user1@host1"
|
|
|
|
|
"|user2@"
|
|
|
|
|
"|user3@:/path/to/file"))
|
|
|
|
|
(format "/%s@%s|%s@%s|%s@%s:"
|
|
|
|
|
"user1" "host1"
|
|
|
|
|
"user2" "host1"
|
|
|
|
|
"user3" "host1")))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/%u@%h"
|
2018-11-06 15:48:05 +01:00
|
|
|
|
"|user2@host2"
|
2018-10-20 13:38:31 +02:00
|
|
|
|
"|%u@%h"
|
2018-11-06 15:48:05 +01:00
|
|
|
|
"|user4%domain4@host4#1234:/path/to/file"))
|
|
|
|
|
(format "/%s@%s|%s@%s|%s@%s|%s@%s:"
|
|
|
|
|
"user2" "host2"
|
|
|
|
|
"user2" "host2"
|
|
|
|
|
"user4" "host4"
|
|
|
|
|
"user4%domain4" "host4#1234"))))
|
2017-04-10 17:22:13 +02:00
|
|
|
|
|
|
|
|
|
;; Exit.
|
|
|
|
|
(tramp-change-syntax syntax))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test02-file-name-dissect-separate ()
|
|
|
|
|
"Check separate file name components."
|
|
|
|
|
:tags '(:expensive-test)
|
|
|
|
|
(let ((tramp-default-method "default-method")
|
|
|
|
|
(tramp-default-user "default-user")
|
|
|
|
|
(tramp-default-host "default-host")
|
2018-01-21 00:14:33 +01:00
|
|
|
|
tramp-default-method-alist
|
|
|
|
|
tramp-default-user-alist
|
|
|
|
|
tramp-default-host-alist
|
2019-06-04 12:51:45 +02:00
|
|
|
|
;; Suppress method name check.
|
|
|
|
|
(non-essential t)
|
2018-12-06 15:25:22 +01:00
|
|
|
|
;; Suppress check for multihops.
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(tramp-cache-data (make-hash-table :test #'equal))
|
2018-12-06 15:25:22 +01:00
|
|
|
|
(tramp-connection-properties '((nil "login-program" t)))
|
2017-04-10 17:22:13 +02:00
|
|
|
|
(syntax tramp-syntax))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(tramp-change-syntax 'separate)
|
2019-06-04 12:51:45 +02:00
|
|
|
|
;; An unknown method shall raise an error.
|
|
|
|
|
(let (non-essential)
|
|
|
|
|
(should-error
|
|
|
|
|
(expand-file-name "/[method/user@host]")
|
|
|
|
|
:type 'user-error))
|
|
|
|
|
|
2017-04-10 17:22:13 +02:00
|
|
|
|
;; Expand `tramp-default-user' and `tramp-default-host'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/]")
|
|
|
|
|
(format
|
|
|
|
|
"/[%s/%s@%s]" "method" "default-user" "default-host")))
|
|
|
|
|
(should (string-equal (file-remote-p "/[method/]" 'method) "method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/]" 'host) "default-host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[method/]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[method/]" 'hop) nil))
|
|
|
|
|
|
2017-04-16 16:51:24 +02:00
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/host]")
|
|
|
|
|
(format
|
|
|
|
|
"/[%s/%s@%s]" "default-method" "default-user" "host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/host]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/host]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/host]" 'host) "host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/host]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/host]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-host'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/user@]")
|
|
|
|
|
(format
|
|
|
|
|
"/[%s/%s@%s]" "default-method" "user" "default-host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/user@]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/user@]" 'user) "user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/user@]" 'host) "default-host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/user@]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/user@]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/user@host]")
|
|
|
|
|
(format "/[%s/%s@%s]" "default-method" "user" "host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/user@host]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/user@host]" 'user) "user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/user@host]" 'host) "host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/user@host]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/user@host]" 'hop) nil))
|
|
|
|
|
|
2017-04-10 17:22:13 +02:00
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/host]")
|
|
|
|
|
(format
|
|
|
|
|
"/[%s/%s@%s]" "default-method" "default-user" "host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/host]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/host]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/host]" 'host) "host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/host]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/host]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-host'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/user@]")
|
|
|
|
|
(format
|
|
|
|
|
"/[%s/%s@%s]" "default-method" "user" "default-host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/user@]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/user@]" 'user) "user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/user@]" 'host) "default-host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/user@]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/user@]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/user@host]")
|
|
|
|
|
(format "/[%s/%s@%s]" "default-method" "user" "host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/user@host]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/user@host]" 'user) "user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/user@host]" 'host) "host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/user@host]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/user@host]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/host]")
|
|
|
|
|
(format "/[%s/%s@%s]" "method" "default-user" "host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/host]" 'method) "method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/host]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[method/host]" 'host) "host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[method/host]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[method/host]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-host'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@]")
|
|
|
|
|
(format "/[%s/%s@%s]" "method" "user" "default-host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@]" 'method) "method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[method/user@]" 'user) "user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@]" 'host) "default-host"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[method/user@]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; No expansion.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@host]")
|
|
|
|
|
(format "/[%s/%s@%s]" "method" "user" "host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@host]" 'method) "method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@host]" 'user) "user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@host]" 'host) "host"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@host]" 'localname) ""))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@host]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; No expansion.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@email@host]")
|
|
|
|
|
(format "/[%s/%s@%s]" "method" "user@email" "host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/[method/user@email@host]" 'method) "method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/[method/user@email@host]" 'user) "user@email"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@email@host]" 'host) "host"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@email@host]" 'localname) ""))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@email@host]" 'hop) nil))
|
|
|
|
|
|
2017-04-16 16:51:24 +02:00
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/host#1234]")
|
|
|
|
|
(format
|
|
|
|
|
"/[%s/%s@%s]" "default-method" "default-user" "host#1234")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/host#1234]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/host#1234]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/host#1234]" 'host) "host#1234"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/host#1234]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/host#1234]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/user@host#1234]")
|
|
|
|
|
(format "/[%s/%s@%s]" "default-method" "user" "host#1234")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/[/user@host#1234]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/[/user@host#1234]" 'user) "user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/user@host#1234]" 'host) "host#1234"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/user@host#1234]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/user@host#1234]" 'hop) nil))
|
|
|
|
|
|
2017-04-10 17:22:13 +02:00
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/host#1234]")
|
|
|
|
|
(format
|
|
|
|
|
"/[%s/%s@%s]" "default-method" "default-user" "host#1234")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/host#1234]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/host#1234]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/host#1234]" 'host) "host#1234"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/host#1234]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/host#1234]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/user@host#1234]")
|
|
|
|
|
(format "/[%s/%s@%s]" "default-method" "user" "host#1234")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/[-/user@host#1234]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/[-/user@host#1234]" 'user) "user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/user@host#1234]" 'host) "host#1234"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/user@host#1234]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/user@host#1234]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/host#1234]")
|
|
|
|
|
(format "/[%s/%s@%s]" "method" "default-user" "host#1234")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/host#1234]" 'method) "method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/host#1234]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/host#1234]" 'host) "host#1234"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/host#1234]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[method/host#1234]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; No expansion.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@host#1234]")
|
|
|
|
|
(format "/[%s/%s@%s]" "method" "user" "host#1234")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@host#1234]" 'method) "method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@host#1234]" 'user) "user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/[method/user@host#1234]" 'host) "host#1234"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@host#1234]" 'localname) ""))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@host#1234]" 'hop) nil))
|
|
|
|
|
|
2017-04-16 16:51:24 +02:00
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/1.2.3.4]")
|
|
|
|
|
(format
|
|
|
|
|
"/[%s/%s@%s]" "default-method" "default-user" "1.2.3.4")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/1.2.3.4]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/1.2.3.4]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/1.2.3.4]" 'host) "1.2.3.4"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/1.2.3.4]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/1.2.3.4]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/user@1.2.3.4]")
|
|
|
|
|
(format "/[%s/%s@%s]" "default-method" "user" "1.2.3.4")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/[/user@1.2.3.4]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/user@1.2.3.4]" 'user) "user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/user@1.2.3.4]" 'host) "1.2.3.4"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/user@1.2.3.4]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/user@1.2.3.4]" 'hop) nil))
|
|
|
|
|
|
2017-04-10 17:22:13 +02:00
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/1.2.3.4]")
|
|
|
|
|
(format
|
|
|
|
|
"/[%s/%s@%s]" "default-method" "default-user" "1.2.3.4")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/1.2.3.4]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/1.2.3.4]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/1.2.3.4]" 'host) "1.2.3.4"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/1.2.3.4]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/1.2.3.4]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/user@1.2.3.4]")
|
|
|
|
|
(format "/[%s/%s@%s]" "default-method" "user" "1.2.3.4")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/[-/user@1.2.3.4]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/user@1.2.3.4]" 'user) "user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/user@1.2.3.4]" 'host) "1.2.3.4"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/user@1.2.3.4]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/user@1.2.3.4]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/1.2.3.4]")
|
|
|
|
|
(format "/[%s/%s@%s]" "method" "default-user" "1.2.3.4")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/1.2.3.4]" 'method) "method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/1.2.3.4]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/1.2.3.4]" 'host) "1.2.3.4"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/1.2.3.4]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[method/1.2.3.4]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; No expansion.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@1.2.3.4]")
|
|
|
|
|
(format "/[%s/%s@%s]" "method" "user" "1.2.3.4")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@1.2.3.4]" 'method) "method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@1.2.3.4]" 'user) "user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@1.2.3.4]" 'host) "1.2.3.4"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@1.2.3.4]" 'localname) ""))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@1.2.3.4]" 'hop) nil))
|
|
|
|
|
|
2017-04-16 16:51:24 +02:00
|
|
|
|
;; Expand `tramp-default-method', `tramp-default-user' and
|
|
|
|
|
;; `tramp-default-host'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/]")
|
|
|
|
|
(format
|
|
|
|
|
"/[%s/%s@%s]"
|
|
|
|
|
"default-method" "default-user" "default-host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/]" 'host) "default-host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(let ((tramp-default-host "::1"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/]")
|
|
|
|
|
(format
|
|
|
|
|
"/[%s/%s@%s]"
|
|
|
|
|
"default-method" "default-user" "::1")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/]" 'host) "::1"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/]" 'hop) nil)))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/::1]")
|
|
|
|
|
(format
|
|
|
|
|
"/[%s/%s@%s]" "default-method" "default-user" "::1")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/::1]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/::1]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/::1]" 'host) "::1"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/::1]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/::1]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/user@::1]")
|
|
|
|
|
(format "/[%s/%s@%s]" "default-method" "user" "::1")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[/user@::1]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/user@::1]" 'user) "user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/user@::1]" 'host) "::1"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/user@::1]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[/user@::1]" 'hop) nil))
|
|
|
|
|
|
2017-04-10 17:22:13 +02:00
|
|
|
|
;; Expand `tramp-default-method', `tramp-default-user' and
|
|
|
|
|
;; `tramp-default-host'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/]")
|
|
|
|
|
(format
|
|
|
|
|
"/[%s/%s@%s]"
|
|
|
|
|
"default-method" "default-user" "default-host")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/]" 'host) "default-host"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(let ((tramp-default-host "::1"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/]")
|
|
|
|
|
(format
|
|
|
|
|
"/[%s/%s@%s]"
|
|
|
|
|
"default-method" "default-user" "::1")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/]" 'host) "::1"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/]" 'hop) nil)))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method' and `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/::1]")
|
|
|
|
|
(format
|
|
|
|
|
"/[%s/%s@%s]" "default-method" "default-user" "::1")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/::1]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/::1]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/::1]" 'host) "::1"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/::1]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/::1]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/user@::1]")
|
|
|
|
|
(format "/[%s/%s@%s]" "default-method" "user" "::1")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[-/user@::1]" 'method) "default-method"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/user@::1]" 'user) "user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/user@::1]" 'host) "::1"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/user@::1]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[-/user@::1]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-user'.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/::1]")
|
|
|
|
|
(format "/[%s/%s@%s]" "method" "default-user" "::1")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/::1]" 'method) "method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/::1]" 'user) "default-user"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[method/::1]" 'host) "::1"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[method/::1]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[method/::1]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; No expansion.
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@::1]")
|
|
|
|
|
(format "/[%s/%s@%s]" "method" "user" "::1")))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@::1]" 'method) "method"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@::1]" 'user) "user"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@::1]" 'host) "::1"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/user@::1]" 'localname) ""))
|
|
|
|
|
(should (string-equal (file-remote-p "/[method/user@::1]" 'hop) nil))
|
|
|
|
|
|
|
|
|
|
;; Local file name part.
|
2017-04-16 16:51:24 +02:00
|
|
|
|
(should (string-equal (file-remote-p "/[/host]/:" 'localname) "/:"))
|
2017-04-10 17:22:13 +02:00
|
|
|
|
(should (string-equal (file-remote-p "/[-/host]/:" 'localname) "/:"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[method/]:" 'localname) ":"))
|
|
|
|
|
(should (string-equal (file-remote-p "/[method/] " 'localname) " "))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/]file" 'localname) "file"))
|
|
|
|
|
(should (string-equal
|
|
|
|
|
(file-remote-p "/[method/]/path/to/file" 'localname)
|
|
|
|
|
"/path/to/file"))
|
|
|
|
|
|
|
|
|
|
;; Multihop.
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/[method1/user1@host1|method2/user2@host2]/path/to/file")
|
|
|
|
|
(format "/[%s/%s@%s|%s/%s@%s]"
|
|
|
|
|
"method1" "user1" "host1" "method2" "user2" "host2")))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/[method1/user1@host1|method2/user2@host2]/path/to/file" 'method)
|
|
|
|
|
"method2"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/[method1/user1@host1|method2/user2@host2]/path/to/file" 'user)
|
|
|
|
|
"user2"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/[method1/user1@host1|method2/user2@host2]/path/to/file" 'host)
|
|
|
|
|
"host2"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/[method1/user1@host1|method2/user2@host2]/path/to/file"
|
|
|
|
|
'localname)
|
|
|
|
|
"/path/to/file"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
"/[method1/user1@host1|method2/user2@host2]/path/to/file" 'hop)
|
|
|
|
|
(format "%s/%s@%s|"
|
|
|
|
|
"method1" "user1" "host1")))
|
|
|
|
|
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/[method1/user1@host1"
|
|
|
|
|
"|method2/user2@host2"
|
|
|
|
|
"|method3/user3@host3]/path/to/file"))
|
|
|
|
|
(format "/[%s/%s@%s|%s/%s@%s|%s/%s@%s]"
|
|
|
|
|
"method1" "user1" "host1"
|
|
|
|
|
"method2" "user2" "host2"
|
|
|
|
|
"method3" "user3" "host3")))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/[method1/user1@host1"
|
|
|
|
|
"|method2/user2@host2"
|
|
|
|
|
"|method3/user3@host3]/path/to/file")
|
|
|
|
|
'method)
|
|
|
|
|
"method3"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/[method1/user1@host1"
|
|
|
|
|
"|method2/user2@host2"
|
|
|
|
|
"|method3/user3@host3]/path/to/file")
|
|
|
|
|
'user)
|
|
|
|
|
"user3"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/[method1/user1@host1"
|
|
|
|
|
"|method2/user2@host2"
|
|
|
|
|
"|method3/user3@host3]/path/to/file")
|
|
|
|
|
'host)
|
|
|
|
|
"host3"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/[method1/user1@host1"
|
|
|
|
|
"|method2/user2@host2"
|
|
|
|
|
"|method3/user3@host3]/path/to/file")
|
|
|
|
|
'localname)
|
|
|
|
|
"/path/to/file"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/[method1/user1@host1"
|
|
|
|
|
"|method2/user2@host2"
|
|
|
|
|
"|method3/user3@host3]/path/to/file")
|
|
|
|
|
'hop)
|
|
|
|
|
(format "%s/%s@%s|%s/%s@%s|"
|
2018-01-21 00:14:33 +01:00
|
|
|
|
"method1" "user1" "host1" "method2" "user2" "host2")))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-method-alist'.
|
|
|
|
|
(add-to-list 'tramp-default-method-alist '("host1" "user1" "method1"))
|
|
|
|
|
(add-to-list 'tramp-default-method-alist '("host2" "user2" "method2"))
|
|
|
|
|
(add-to-list 'tramp-default-method-alist '("host3" "user3" "method3"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/[/user1@host1"
|
|
|
|
|
"|/user2@host2"
|
|
|
|
|
"|/user3@host3]/path/to/file"))
|
2018-10-20 13:38:31 +02:00
|
|
|
|
(format "/[%s/%s@%s|%s/%s@%s|%s/%s@%s]"
|
|
|
|
|
"method1" "user1" "host1"
|
|
|
|
|
"method2" "user2" "host2"
|
2018-01-21 00:14:33 +01:00
|
|
|
|
"method3" "user3" "host3")))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-user-alist'.
|
|
|
|
|
(add-to-list 'tramp-default-user-alist '("method1" "host1" "user1"))
|
|
|
|
|
(add-to-list 'tramp-default-user-alist '("method2" "host2" "user2"))
|
|
|
|
|
(add-to-list 'tramp-default-user-alist '("method3" "host3" "user3"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/[method1/host1"
|
|
|
|
|
"|method2/host2"
|
|
|
|
|
"|method3/host3]/path/to/file"))
|
2018-10-20 13:38:31 +02:00
|
|
|
|
(format "/[%s/%s@%s|%s/%s@%s|%s/%s@%s]"
|
|
|
|
|
"method1" "user1" "host1"
|
|
|
|
|
"method2" "user2" "host2"
|
2018-01-21 00:14:33 +01:00
|
|
|
|
"method3" "user3" "host3")))
|
|
|
|
|
|
|
|
|
|
;; Expand `tramp-default-host-alist'.
|
|
|
|
|
(add-to-list 'tramp-default-host-alist '("method1" "user1" "host1"))
|
|
|
|
|
(add-to-list 'tramp-default-host-alist '("method2" "user2" "host2"))
|
|
|
|
|
(add-to-list 'tramp-default-host-alist '("method3" "user3" "host3"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/[method1/user1@"
|
|
|
|
|
"|method2/user2@"
|
|
|
|
|
"|method3/user3@]/path/to/file"))
|
2018-10-20 13:38:31 +02:00
|
|
|
|
(format "/[%s/%s@%s|%s/%s@%s|%s/%s@%s]"
|
|
|
|
|
"method1" "user1" "host1"
|
|
|
|
|
"method2" "user2" "host2"
|
|
|
|
|
"method3" "user3" "host3")))
|
|
|
|
|
|
|
|
|
|
;; Ad-hoc user name and host name expansion.
|
|
|
|
|
(setq tramp-default-method-alist nil
|
|
|
|
|
tramp-default-user-alist nil
|
|
|
|
|
tramp-default-host-alist nil)
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/[method1/user1@host1"
|
|
|
|
|
"|method2/user2@"
|
|
|
|
|
"|method3/user3@]/path/to/file"))
|
|
|
|
|
(format "/[%s/%s@%s|%s/%s@%s|%s/%s@%s]"
|
|
|
|
|
"method1" "user1" "host1"
|
|
|
|
|
"method2" "user2" "host1"
|
|
|
|
|
"method3" "user3" "host1")))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p
|
|
|
|
|
(concat
|
|
|
|
|
"/[method1/%u@%h"
|
2018-11-06 15:48:05 +01:00
|
|
|
|
"|method2/user2@host2"
|
|
|
|
|
"|method3/%u@%h"
|
|
|
|
|
"|method4/user4%domain4@host4#1234]/path/to/file"))
|
|
|
|
|
(format "/[%s/%s@%s|%s/%s@%s|%s/%s@%s|%s/%s@%s]"
|
|
|
|
|
"method1" "user2" "host2"
|
|
|
|
|
"method2" "user2" "host2"
|
|
|
|
|
"method3" "user4" "host4"
|
|
|
|
|
"method4" "user4%domain4" "host4#1234"))))
|
2017-04-10 17:22:13 +02:00
|
|
|
|
|
|
|
|
|
;; Exit.
|
|
|
|
|
(tramp-change-syntax syntax))))
|
|
|
|
|
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(ert-deftest tramp-test03-file-name-defaults ()
|
|
|
|
|
"Check default values for some methods."
|
|
|
|
|
;; Default values in tramp-adb.el.
|
2019-06-04 12:51:45 +02:00
|
|
|
|
(when (assoc "adb" tramp-methods)
|
|
|
|
|
(should (string-equal (file-remote-p "/adb::" 'host) "")))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
;; Default values in tramp-ftp.el.
|
2019-06-04 12:51:45 +02:00
|
|
|
|
(when (assoc "ftp" tramp-methods)
|
|
|
|
|
(should (string-equal (file-remote-p "/-:ftp.host:" 'method) "ftp"))
|
|
|
|
|
(dolist (u '("ftp" "anonymous"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal (file-remote-p (format "/-:%s@:" u) 'method) "ftp"))))
|
2019-01-28 16:33:47 +01:00
|
|
|
|
;; Default values in tramp-sh.el and tramp-sudoedit.el.
|
2019-06-04 12:51:45 +02:00
|
|
|
|
(when (assoc "su" tramp-methods)
|
|
|
|
|
(dolist (h `("127.0.0.1" "[::1]" "localhost" "localhost6" ,(system-name)))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal (file-remote-p (format "/-:root@%s:" h) 'method) "su")))
|
|
|
|
|
(dolist (m '("su" "sudo" "ksu" "doas" "sudoedit"))
|
|
|
|
|
(should (string-equal (file-remote-p (format "/%s::" m) 'user) "root"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal (file-remote-p (format "/%s::" m) 'host) (system-name))))
|
|
|
|
|
(dolist (m '("rcp" "remcp" "rsh" "telnet" "krlogin" "fcp" "nc"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p (format "/%s::" m) 'user) (user-login-name)))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
;; Default values in tramp-smb.el.
|
2019-06-04 12:51:45 +02:00
|
|
|
|
(when (assoc "smb" tramp-methods)
|
|
|
|
|
(should (string-equal (file-remote-p "/smb::" 'user) nil))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2018-03-29 15:59:11 +02:00
|
|
|
|
;; The following test is inspired by Bug#30946.
|
|
|
|
|
(ert-deftest tramp-test03-file-name-host-rules ()
|
|
|
|
|
"Check host name rules for host-less methods."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
|
|
|
|
(skip-unless (tramp--test-sh-p))
|
|
|
|
|
|
|
|
|
|
;; Host names must match rules in case the command template of a
|
|
|
|
|
;; method doesn't use them.
|
|
|
|
|
(dolist (m '("su" "sg" "sudo" "doas" "ksu"))
|
2018-07-01 11:58:55 +02:00
|
|
|
|
(let ((vec (tramp-dissect-file-name tramp-test-temporary-file-directory))
|
|
|
|
|
tramp-connection-properties tramp-default-proxies-alist)
|
|
|
|
|
(ignore-errors (tramp-cleanup-connection vec nil 'keep-password))
|
2018-05-02 12:31:51 +02:00
|
|
|
|
;; Single hop. The host name must match `tramp-local-host-regexp'.
|
|
|
|
|
(should-error
|
|
|
|
|
(find-file (format "/%s:foo:" m))
|
|
|
|
|
:type 'user-error)
|
|
|
|
|
;; Multi hop. The host name must match the previous hop.
|
|
|
|
|
(should-error
|
|
|
|
|
(find-file
|
|
|
|
|
(format
|
|
|
|
|
"%s|%s:foo:"
|
|
|
|
|
(substring (file-remote-p tramp-test-temporary-file-directory) 0 -1)
|
|
|
|
|
m))
|
2018-12-09 17:09:53 +01:00
|
|
|
|
:type 'user-error))))
|
2018-05-02 12:31:51 +02:00
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test03-file-name-method-rules ()
|
|
|
|
|
"Check file name rules for some methods."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2018-12-06 15:25:22 +01:00
|
|
|
|
|
|
|
|
|
;; Multi hops are allowed for inline methods only.
|
|
|
|
|
(should-error
|
|
|
|
|
(file-remote-p "/ssh:user1@host1|method:user2@host2:/path/to/file")
|
|
|
|
|
:type 'user-error)
|
|
|
|
|
(should-error
|
|
|
|
|
(file-remote-p "/method:user1@host1|ssh:user2@host2:/path/to/file")
|
|
|
|
|
:type 'user-error)
|
2018-05-02 12:31:51 +02:00
|
|
|
|
|
|
|
|
|
;; Samba does not support file names with periods followed by
|
|
|
|
|
;; spaces, and trailing periods or spaces.
|
|
|
|
|
(when (tramp-smb-file-name-p tramp-test-temporary-file-directory)
|
|
|
|
|
(dolist (file '("foo." "foo. bar" "foo "))
|
|
|
|
|
(should-error
|
|
|
|
|
(tramp-smb-get-localname
|
|
|
|
|
(tramp-dissect-file-name
|
|
|
|
|
(expand-file-name file tramp-test-temporary-file-directory)))
|
|
|
|
|
:type 'file-error))))
|
2018-03-29 15:59:11 +02:00
|
|
|
|
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(ert-deftest tramp-test04-substitute-in-file-name ()
|
|
|
|
|
"Check `substitute-in-file-name'."
|
2019-06-04 12:51:45 +02:00
|
|
|
|
;; Suppress method name check.
|
|
|
|
|
(let ((tramp-methods (cons '("method") tramp-methods)))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal (substitute-in-file-name "/method:host:///foo") "/foo"))
|
|
|
|
|
(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:/path//foo") "/method:host:/foo"))
|
|
|
|
|
;; Quoting local part.
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(substitute-in-file-name "/method:host:/:///foo")
|
|
|
|
|
"/method:host:/:///foo"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(substitute-in-file-name "/method:host:/://foo") "/method:host:/://foo"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(substitute-in-file-name "/method:host:/:/path///foo")
|
|
|
|
|
"/method:host:/:/path///foo"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(substitute-in-file-name "/method:host:/:/path//foo")
|
|
|
|
|
"/method:host:/:/path//foo"))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
2019-10-31 11:13:13 +01:00
|
|
|
|
;; Forwhatever reasons, the following tests let Emacs crash for
|
|
|
|
|
;; Emacs 24 and Emacs 25, occasionally. No idea what's up.
|
|
|
|
|
(when (or (tramp--test-emacs26-p) (tramp--test-emacs27-p))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal (substitute-in-file-name "/method:host://~foo") "/~foo"))
|
|
|
|
|
(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"))
|
|
|
|
|
;; (substitute-in-file-name "/path/~foo") expands only for a local
|
|
|
|
|
;; user "foo" to "/~foo"". Otherwise, it doesn't expand.
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(substitute-in-file-name
|
|
|
|
|
"/method:host:/path/~foo") "/method:host:/path/~foo"))
|
|
|
|
|
;; Quoting local part.
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(substitute-in-file-name "/method:host:/://~foo")
|
|
|
|
|
"/method:host:/://~foo"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(substitute-in-file-name
|
|
|
|
|
"/method:host:/:/~foo") "/method:host:/:/~foo"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(substitute-in-file-name
|
|
|
|
|
"/method:host:/:/path//~foo") "/method:host:/:/path//~foo"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(substitute-in-file-name
|
|
|
|
|
"/method:host:/:/path/~foo") "/method:host:/:/path/~foo")))
|
2019-06-04 12:51:45 +02:00
|
|
|
|
|
|
|
|
|
(let (process-environment)
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(substitute-in-file-name "/method:host:/path/$FOO")
|
|
|
|
|
"/method:host:/path/$FOO"))
|
|
|
|
|
(setenv "FOO" "bla")
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(substitute-in-file-name "/method:host:/path/$FOO")
|
|
|
|
|
"/method:host:/path/bla"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(substitute-in-file-name "/method:host:/path/$$FOO")
|
|
|
|
|
"/method:host:/path/$FOO"))
|
|
|
|
|
;; Quoting local part.
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(substitute-in-file-name "/method:host:/:/path/$FOO")
|
|
|
|
|
"/method:host:/:/path/$FOO"))
|
|
|
|
|
(setenv "FOO" "bla")
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(substitute-in-file-name "/method:host:/:/path/$FOO")
|
|
|
|
|
"/method:host:/:/path/$FOO"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(substitute-in-file-name "/method:host:/:/path/$$FOO")
|
|
|
|
|
"/method:host:/:/path/$$FOO")))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test05-expand-file-name ()
|
|
|
|
|
"Check `expand-file-name'."
|
2019-06-04 12:51:45 +02:00
|
|
|
|
;; Suppress method name check.
|
|
|
|
|
(let ((tramp-methods (cons '("method") tramp-methods)))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(expand-file-name "/method:host:/path/./file") "/method:host:/path/file"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(expand-file-name "/method:host:/path/../file") "/method:host:/file"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(expand-file-name "/method:host:/path/.") "/method:host:/path"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(expand-file-name "/method:host:/path/..") "/method:host:/"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(expand-file-name "." "/method:host:/path/") "/method:host:/path"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(expand-file-name "" "/method:host:/path/") "/method:host:/path"))
|
|
|
|
|
;; Quoting local part.
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(expand-file-name "/method:host:/:/path/./file")
|
|
|
|
|
"/method:host:/:/path/file"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(expand-file-name "/method:host:/:/path/../file") "/method:host:/:/file"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(expand-file-name "/method:host:/:/~/path/./file")
|
|
|
|
|
"/method:host:/:/~/path/file"))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2019-03-29 17:22:25 +01:00
|
|
|
|
;; The following test is inspired by Bug#26911 and Bug#34834. They
|
|
|
|
|
;; are rather bugs in `expand-file-name', and it fails for all Emacs
|
|
|
|
|
;; versions. Test added for later, when they are fixed.
|
2017-05-16 14:49:51 +02:00
|
|
|
|
(ert-deftest tramp-test05-expand-file-name-relative ()
|
|
|
|
|
"Check `expand-file-name'."
|
|
|
|
|
;; Mark as failed until bug has been fixed.
|
|
|
|
|
:expected-result :failed
|
2017-05-19 13:57:36 +02:00
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2018-03-29 15:59:11 +02:00
|
|
|
|
|
2017-06-05 12:59:26 +02:00
|
|
|
|
;; These are the methods the test doesn't fail.
|
2018-12-06 16:11:27 +01:00
|
|
|
|
(when (or (tramp--test-adb-p) (tramp--test-gvfs-p) (tramp--test-rclone-p)
|
2017-06-05 12:59:26 +02:00
|
|
|
|
(tramp-smb-file-name-p tramp-test-temporary-file-directory))
|
2017-05-19 13:57:36 +02:00
|
|
|
|
(setf (ert-test-expected-result-type
|
|
|
|
|
(ert-get-test 'tramp-test05-expand-file-name-relative))
|
|
|
|
|
:passed))
|
|
|
|
|
|
2017-05-16 14:49:51 +02:00
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(let ((default-directory
|
|
|
|
|
(concat
|
|
|
|
|
(file-remote-p tramp-test-temporary-file-directory) "/path")))
|
|
|
|
|
(expand-file-name ".." "./"))
|
|
|
|
|
(concat (file-remote-p tramp-test-temporary-file-directory) "/"))))
|
|
|
|
|
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(ert-deftest tramp-test06-directory-file-name ()
|
|
|
|
|
"Check `directory-file-name'.
|
2015-03-04 11:46:06 +01:00
|
|
|
|
This checks also `file-name-as-directory', `file-name-directory',
|
|
|
|
|
`file-name-nondirectory' and `unhandled-file-name-directory'."
|
2019-06-04 12:51:45 +02:00
|
|
|
|
;; Suppress method name check.
|
|
|
|
|
(let ((tramp-methods (cons '("method") tramp-methods)))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(directory-file-name "/method:host:/path/to/file")
|
|
|
|
|
"/method:host:/path/to/file"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(directory-file-name "/method:host:/path/to/file/")
|
|
|
|
|
"/method:host:/path/to/file"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(directory-file-name "/method:host:/path/to/file//")
|
|
|
|
|
"/method:host:/path/to/file"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-name-as-directory "/method:host:/path/to/file")
|
|
|
|
|
"/method:host:/path/to/file/"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-name-as-directory "/method:host:/path/to/file/")
|
|
|
|
|
"/method:host:/path/to/file/"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-name-directory "/method:host:/path/to/file")
|
|
|
|
|
"/method:host:/path/to/"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-name-directory "/method:host:/path/to/file/")
|
|
|
|
|
"/method:host:/path/to/file/"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal (file-name-directory "/method:host:file") "/method:host:"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-name-directory "/method:host:path/") "/method:host:path/"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-name-directory "/method:host:path/to") "/method:host:path/"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-name-nondirectory "/method:host:/path/to/file") "file"))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal (file-name-nondirectory "/method:host:/path/to/file/") ""))
|
|
|
|
|
(should-not
|
|
|
|
|
(unhandled-file-name-directory "/method:host:/path/to/file")))
|
2016-05-02 09:02:27 +02:00
|
|
|
|
|
|
|
|
|
;; Bug#10085.
|
Add `make-nearby-temp-file' and `temporary-file-directory'
* doc/lispref/files.texi (Unique File Names):
Introduce `make-nearby-temp-file' and `temporary-file-directory'.
(Magic File Names): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* etc/NEWS (provided): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* lisp/files.el (mounted-file-systems): New defcustom.
(temporary-file-directory, make-nearby-temp-file): New defuns.
(normal-backup-enable-predicate): Fix docstring.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
<make-nearby-temp-file, temporary-file-directory>: Add handler.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `make-nearby-temp-file' and `temporary-file-directory'.
(tramp-get-remote-tmpdir): Remove compatibility code.
(tramp-handle-temporary-file-directory)
(tramp-handle-make-nearby-temp-file): New defuns.
* lisp/org/ob-core.el (org-babel-local-file-name):
* lisp/progmodes/gud.el (gud-common-init):
* lisp/vc/vc-hooks.el (vc-user-login-name): Use `file-remote-p'.
* lisp/vc/vc-git.el (vc-git-checkin): Handle remote log message.
* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name):
Check `tramp--test-enabled'.
(tramp-test18-file-attributes): Add tests for
`file-ownership-preserved-p'.
(tramp-test27-start-file-process, tramp-test28-shell-command):
Reduce timeouts in `accept-process-output'.
(tramp-test--shell-command-to-string-asynchronously): Add timeout.
(tramp-test29-environment-variables): Remove additional sleep calls.
(tramp-test32-make-nearby-temp-file): New test.
(tramp--test-special-characters, tramp--test-utf8): Adapt docstring.
(tramp-test33-special-characters)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls, tramp-test34-utf8)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests)
(tramp-test36-recursive-load, tramp-test37-unload): Rename.
(tramp--test-ftp-p): Simplify check.
(tramp--test-sh-p): New defun.
(tramp-test20-file-modes, tramp-test22-file-times)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command)
(tramp-test29-environment-variables)
(tramp-test30-vc-registered)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests): Use it.
2016-08-07 13:57:23 +02:00
|
|
|
|
(when (tramp--test-enabled) ;; Packages like tramp-gvfs.el might be disabled.
|
|
|
|
|
(dolist (n-e '(nil t))
|
|
|
|
|
;; We must clear `tramp-default-method'. On hydra, it is "ftp",
|
|
|
|
|
;; which ruins the tests.
|
|
|
|
|
(let ((non-essential n-e)
|
2019-01-22 15:22:52 +01:00
|
|
|
|
(tramp-default-method
|
|
|
|
|
(file-remote-p tramp-test-temporary-file-directory 'method)))
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(dolist
|
|
|
|
|
(file
|
|
|
|
|
`(,(format
|
|
|
|
|
"/%s::"
|
|
|
|
|
(file-remote-p tramp-test-temporary-file-directory 'method))
|
|
|
|
|
,(format
|
|
|
|
|
"/-:%s:"
|
|
|
|
|
(file-remote-p tramp-test-temporary-file-directory 'host))))
|
|
|
|
|
(should (string-equal (directory-file-name file) file))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-name-as-directory file)
|
|
|
|
|
(if (tramp-completion-mode-p)
|
|
|
|
|
file (concat file "./"))))
|
|
|
|
|
(should (string-equal (file-name-directory file) file))
|
|
|
|
|
(should (string-equal (file-name-nondirectory file) "")))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test07-file-exists-p ()
|
2013-11-06 09:33:02 +01:00
|
|
|
|
"Check `file-exist-p', `write-region' and `delete-file'."
|
2013-11-08 10:31:15 +01:00
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(let ((tmp-name (tramp--test-make-temp-name nil quoted)))
|
|
|
|
|
(should-not (file-exists-p tmp-name))
|
|
|
|
|
(write-region "foo" nil tmp-name)
|
|
|
|
|
(should (file-exists-p tmp-name))
|
|
|
|
|
(delete-file tmp-name)
|
|
|
|
|
(should-not (file-exists-p tmp-name)))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test08-file-local-copy ()
|
|
|
|
|
"Check `file-local-copy'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
tmp-name2)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(write-region "foo" nil tmp-name1)
|
|
|
|
|
(should (setq tmp-name2 (file-local-copy tmp-name1)))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents tmp-name2)
|
|
|
|
|
(should (string-equal (buffer-string) "foo")))
|
|
|
|
|
;; Check also that a file transfer with compression works.
|
|
|
|
|
(let ((default-directory tramp-test-temporary-file-directory)
|
|
|
|
|
(tramp-copy-size-limit 4)
|
|
|
|
|
(tramp-inline-compress-start-size 2))
|
|
|
|
|
(delete-file tmp-name2)
|
2017-08-30 12:00:26 +02:00
|
|
|
|
(should (setq tmp-name2 (file-local-copy tmp-name1))))
|
|
|
|
|
;; Error case.
|
|
|
|
|
(delete-file tmp-name1)
|
|
|
|
|
(delete-file tmp-name2)
|
|
|
|
|
(should-error
|
|
|
|
|
(setq tmp-name2 (file-local-copy tmp-name1))
|
|
|
|
|
:type tramp-file-missing))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(delete-file tmp-name1)
|
|
|
|
|
(delete-file tmp-name2))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test09-insert-file-contents ()
|
|
|
|
|
"Check `insert-file-contents'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(let ((tmp-name (tramp--test-make-temp-name nil quoted)))
|
|
|
|
|
(unwind-protect
|
2017-08-30 12:00:26 +02:00
|
|
|
|
(with-temp-buffer
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(write-region "foo" nil tmp-name)
|
2017-08-30 12:00:26 +02:00
|
|
|
|
(insert-file-contents tmp-name)
|
|
|
|
|
(should (string-equal (buffer-string) "foo"))
|
|
|
|
|
(insert-file-contents tmp-name)
|
|
|
|
|
(should (string-equal (buffer-string) "foofoo"))
|
|
|
|
|
;; Insert partly.
|
|
|
|
|
(insert-file-contents tmp-name nil 1 3)
|
|
|
|
|
(should (string-equal (buffer-string) "oofoofoo"))
|
|
|
|
|
;; Replace.
|
|
|
|
|
(insert-file-contents tmp-name nil nil nil 'replace)
|
|
|
|
|
(should (string-equal (buffer-string) "foo"))
|
|
|
|
|
;; Error case.
|
|
|
|
|
(delete-file tmp-name)
|
|
|
|
|
(should-error
|
|
|
|
|
(insert-file-contents tmp-name)
|
|
|
|
|
:type tramp-file-missing))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-file tmp-name))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test10-write-region ()
|
|
|
|
|
"Check `write-region'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
2017-05-08 22:17:53 -04:00
|
|
|
|
(let ((tmp-name (tramp--test-make-temp-name nil quoted)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(unwind-protect
|
2017-05-08 22:17:53 -04:00
|
|
|
|
(progn
|
2017-05-16 14:49:51 +02:00
|
|
|
|
;; Write buffer. Use absolute and relative file name.
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert "foo")
|
|
|
|
|
(write-region nil nil tmp-name))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents tmp-name)
|
|
|
|
|
(should (string-equal (buffer-string) "foo")))
|
2017-05-16 14:49:51 +02:00
|
|
|
|
(delete-file tmp-name)
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert "foo")
|
|
|
|
|
(should-not (file-exists-p tmp-name))
|
|
|
|
|
(let ((default-directory (file-name-directory tmp-name)))
|
|
|
|
|
(should-not (file-exists-p (file-name-nondirectory tmp-name)))
|
|
|
|
|
(write-region nil nil (file-name-nondirectory tmp-name))
|
|
|
|
|
(should (file-exists-p (file-name-nondirectory tmp-name))))
|
|
|
|
|
(should (file-exists-p tmp-name)))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents tmp-name)
|
|
|
|
|
(should (string-equal (buffer-string) "foo")))
|
2017-05-09 14:35:56 +02:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Append.
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert "bla")
|
|
|
|
|
(write-region nil nil tmp-name 'append))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents tmp-name)
|
|
|
|
|
(should (string-equal (buffer-string) "foobla")))
|
2017-05-09 14:35:56 +02:00
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert "baz")
|
|
|
|
|
(write-region nil nil tmp-name 3))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents tmp-name)
|
|
|
|
|
(should (string-equal (buffer-string) "foobaz")))
|
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Write string.
|
|
|
|
|
(write-region "foo" nil tmp-name)
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents tmp-name)
|
|
|
|
|
(should (string-equal (buffer-string) "foo")))
|
2017-05-09 14:35:56 +02:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Write partly.
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert "123456789")
|
|
|
|
|
(write-region 3 5 tmp-name))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents tmp-name)
|
2017-08-12 12:30:39 +02:00
|
|
|
|
(should (string-equal (buffer-string) "34")))
|
|
|
|
|
|
2018-01-04 12:48:07 +01:00
|
|
|
|
;; Check message.
|
|
|
|
|
;; Macro `ert-with-message-capture' was introduced in Emacs 26.1.
|
|
|
|
|
(with-no-warnings (when (symbol-plist 'ert-with-message-capture)
|
|
|
|
|
(let ((tramp-message-show-message t))
|
|
|
|
|
(dolist (noninteractive '(nil t))
|
|
|
|
|
(dolist (visit '(nil t "string" no-message))
|
|
|
|
|
(ert-with-message-capture tramp--test-messages
|
|
|
|
|
(write-region "foo" nil tmp-name nil visit)
|
|
|
|
|
;; We must check the last line. There could be
|
|
|
|
|
;; other messages from the progress reporter.
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
(if (and (null noninteractive)
|
|
|
|
|
(or (eq visit t) (null visit) (stringp visit)))
|
|
|
|
|
(format "^Wrote %s\n\\'" tmp-name) "^\\'")
|
|
|
|
|
tramp--test-messages))))))))
|
|
|
|
|
|
2017-08-12 12:30:39 +02:00
|
|
|
|
;; Do not overwrite if excluded.
|
|
|
|
|
(cl-letf (((symbol-function 'y-or-n-p) (lambda (_prompt) t)))
|
|
|
|
|
(write-region "foo" nil tmp-name nil nil nil 'mustbenew))
|
2017-09-13 20:10:40 +02:00
|
|
|
|
;; `mustbenew' is passed to Tramp since Emacs 26.1.
|
|
|
|
|
(when (tramp--test-emacs26-p)
|
2017-08-12 12:30:39 +02:00
|
|
|
|
(should-error
|
|
|
|
|
(cl-letf (((symbol-function 'y-or-n-p) 'ignore))
|
|
|
|
|
(write-region "foo" nil tmp-name nil nil nil 'mustbenew))
|
|
|
|
|
:type 'file-already-exists)
|
|
|
|
|
(should-error
|
|
|
|
|
(write-region "foo" nil tmp-name nil nil nil 'excl)
|
|
|
|
|
:type 'file-already-exists)))
|
2015-06-28 20:51:54 +02:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-file tmp-name))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2019-05-08 09:44:22 +02:00
|
|
|
|
;; The following test is inspired by Bug#35497.
|
2019-05-08 09:13:58 +02:00
|
|
|
|
(ert-deftest tramp-test10-write-region-file-precious-flag ()
|
|
|
|
|
"Check that `file-precious-flag' is respected with Tramp in use."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
|
|
|
|
(skip-unless (tramp--test-sh-p))
|
2019-05-08 09:44:22 +02:00
|
|
|
|
;; The bug is fixed in Emacs 27.1.
|
|
|
|
|
(skip-unless (tramp--test-emacs27-p))
|
2019-05-08 09:13:58 +02:00
|
|
|
|
|
|
|
|
|
(let* ((tmp-name (tramp--test-make-temp-name))
|
|
|
|
|
written-files
|
|
|
|
|
(advice (lambda (_start _end filename &rest _r)
|
|
|
|
|
(push filename written-files))))
|
|
|
|
|
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-current-buffer (find-file-noselect tmp-name)
|
|
|
|
|
;; Write initial contents. Adapt `visited-file-modtime'
|
|
|
|
|
;; in order to suppress confirmation.
|
|
|
|
|
(insert "foo")
|
|
|
|
|
(write-region nil nil tmp-name)
|
|
|
|
|
(set-visited-file-modtime)
|
|
|
|
|
;; Run the test.
|
|
|
|
|
(advice-add 'write-region :before advice)
|
|
|
|
|
(setq-local file-precious-flag t)
|
2019-06-13 20:24:41 -04:00
|
|
|
|
(setq-local backup-inhibited t)
|
2019-05-08 09:13:58 +02:00
|
|
|
|
(insert "bar")
|
|
|
|
|
(should (null (save-buffer)))
|
|
|
|
|
(should-not (cl-member tmp-name written-files :test #'string=)))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (advice-remove 'write-region advice))
|
|
|
|
|
(ignore-errors (delete-file tmp-name)))))
|
|
|
|
|
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(ert-deftest tramp-test11-copy-file ()
|
|
|
|
|
"Check `copy-file'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-02-01 15:49:18 +01:00
|
|
|
|
;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579.
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (and (tramp--test-expensive-test) (tramp--test-emacs27-p))
|
2017-12-06 20:49:30 +01:00
|
|
|
|
'(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name2 (tramp--test-make-temp-name nil quoted))
|
2017-10-20 12:46:54 +02:00
|
|
|
|
(tmp-name3 (tramp--test-make-temp-name 'local quoted)))
|
|
|
|
|
(dolist (source-target
|
|
|
|
|
`(;; Copy on remote side.
|
|
|
|
|
(,tmp-name1 . ,tmp-name2)
|
|
|
|
|
;; Copy from remote side to local side.
|
|
|
|
|
(,tmp-name1 . ,tmp-name3)
|
|
|
|
|
;; Copy from local side to remote side.
|
|
|
|
|
(,tmp-name3 . ,tmp-name1)))
|
|
|
|
|
(let ((source (car source-target))
|
|
|
|
|
(target (cdr source-target)))
|
|
|
|
|
|
|
|
|
|
;; Copy simple file.
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
2019-11-04 17:34:31 +01:00
|
|
|
|
(should-error
|
|
|
|
|
(copy-file source target)
|
|
|
|
|
:type tramp-file-missing)
|
2017-10-20 12:46:54 +02:00
|
|
|
|
(write-region "foo" nil source)
|
|
|
|
|
(should (file-exists-p source))
|
|
|
|
|
(copy-file source target)
|
|
|
|
|
(should (file-exists-p target))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents target)
|
|
|
|
|
(should (string-equal (buffer-string) "foo")))
|
2019-01-23 15:23:57 +01:00
|
|
|
|
(when (tramp--test-expensive-test)
|
|
|
|
|
(should-error
|
|
|
|
|
(copy-file source target)
|
|
|
|
|
:type 'file-already-exists))
|
2017-10-20 12:46:54 +02:00
|
|
|
|
(copy-file source target 'ok))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-file source))
|
|
|
|
|
(ignore-errors (delete-file target)))
|
|
|
|
|
|
|
|
|
|
;; Copy file to directory.
|
|
|
|
|
(unwind-protect
|
Add new Tramp connection method "owncloud"
* doc/misc/tramp.texi (all): Use @acronym{GNOME} thoroughly.
(Using GNOME Online Accounts based methods): Rename from
"Using Google Drive". Add `owncloud'.
(GVFS based methods): Add `owncloud'.
* etc/NEWS: Add Tramp connection method "owncloud".
* lisp/net/tramp-gvfs.el (tramp-gvfs-methods): Add "owncloud".
Remove goa methods if not supported.
(tramp-goa-methods, tramp-goa-service, tramp-goa-path)
(tramp-goa-path-accounts, tramp-goa-interface-documents)
(tramp-goa-interface-printers, tramp-goa-interface-files)
(tramp-goa-interface-contacts, tramp-goa-interface-calendar)
(tramp-goa-interface-oauth2based)
(tramp-goa-interface-account, tramp-goa-identity-regexp)
(tramp-goa-interface-mail, tramp-goa-interface-chat)
(tramp-goa-interface-photos, tramp-goa-path-manager)
(tramp-goa-interface-documents)
(tramp-gvfs-owncloud-default-prefix)
(tramp-gvfs-owncloud-default-prefix-regexp): New defconst.
(tramp-goa-name): New defstruct.
(tramp-gvfs-stringify-dbus-message): Handle all consp messages.
(tramp-dbus-function, tramp-gvfs-get-remote-prefix)
(tramp-get-goa-accounts): New defun.
(with-tramp-dbus-call-method): Use it.
(with-tramp-dbus-get-all-properties): New defmacro.
(tramp-gvfs-url-file-name)
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p, tramp-gvfs-mount-spec):
Map between "owncloud" and "davs".
(tramp-gvfs-maybe-open-connection): Set "vector" connection property.
* test/lisp/net/tramp-tests.el (tramp-gvfs-handler-askquestion):
Suppress run in tests.
(tramp--test-owncloud-p): New defun.
(tramp-test11-copy-file, tramp-test12-rename-file): Use it.
2018-01-05 21:04:39 +01:00
|
|
|
|
;; FIXME: This fails on my QNAP server, see
|
|
|
|
|
;; /share/Web/owncloud/data/owncloud.log
|
2018-08-04 12:05:28 +02:00
|
|
|
|
(unless (tramp--test-nextcloud-p)
|
2017-10-20 12:46:54 +02:00
|
|
|
|
(write-region "foo" nil source)
|
|
|
|
|
(should (file-exists-p source))
|
|
|
|
|
(make-directory target)
|
|
|
|
|
(should (file-directory-p target))
|
2019-01-23 15:23:57 +01:00
|
|
|
|
;; This has been changed in Emacs 26.1.
|
|
|
|
|
(when (and (tramp--test-expensive-test) (tramp--test-emacs26-p))
|
|
|
|
|
(should-error
|
|
|
|
|
(copy-file source target)
|
2019-07-12 15:10:57 +02:00
|
|
|
|
:type 'file-already-exists)
|
|
|
|
|
(should-error
|
|
|
|
|
(copy-file source target 'ok)
|
|
|
|
|
:type 'file-error))
|
2017-10-20 12:46:54 +02:00
|
|
|
|
(copy-file source (file-name-as-directory target))
|
|
|
|
|
(should
|
|
|
|
|
(file-exists-p
|
|
|
|
|
(expand-file-name (file-name-nondirectory source) target))))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-file source))
|
|
|
|
|
(ignore-errors (delete-directory target 'recursive)))
|
|
|
|
|
|
|
|
|
|
;; Copy directory to existing directory.
|
|
|
|
|
(unwind-protect
|
Add new Tramp connection method "owncloud"
* doc/misc/tramp.texi (all): Use @acronym{GNOME} thoroughly.
(Using GNOME Online Accounts based methods): Rename from
"Using Google Drive". Add `owncloud'.
(GVFS based methods): Add `owncloud'.
* etc/NEWS: Add Tramp connection method "owncloud".
* lisp/net/tramp-gvfs.el (tramp-gvfs-methods): Add "owncloud".
Remove goa methods if not supported.
(tramp-goa-methods, tramp-goa-service, tramp-goa-path)
(tramp-goa-path-accounts, tramp-goa-interface-documents)
(tramp-goa-interface-printers, tramp-goa-interface-files)
(tramp-goa-interface-contacts, tramp-goa-interface-calendar)
(tramp-goa-interface-oauth2based)
(tramp-goa-interface-account, tramp-goa-identity-regexp)
(tramp-goa-interface-mail, tramp-goa-interface-chat)
(tramp-goa-interface-photos, tramp-goa-path-manager)
(tramp-goa-interface-documents)
(tramp-gvfs-owncloud-default-prefix)
(tramp-gvfs-owncloud-default-prefix-regexp): New defconst.
(tramp-goa-name): New defstruct.
(tramp-gvfs-stringify-dbus-message): Handle all consp messages.
(tramp-dbus-function, tramp-gvfs-get-remote-prefix)
(tramp-get-goa-accounts): New defun.
(with-tramp-dbus-call-method): Use it.
(with-tramp-dbus-get-all-properties): New defmacro.
(tramp-gvfs-url-file-name)
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p, tramp-gvfs-mount-spec):
Map between "owncloud" and "davs".
(tramp-gvfs-maybe-open-connection): Set "vector" connection property.
* test/lisp/net/tramp-tests.el (tramp-gvfs-handler-askquestion):
Suppress run in tests.
(tramp--test-owncloud-p): New defun.
(tramp-test11-copy-file, tramp-test12-rename-file): Use it.
2018-01-05 21:04:39 +01:00
|
|
|
|
;; FIXME: This fails on my QNAP server, see
|
|
|
|
|
;; /share/Web/owncloud/data/owncloud.log
|
2019-09-18 14:12:54 +02:00
|
|
|
|
(unless (tramp--test-nextcloud-p)
|
2017-10-20 12:46:54 +02:00
|
|
|
|
(make-directory source)
|
|
|
|
|
(should (file-directory-p source))
|
|
|
|
|
(write-region "foo" nil (expand-file-name "foo" source))
|
|
|
|
|
(should (file-exists-p (expand-file-name "foo" source)))
|
|
|
|
|
(make-directory target)
|
|
|
|
|
(should (file-directory-p target))
|
|
|
|
|
;; Directory `target' exists already, so we must use
|
|
|
|
|
;; `file-name-as-directory'.
|
|
|
|
|
(copy-file source (file-name-as-directory target))
|
|
|
|
|
(should
|
|
|
|
|
(file-exists-p
|
|
|
|
|
(expand-file-name
|
|
|
|
|
(concat (file-name-nondirectory source) "/foo") target))))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-directory source 'recursive))
|
|
|
|
|
(ignore-errors (delete-directory target 'recursive)))
|
|
|
|
|
|
|
|
|
|
;; Copy directory/file to non-existing directory.
|
|
|
|
|
(unwind-protect
|
Add new Tramp connection method "owncloud"
* doc/misc/tramp.texi (all): Use @acronym{GNOME} thoroughly.
(Using GNOME Online Accounts based methods): Rename from
"Using Google Drive". Add `owncloud'.
(GVFS based methods): Add `owncloud'.
* etc/NEWS: Add Tramp connection method "owncloud".
* lisp/net/tramp-gvfs.el (tramp-gvfs-methods): Add "owncloud".
Remove goa methods if not supported.
(tramp-goa-methods, tramp-goa-service, tramp-goa-path)
(tramp-goa-path-accounts, tramp-goa-interface-documents)
(tramp-goa-interface-printers, tramp-goa-interface-files)
(tramp-goa-interface-contacts, tramp-goa-interface-calendar)
(tramp-goa-interface-oauth2based)
(tramp-goa-interface-account, tramp-goa-identity-regexp)
(tramp-goa-interface-mail, tramp-goa-interface-chat)
(tramp-goa-interface-photos, tramp-goa-path-manager)
(tramp-goa-interface-documents)
(tramp-gvfs-owncloud-default-prefix)
(tramp-gvfs-owncloud-default-prefix-regexp): New defconst.
(tramp-goa-name): New defstruct.
(tramp-gvfs-stringify-dbus-message): Handle all consp messages.
(tramp-dbus-function, tramp-gvfs-get-remote-prefix)
(tramp-get-goa-accounts): New defun.
(with-tramp-dbus-call-method): Use it.
(with-tramp-dbus-get-all-properties): New defmacro.
(tramp-gvfs-url-file-name)
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p, tramp-gvfs-mount-spec):
Map between "owncloud" and "davs".
(tramp-gvfs-maybe-open-connection): Set "vector" connection property.
* test/lisp/net/tramp-tests.el (tramp-gvfs-handler-askquestion):
Suppress run in tests.
(tramp--test-owncloud-p): New defun.
(tramp-test11-copy-file, tramp-test12-rename-file): Use it.
2018-01-05 21:04:39 +01:00
|
|
|
|
;; FIXME: This fails on my QNAP server, see
|
|
|
|
|
;; /share/Web/owncloud/data/owncloud.log
|
2019-09-18 14:12:54 +02:00
|
|
|
|
(unless (tramp--test-nextcloud-p)
|
2017-10-20 12:46:54 +02:00
|
|
|
|
(make-directory source)
|
|
|
|
|
(should (file-directory-p source))
|
|
|
|
|
(write-region "foo" nil (expand-file-name "foo" source))
|
|
|
|
|
(should (file-exists-p (expand-file-name "foo" source)))
|
|
|
|
|
(make-directory target)
|
|
|
|
|
(should (file-directory-p target))
|
|
|
|
|
(copy-file
|
|
|
|
|
source
|
|
|
|
|
(expand-file-name (file-name-nondirectory source) target))
|
|
|
|
|
(should
|
|
|
|
|
(file-exists-p
|
|
|
|
|
(expand-file-name
|
|
|
|
|
(concat (file-name-nondirectory source) "/foo") target))))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-directory source 'recursive))
|
2019-01-23 15:23:57 +01:00
|
|
|
|
(ignore-errors (delete-directory target 'recursive))))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test12-rename-file ()
|
|
|
|
|
"Check `rename-file'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-02-01 15:49:18 +01:00
|
|
|
|
;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579.
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (and (tramp--test-expensive-test) (tramp--test-emacs27-p))
|
2017-12-06 20:49:30 +01:00
|
|
|
|
'(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name2 (tramp--test-make-temp-name nil quoted))
|
2017-10-20 12:46:54 +02:00
|
|
|
|
(tmp-name3 (tramp--test-make-temp-name 'local quoted)))
|
|
|
|
|
(dolist (source-target
|
|
|
|
|
`(;; Rename on remote side.
|
|
|
|
|
(,tmp-name1 . ,tmp-name2)
|
|
|
|
|
;; Rename from remote side to local side.
|
|
|
|
|
(,tmp-name1 . ,tmp-name3)
|
|
|
|
|
;; Rename from local side to remote side.
|
|
|
|
|
(,tmp-name3 . ,tmp-name1)))
|
|
|
|
|
(let ((source (car source-target))
|
|
|
|
|
(target (cdr source-target)))
|
|
|
|
|
|
|
|
|
|
;; Rename simple file.
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
2019-11-04 17:34:31 +01:00
|
|
|
|
(should-error
|
|
|
|
|
(rename-file source target)
|
|
|
|
|
:type tramp-file-missing)
|
2017-10-20 12:46:54 +02:00
|
|
|
|
(write-region "foo" nil source)
|
|
|
|
|
(should (file-exists-p source))
|
|
|
|
|
(rename-file source target)
|
|
|
|
|
(should-not (file-exists-p source))
|
|
|
|
|
(should (file-exists-p target))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents target)
|
|
|
|
|
(should (string-equal (buffer-string) "foo")))
|
|
|
|
|
(write-region "foo" nil source)
|
|
|
|
|
(should (file-exists-p source))
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(when (tramp--test-expensive-test)
|
|
|
|
|
(should-error
|
|
|
|
|
(rename-file source target)
|
|
|
|
|
:type 'file-already-exists))
|
2017-10-20 12:46:54 +02:00
|
|
|
|
(rename-file source target 'ok)
|
|
|
|
|
(should-not (file-exists-p source)))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-file source))
|
|
|
|
|
(ignore-errors (delete-file target)))
|
|
|
|
|
|
|
|
|
|
;; Rename file to directory.
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(write-region "foo" nil source)
|
|
|
|
|
(should (file-exists-p source))
|
|
|
|
|
(make-directory target)
|
|
|
|
|
(should (file-directory-p target))
|
|
|
|
|
;; This has been changed in Emacs 26.1.
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(when (and (tramp--test-expensive-test) (tramp--test-emacs26-p))
|
2017-10-20 12:46:54 +02:00
|
|
|
|
(should-error
|
|
|
|
|
(rename-file source target)
|
2019-07-12 15:10:57 +02:00
|
|
|
|
:type 'file-already-exists)
|
|
|
|
|
(should-error
|
|
|
|
|
(rename-file source target 'ok)
|
|
|
|
|
:type 'file-error))
|
2017-10-20 12:46:54 +02:00
|
|
|
|
(rename-file source (file-name-as-directory target))
|
|
|
|
|
(should-not (file-exists-p source))
|
|
|
|
|
(should
|
|
|
|
|
(file-exists-p
|
|
|
|
|
(expand-file-name (file-name-nondirectory source) target))))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-file source))
|
|
|
|
|
(ignore-errors (delete-directory target 'recursive)))
|
|
|
|
|
|
|
|
|
|
;; Rename directory to existing directory.
|
|
|
|
|
(unwind-protect
|
Add new Tramp connection method "owncloud"
* doc/misc/tramp.texi (all): Use @acronym{GNOME} thoroughly.
(Using GNOME Online Accounts based methods): Rename from
"Using Google Drive". Add `owncloud'.
(GVFS based methods): Add `owncloud'.
* etc/NEWS: Add Tramp connection method "owncloud".
* lisp/net/tramp-gvfs.el (tramp-gvfs-methods): Add "owncloud".
Remove goa methods if not supported.
(tramp-goa-methods, tramp-goa-service, tramp-goa-path)
(tramp-goa-path-accounts, tramp-goa-interface-documents)
(tramp-goa-interface-printers, tramp-goa-interface-files)
(tramp-goa-interface-contacts, tramp-goa-interface-calendar)
(tramp-goa-interface-oauth2based)
(tramp-goa-interface-account, tramp-goa-identity-regexp)
(tramp-goa-interface-mail, tramp-goa-interface-chat)
(tramp-goa-interface-photos, tramp-goa-path-manager)
(tramp-goa-interface-documents)
(tramp-gvfs-owncloud-default-prefix)
(tramp-gvfs-owncloud-default-prefix-regexp): New defconst.
(tramp-goa-name): New defstruct.
(tramp-gvfs-stringify-dbus-message): Handle all consp messages.
(tramp-dbus-function, tramp-gvfs-get-remote-prefix)
(tramp-get-goa-accounts): New defun.
(with-tramp-dbus-call-method): Use it.
(with-tramp-dbus-get-all-properties): New defmacro.
(tramp-gvfs-url-file-name)
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p, tramp-gvfs-mount-spec):
Map between "owncloud" and "davs".
(tramp-gvfs-maybe-open-connection): Set "vector" connection property.
* test/lisp/net/tramp-tests.el (tramp-gvfs-handler-askquestion):
Suppress run in tests.
(tramp--test-owncloud-p): New defun.
(tramp-test11-copy-file, tramp-test12-rename-file): Use it.
2018-01-05 21:04:39 +01:00
|
|
|
|
;; FIXME: This fails on my QNAP server, see
|
|
|
|
|
;; /share/Web/owncloud/data/owncloud.log
|
2018-08-04 12:05:28 +02:00
|
|
|
|
(unless (tramp--test-nextcloud-p)
|
2017-10-20 12:46:54 +02:00
|
|
|
|
(make-directory source)
|
|
|
|
|
(should (file-directory-p source))
|
|
|
|
|
(write-region "foo" nil (expand-file-name "foo" source))
|
|
|
|
|
(should (file-exists-p (expand-file-name "foo" source)))
|
|
|
|
|
(make-directory target)
|
|
|
|
|
(should (file-directory-p target))
|
|
|
|
|
;; Directory `target' exists already, so we must use
|
|
|
|
|
;; `file-name-as-directory'.
|
|
|
|
|
(rename-file source (file-name-as-directory target))
|
|
|
|
|
(should-not (file-exists-p source))
|
|
|
|
|
(should
|
|
|
|
|
(file-exists-p
|
|
|
|
|
(expand-file-name
|
|
|
|
|
(concat (file-name-nondirectory source) "/foo") target))))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-directory source 'recursive))
|
|
|
|
|
(ignore-errors (delete-directory target 'recursive)))
|
|
|
|
|
|
|
|
|
|
;; Rename directory/file to non-existing directory.
|
|
|
|
|
(unwind-protect
|
Add new Tramp connection method "owncloud"
* doc/misc/tramp.texi (all): Use @acronym{GNOME} thoroughly.
(Using GNOME Online Accounts based methods): Rename from
"Using Google Drive". Add `owncloud'.
(GVFS based methods): Add `owncloud'.
* etc/NEWS: Add Tramp connection method "owncloud".
* lisp/net/tramp-gvfs.el (tramp-gvfs-methods): Add "owncloud".
Remove goa methods if not supported.
(tramp-goa-methods, tramp-goa-service, tramp-goa-path)
(tramp-goa-path-accounts, tramp-goa-interface-documents)
(tramp-goa-interface-printers, tramp-goa-interface-files)
(tramp-goa-interface-contacts, tramp-goa-interface-calendar)
(tramp-goa-interface-oauth2based)
(tramp-goa-interface-account, tramp-goa-identity-regexp)
(tramp-goa-interface-mail, tramp-goa-interface-chat)
(tramp-goa-interface-photos, tramp-goa-path-manager)
(tramp-goa-interface-documents)
(tramp-gvfs-owncloud-default-prefix)
(tramp-gvfs-owncloud-default-prefix-regexp): New defconst.
(tramp-goa-name): New defstruct.
(tramp-gvfs-stringify-dbus-message): Handle all consp messages.
(tramp-dbus-function, tramp-gvfs-get-remote-prefix)
(tramp-get-goa-accounts): New defun.
(with-tramp-dbus-call-method): Use it.
(with-tramp-dbus-get-all-properties): New defmacro.
(tramp-gvfs-url-file-name)
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p, tramp-gvfs-mount-spec):
Map between "owncloud" and "davs".
(tramp-gvfs-maybe-open-connection): Set "vector" connection property.
* test/lisp/net/tramp-tests.el (tramp-gvfs-handler-askquestion):
Suppress run in tests.
(tramp--test-owncloud-p): New defun.
(tramp-test11-copy-file, tramp-test12-rename-file): Use it.
2018-01-05 21:04:39 +01:00
|
|
|
|
;; FIXME: This fails on my QNAP server, see
|
|
|
|
|
;; /share/Web/owncloud/data/owncloud.log
|
2018-08-04 12:05:28 +02:00
|
|
|
|
(unless (tramp--test-nextcloud-p)
|
2017-10-20 12:46:54 +02:00
|
|
|
|
(make-directory source)
|
|
|
|
|
(should (file-directory-p source))
|
|
|
|
|
(write-region "foo" nil (expand-file-name "foo" source))
|
|
|
|
|
(should (file-exists-p (expand-file-name "foo" source)))
|
|
|
|
|
(make-directory target)
|
|
|
|
|
(should (file-directory-p target))
|
|
|
|
|
(rename-file
|
|
|
|
|
source
|
|
|
|
|
(expand-file-name (file-name-nondirectory source) target))
|
|
|
|
|
(should-not (file-exists-p source))
|
|
|
|
|
(should
|
|
|
|
|
(file-exists-p
|
|
|
|
|
(expand-file-name
|
|
|
|
|
(concat (file-name-nondirectory source) "/foo") target))))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-directory source 'recursive))
|
|
|
|
|
(ignore-errors (delete-directory target 'recursive))))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test13-make-directory ()
|
|
|
|
|
"Check `make-directory'.
|
|
|
|
|
This tests also `file-directory-p' and `file-accessible-directory-p'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(let* ((tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name2 (expand-file-name "foo/bar" tmp-name1)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(make-directory tmp-name1)
|
|
|
|
|
(should (file-directory-p tmp-name1))
|
|
|
|
|
(should (file-accessible-directory-p tmp-name1))
|
2017-09-12 11:20:49 +02:00
|
|
|
|
(should-error (make-directory tmp-name2) :type 'file-error)
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(make-directory tmp-name2 'parents)
|
|
|
|
|
(should (file-directory-p tmp-name2))
|
2017-10-08 13:55:20 +02:00
|
|
|
|
(should (file-accessible-directory-p tmp-name2))
|
|
|
|
|
;; If PARENTS is non-nil, `make-directory' shall not
|
|
|
|
|
;; signal an error when DIR exists already.
|
|
|
|
|
(make-directory tmp-name2 'parents))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-directory tmp-name1 'recursive))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test14-delete-directory ()
|
|
|
|
|
"Check `delete-directory'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
2019-11-04 17:34:31 +01:00
|
|
|
|
(let* ((tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name2 (expand-file-name "foo" tmp-name1)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Delete empty directory.
|
2019-11-04 17:34:31 +01:00
|
|
|
|
(make-directory tmp-name1)
|
|
|
|
|
(should (file-directory-p tmp-name1))
|
|
|
|
|
(delete-directory tmp-name1)
|
|
|
|
|
(should-not (file-directory-p tmp-name1))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Delete non-empty directory.
|
2019-11-04 17:34:31 +01:00
|
|
|
|
(make-directory tmp-name1)
|
|
|
|
|
(should (file-directory-p tmp-name1))
|
|
|
|
|
(write-region "foo" nil (expand-file-name "bla" tmp-name1))
|
|
|
|
|
(should (file-exists-p (expand-file-name "bla" tmp-name1)))
|
|
|
|
|
(make-directory tmp-name2)
|
|
|
|
|
(should (file-directory-p tmp-name2))
|
|
|
|
|
(write-region "foo" nil (expand-file-name "bla" tmp-name2))
|
|
|
|
|
(should (file-exists-p (expand-file-name "bla" tmp-name2)))
|
|
|
|
|
(should-error (delete-directory tmp-name1) :type 'file-error)
|
|
|
|
|
(delete-directory tmp-name1 'recursive)
|
|
|
|
|
(should-not (file-directory-p tmp-name1)))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test15-copy-directory ()
|
|
|
|
|
"Check `copy-directory'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(let* ((tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name2 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name3 (expand-file-name
|
|
|
|
|
(file-name-nondirectory tmp-name1) tmp-name2))
|
|
|
|
|
(tmp-name4 (expand-file-name "foo" tmp-name1))
|
|
|
|
|
(tmp-name5 (expand-file-name "foo" tmp-name2))
|
|
|
|
|
(tmp-name6 (expand-file-name "foo" tmp-name3)))
|
|
|
|
|
|
|
|
|
|
;; Copy complete directory.
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
2019-11-04 17:34:31 +01:00
|
|
|
|
(should-error
|
|
|
|
|
(copy-directory tmp-name1 tmp-name2)
|
|
|
|
|
:type tramp-file-missing)
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Copy empty directory.
|
|
|
|
|
(make-directory tmp-name1)
|
|
|
|
|
(write-region "foo" nil tmp-name4)
|
|
|
|
|
(should (file-directory-p tmp-name1))
|
|
|
|
|
(should (file-exists-p tmp-name4))
|
|
|
|
|
(copy-directory tmp-name1 tmp-name2)
|
|
|
|
|
(should (file-directory-p tmp-name2))
|
|
|
|
|
(should (file-exists-p tmp-name5))
|
|
|
|
|
;; Target directory does exist already.
|
2017-09-13 20:10:40 +02:00
|
|
|
|
;; This has been changed in Emacs 26.1.
|
|
|
|
|
(when (tramp--test-emacs26-p)
|
|
|
|
|
(should-error
|
|
|
|
|
(copy-directory tmp-name1 tmp-name2)
|
|
|
|
|
:type 'file-error))
|
2017-09-10 23:04:10 -07:00
|
|
|
|
(copy-directory tmp-name1 (file-name-as-directory tmp-name2))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(should (file-directory-p tmp-name3))
|
|
|
|
|
(should (file-exists-p tmp-name6)))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(delete-directory tmp-name1 'recursive)
|
|
|
|
|
(delete-directory tmp-name2 'recursive)))
|
|
|
|
|
|
|
|
|
|
;; Copy directory contents.
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
;; Copy empty directory.
|
|
|
|
|
(make-directory tmp-name1)
|
|
|
|
|
(write-region "foo" nil tmp-name4)
|
|
|
|
|
(should (file-directory-p tmp-name1))
|
|
|
|
|
(should (file-exists-p tmp-name4))
|
|
|
|
|
(copy-directory tmp-name1 tmp-name2 nil 'parents 'contents)
|
|
|
|
|
(should (file-directory-p tmp-name2))
|
|
|
|
|
(should (file-exists-p tmp-name5))
|
|
|
|
|
;; Target directory does exist already.
|
|
|
|
|
(delete-file tmp-name5)
|
|
|
|
|
(should-not (file-exists-p tmp-name5))
|
2017-09-12 11:20:49 +02:00
|
|
|
|
(copy-directory
|
|
|
|
|
tmp-name1 (file-name-as-directory tmp-name2)
|
|
|
|
|
nil 'parents 'contents)
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(should (file-directory-p tmp-name2))
|
|
|
|
|
(should (file-exists-p tmp-name5))
|
|
|
|
|
(should-not (file-directory-p tmp-name3))
|
|
|
|
|
(should-not (file-exists-p tmp-name6)))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(delete-directory tmp-name1 'recursive)
|
|
|
|
|
(delete-directory tmp-name2 'recursive))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test16-directory-files ()
|
|
|
|
|
"Check `directory-files'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
2017-08-22 16:22:33 +02:00
|
|
|
|
(let* ((tmp-name1 (tramp--test-make-temp-name nil quoted))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(tmp-name2 (expand-file-name "bla" tmp-name1))
|
|
|
|
|
(tmp-name3 (expand-file-name "foo" tmp-name1)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
2019-11-04 17:34:31 +01:00
|
|
|
|
(should-error
|
|
|
|
|
(directory-files tmp-name1)
|
|
|
|
|
:type tramp-file-missing)
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(make-directory tmp-name1)
|
|
|
|
|
(write-region "foo" nil tmp-name2)
|
|
|
|
|
(write-region "bla" nil tmp-name3)
|
|
|
|
|
(should (file-directory-p tmp-name1))
|
|
|
|
|
(should (file-exists-p tmp-name2))
|
|
|
|
|
(should (file-exists-p tmp-name3))
|
|
|
|
|
(should (equal (directory-files tmp-name1) '("." ".." "bla" "foo")))
|
|
|
|
|
(should (equal (directory-files tmp-name1 'full)
|
|
|
|
|
`(,(concat tmp-name1 "/.")
|
|
|
|
|
,(concat tmp-name1 "/..")
|
|
|
|
|
,tmp-name2 ,tmp-name3)))
|
|
|
|
|
(should (equal (directory-files
|
|
|
|
|
tmp-name1 nil directory-files-no-dot-files-regexp)
|
|
|
|
|
'("bla" "foo")))
|
|
|
|
|
(should (equal (directory-files
|
|
|
|
|
tmp-name1 'full directory-files-no-dot-files-regexp)
|
|
|
|
|
`(,tmp-name2 ,tmp-name3))))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-directory tmp-name1 'recursive))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2017-08-22 16:22:33 +02:00
|
|
|
|
;; This is not a file name handler test. But Tramp needed to apply an
|
|
|
|
|
;; advice for older Emacs versions, so we check that this has been fixed.
|
|
|
|
|
(ert-deftest tramp-test16-file-expand-wildcards ()
|
|
|
|
|
"Check `file-expand-wildcards'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
2017-08-22 16:22:33 +02:00
|
|
|
|
(let* ((tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name2 (expand-file-name "foo" tmp-name1))
|
|
|
|
|
(tmp-name3 (expand-file-name "bar" tmp-name1))
|
|
|
|
|
(tmp-name4 (expand-file-name "baz" tmp-name1))
|
|
|
|
|
(default-directory tmp-name1))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(make-directory tmp-name1)
|
|
|
|
|
(write-region "foo" nil tmp-name2)
|
|
|
|
|
(write-region "bar" nil tmp-name3)
|
|
|
|
|
(write-region "baz" nil tmp-name4)
|
|
|
|
|
(should (file-directory-p tmp-name1))
|
|
|
|
|
(should (file-exists-p tmp-name2))
|
|
|
|
|
(should (file-exists-p tmp-name3))
|
|
|
|
|
(should (file-exists-p tmp-name4))
|
|
|
|
|
|
2017-09-13 20:10:40 +02:00
|
|
|
|
;; `sort' works destructive.
|
|
|
|
|
(should
|
|
|
|
|
(equal (file-expand-wildcards "*")
|
|
|
|
|
(sort (copy-sequence '("foo" "bar" "baz")) 'string<)))
|
|
|
|
|
(should
|
|
|
|
|
(equal (file-expand-wildcards "ba?")
|
|
|
|
|
(sort (copy-sequence '("bar" "baz")) 'string<)))
|
|
|
|
|
(should
|
|
|
|
|
(equal (file-expand-wildcards "ba[rz]")
|
|
|
|
|
(sort (copy-sequence '("bar" "baz")) 'string<)))
|
|
|
|
|
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(file-expand-wildcards "*" 'full)
|
|
|
|
|
(sort
|
|
|
|
|
(copy-sequence `(,tmp-name2 ,tmp-name3 ,tmp-name4)) 'string<)))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(file-expand-wildcards "ba?" 'full)
|
|
|
|
|
(sort (copy-sequence `(,tmp-name3 ,tmp-name4)) 'string<)))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(file-expand-wildcards "ba[rz]" 'full)
|
|
|
|
|
(sort (copy-sequence `(,tmp-name3 ,tmp-name4)) 'string<)))
|
|
|
|
|
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(file-expand-wildcards (concat tmp-name1 "/" "*"))
|
|
|
|
|
(sort
|
|
|
|
|
(copy-sequence `(,tmp-name2 ,tmp-name3 ,tmp-name4)) 'string<)))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(file-expand-wildcards (concat tmp-name1 "/" "ba?"))
|
|
|
|
|
(sort (copy-sequence `(,tmp-name3 ,tmp-name4)) 'string<)))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(file-expand-wildcards (concat tmp-name1 "/" "ba[rz]"))
|
|
|
|
|
(sort (copy-sequence `(,tmp-name3 ,tmp-name4)) 'string<))))
|
2017-08-22 16:22:33 +02:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors
|
2017-11-06 18:50:53 -05:00
|
|
|
|
(delete-directory tmp-name1 'recursive))))))
|
2017-08-22 16:22:33 +02:00
|
|
|
|
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(ert-deftest tramp-test17-insert-directory ()
|
|
|
|
|
"Check `insert-directory'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
2017-03-13 18:05:59 +01:00
|
|
|
|
(let* ((tmp-name1
|
|
|
|
|
(expand-file-name (tramp--test-make-temp-name nil quoted)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(tmp-name2 (expand-file-name "foo" tmp-name1))
|
|
|
|
|
;; We test for the summary line. Keyword "total" could be localized.
|
|
|
|
|
(process-environment
|
|
|
|
|
(append '("LANG=C" "LANGUAGE=C" "LC_ALL=C") process-environment)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(make-directory tmp-name1)
|
|
|
|
|
(write-region "foo" nil tmp-name2)
|
|
|
|
|
(should (file-directory-p tmp-name1))
|
|
|
|
|
(should (file-exists-p tmp-name2))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-directory tmp-name1 nil)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(should (looking-at-p (regexp-quote tmp-name1))))
|
2017-11-25 16:03:53 +01:00
|
|
|
|
;; This has been fixed in Emacs 26.1. See Bug#29423.
|
|
|
|
|
(when (tramp--test-emacs26-p)
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-directory (file-name-as-directory tmp-name1) nil)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(should
|
|
|
|
|
(looking-at-p
|
|
|
|
|
(regexp-quote (file-name-as-directory tmp-name1))))))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-directory tmp-name1 "-al")
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(should
|
|
|
|
|
(looking-at-p (format "^.+ %s$" (regexp-quote tmp-name1)))))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-directory (file-name-as-directory tmp-name1) "-al")
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(should
|
|
|
|
|
(looking-at-p (format "^.+ %s/$" (regexp-quote tmp-name1)))))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-directory
|
|
|
|
|
(file-name-as-directory tmp-name1) "-al" nil 'full-directory-p)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(should
|
|
|
|
|
(looking-at-p
|
|
|
|
|
(concat
|
|
|
|
|
;; There might be a summary line.
|
2019-07-20 19:16:38 +02:00
|
|
|
|
"\\(total.+[[:digit:]]+ ?[kKMGTPEZY]?i?B?\n\\)?"
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; We don't know in which order ".", ".." and "foo" appear.
|
2017-11-29 09:37:42 +01:00
|
|
|
|
(format
|
|
|
|
|
"\\(.+ %s\\( ->.+\\)?\n\\)\\{%d\\}"
|
|
|
|
|
(regexp-opt (directory-files tmp-name1))
|
2019-02-19 14:00:17 +01:00
|
|
|
|
(length (directory-files tmp-name1)))))))
|
|
|
|
|
|
|
|
|
|
;; Check error case. We do not check for the error type,
|
|
|
|
|
;; because ls-lisp returns `file-error', and native Tramp
|
|
|
|
|
;; returns `file-missing'.
|
|
|
|
|
(delete-directory tmp-name1 'recursive)
|
|
|
|
|
(with-temp-buffer
|
2019-05-18 16:04:58 +02:00
|
|
|
|
(should-error
|
|
|
|
|
(insert-directory tmp-name1 nil)
|
|
|
|
|
:type tramp-file-missing)))
|
2015-06-28 20:51:54 +02:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-directory tmp-name1 'recursive))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2017-07-30 13:08:36 +02:00
|
|
|
|
(ert-deftest tramp-test17-dired-with-wildcards ()
|
|
|
|
|
"Check `dired' with wildcards."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2017-07-31 14:32:24 +02:00
|
|
|
|
(skip-unless (tramp--test-sh-p))
|
2017-10-19 13:37:23 +02:00
|
|
|
|
(skip-unless (not (tramp--test-rsync-p)))
|
2017-07-31 14:32:24 +02:00
|
|
|
|
;; Since Emacs 26.1.
|
2017-07-30 13:08:36 +02:00
|
|
|
|
(skip-unless (fboundp 'insert-directory-wildcard-in-dir-p))
|
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
2017-07-30 13:08:36 +02:00
|
|
|
|
(let* ((tmp-name1
|
|
|
|
|
(expand-file-name (tramp--test-make-temp-name nil quoted)))
|
|
|
|
|
(tmp-name2
|
|
|
|
|
(expand-file-name (tramp--test-make-temp-name nil quoted)))
|
|
|
|
|
(tmp-name3 (expand-file-name "foo" tmp-name1))
|
|
|
|
|
(tmp-name4 (expand-file-name "bar" tmp-name2))
|
|
|
|
|
(tramp-test-temporary-file-directory
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-quote #'identity)
|
2017-07-30 13:08:36 +02:00
|
|
|
|
tramp-test-temporary-file-directory))
|
|
|
|
|
buffer)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(make-directory tmp-name1)
|
|
|
|
|
(write-region "foo" nil tmp-name3)
|
|
|
|
|
(should (file-directory-p tmp-name1))
|
|
|
|
|
(should (file-exists-p tmp-name3))
|
|
|
|
|
(make-directory tmp-name2)
|
|
|
|
|
(write-region "foo" nil tmp-name4)
|
|
|
|
|
(should (file-directory-p tmp-name2))
|
|
|
|
|
(should (file-exists-p tmp-name4))
|
|
|
|
|
|
|
|
|
|
;; Check for expanded directory names.
|
|
|
|
|
(with-current-buffer
|
|
|
|
|
(setq buffer
|
|
|
|
|
(dired-noselect
|
|
|
|
|
(expand-file-name
|
|
|
|
|
"tramp-test*" tramp-test-temporary-file-directory)))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(should
|
|
|
|
|
(re-search-forward
|
|
|
|
|
(regexp-quote
|
|
|
|
|
(file-relative-name
|
|
|
|
|
tmp-name1 tramp-test-temporary-file-directory))))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(should
|
|
|
|
|
(re-search-forward
|
|
|
|
|
(regexp-quote
|
|
|
|
|
(file-relative-name
|
|
|
|
|
tmp-name2 tramp-test-temporary-file-directory)))))
|
|
|
|
|
(kill-buffer buffer)
|
|
|
|
|
|
|
|
|
|
;; Check for expanded directory and file names.
|
|
|
|
|
(with-current-buffer
|
|
|
|
|
(setq buffer
|
|
|
|
|
(dired-noselect
|
|
|
|
|
(expand-file-name
|
|
|
|
|
"tramp-test*/*" tramp-test-temporary-file-directory)))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(should
|
|
|
|
|
(re-search-forward
|
|
|
|
|
(regexp-quote
|
|
|
|
|
(file-relative-name
|
|
|
|
|
tmp-name3 tramp-test-temporary-file-directory))))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(should
|
|
|
|
|
(re-search-forward
|
|
|
|
|
(regexp-quote
|
|
|
|
|
(file-relative-name
|
|
|
|
|
tmp-name4
|
|
|
|
|
tramp-test-temporary-file-directory)))))
|
|
|
|
|
(kill-buffer buffer)
|
|
|
|
|
|
|
|
|
|
;; Check for special characters.
|
|
|
|
|
(setq tmp-name3 (expand-file-name "*?" tmp-name1))
|
|
|
|
|
(setq tmp-name4 (expand-file-name "[a-z0-9]" tmp-name2))
|
|
|
|
|
(write-region "foo" nil tmp-name3)
|
|
|
|
|
(should (file-exists-p tmp-name3))
|
|
|
|
|
(write-region "foo" nil tmp-name4)
|
|
|
|
|
(should (file-exists-p tmp-name4))
|
|
|
|
|
|
|
|
|
|
(with-current-buffer
|
|
|
|
|
(setq buffer
|
|
|
|
|
(dired-noselect
|
|
|
|
|
(expand-file-name
|
|
|
|
|
"tramp-test*/*" tramp-test-temporary-file-directory)))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(should
|
|
|
|
|
(re-search-forward
|
|
|
|
|
(regexp-quote
|
|
|
|
|
(file-relative-name
|
|
|
|
|
tmp-name3 tramp-test-temporary-file-directory))))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(should
|
|
|
|
|
(re-search-forward
|
|
|
|
|
(regexp-quote
|
|
|
|
|
(file-relative-name
|
|
|
|
|
tmp-name4
|
|
|
|
|
tramp-test-temporary-file-directory)))))
|
|
|
|
|
(kill-buffer buffer))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (kill-buffer buffer))
|
|
|
|
|
(ignore-errors (delete-directory tmp-name1 'recursive))
|
|
|
|
|
(ignore-errors (delete-directory tmp-name2 'recursive))))))
|
|
|
|
|
|
2017-08-28 18:08:16 +02:00
|
|
|
|
;; Method "smb" supports `make-symbolic-link' only if the remote host
|
2019-06-24 17:36:00 +02:00
|
|
|
|
;; has CIFS capabilities. tramp-adb.el, tramp-gvfs.el and
|
|
|
|
|
;; tramp-rclone.el do not support symbolic links at all.
|
2017-08-28 18:08:16 +02:00
|
|
|
|
(defmacro tramp--test-ignore-make-symbolic-link-error (&rest body)
|
|
|
|
|
"Run BODY, ignoring \"make-symbolic-link not supported\" file error."
|
2019-06-10 17:53:15 +02:00
|
|
|
|
(declare (indent defun) (debug (body)))
|
2017-08-28 18:08:16 +02:00
|
|
|
|
`(condition-case err
|
|
|
|
|
(progn ,@body)
|
2019-06-24 17:36:00 +02:00
|
|
|
|
(file-error
|
|
|
|
|
(unless (string-equal (error-message-string err)
|
|
|
|
|
"make-symbolic-link not supported")
|
2017-08-28 18:08:16 +02:00
|
|
|
|
(signal (car err) (cdr err))))))
|
|
|
|
|
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(ert-deftest tramp-test18-file-attributes ()
|
|
|
|
|
"Check `file-attributes'.
|
2019-02-19 14:00:17 +01:00
|
|
|
|
This tests also `access-file', `file-readable-p',
|
|
|
|
|
`file-regular-p' and `file-ownership-preserved-p'."
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; We must use `file-truename' for the temporary directory,
|
|
|
|
|
;; because it could be located on a symlinked directory. This
|
|
|
|
|
;; would let the test fail.
|
|
|
|
|
(let* ((tramp-test-temporary-file-directory
|
|
|
|
|
(file-truename tramp-test-temporary-file-directory))
|
|
|
|
|
(tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name2 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
;; File name with "//".
|
|
|
|
|
(tmp-name3
|
|
|
|
|
(format
|
|
|
|
|
"%s%s"
|
|
|
|
|
(file-remote-p tmp-name1)
|
|
|
|
|
(replace-regexp-in-string
|
|
|
|
|
"/" "//" (file-remote-p tmp-name1 'localname))))
|
|
|
|
|
attr)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
2019-02-19 14:00:17 +01:00
|
|
|
|
(should-error
|
|
|
|
|
(access-file tmp-name1 "error")
|
|
|
|
|
:type tramp-file-missing)
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; `file-ownership-preserved-p' should return t for
|
|
|
|
|
;; non-existing files. It is implemented only in tramp-sh.el.
|
|
|
|
|
(when (tramp--test-sh-p)
|
|
|
|
|
(should (file-ownership-preserved-p tmp-name1 'group)))
|
|
|
|
|
(write-region "foo" nil tmp-name1)
|
|
|
|
|
(should (file-exists-p tmp-name1))
|
|
|
|
|
(should (file-readable-p tmp-name1))
|
|
|
|
|
(should (file-regular-p tmp-name1))
|
2019-02-19 14:00:17 +01:00
|
|
|
|
(should-not (access-file tmp-name1 "error"))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(when (tramp--test-sh-p)
|
|
|
|
|
(should (file-ownership-preserved-p tmp-name1 'group)))
|
|
|
|
|
|
|
|
|
|
;; We do not test inodes and device numbers.
|
|
|
|
|
(setq attr (file-attributes tmp-name1))
|
|
|
|
|
(should (consp attr))
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(should (null (tramp-compat-file-attribute-type attr)))
|
|
|
|
|
(should (numberp (tramp-compat-file-attribute-link-number attr)))
|
|
|
|
|
(should (numberp (tramp-compat-file-attribute-user-id attr)))
|
|
|
|
|
(should (numberp (tramp-compat-file-attribute-group-id attr)))
|
|
|
|
|
(should
|
|
|
|
|
(stringp
|
|
|
|
|
(current-time-string
|
|
|
|
|
(tramp-compat-file-attribute-access-time attr))))
|
|
|
|
|
(should
|
|
|
|
|
(stringp
|
|
|
|
|
(current-time-string
|
|
|
|
|
(tramp-compat-file-attribute-modification-time attr))))
|
|
|
|
|
(should
|
|
|
|
|
(stringp
|
|
|
|
|
(current-time-string
|
|
|
|
|
(tramp-compat-file-attribute-status-change-time attr))))
|
|
|
|
|
(should (numberp (tramp-compat-file-attribute-size attr)))
|
|
|
|
|
(should (stringp (tramp-compat-file-attribute-modes attr)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
(setq attr (file-attributes tmp-name1 'string))
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(should (stringp (tramp-compat-file-attribute-user-id attr)))
|
|
|
|
|
(should (stringp (tramp-compat-file-attribute-group-id attr)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
2017-08-28 18:08:16 +02:00
|
|
|
|
(tramp--test-ignore-make-symbolic-link-error
|
2019-02-19 14:00:17 +01:00
|
|
|
|
(should-error
|
|
|
|
|
(access-file tmp-name2 "error")
|
|
|
|
|
:type tramp-file-missing)
|
2017-08-28 18:08:16 +02:00
|
|
|
|
(when (tramp--test-sh-p)
|
|
|
|
|
(should (file-ownership-preserved-p tmp-name2 'group)))
|
|
|
|
|
(make-symbolic-link tmp-name1 tmp-name2)
|
|
|
|
|
(should (file-exists-p tmp-name2))
|
|
|
|
|
(should (file-symlink-p tmp-name2))
|
2019-02-19 14:00:17 +01:00
|
|
|
|
(should-not (access-file tmp-name2 "error"))
|
2017-08-28 18:08:16 +02:00
|
|
|
|
(when (tramp--test-sh-p)
|
|
|
|
|
(should (file-ownership-preserved-p tmp-name2 'group)))
|
|
|
|
|
(setq attr (file-attributes tmp-name2))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-quote #'identity)
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(tramp-compat-file-attribute-type attr))
|
2017-08-28 18:08:16 +02:00
|
|
|
|
(file-remote-p (file-truename tmp-name1) 'localname)))
|
|
|
|
|
(delete-file tmp-name2))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
;; Check, that "//" in symlinks are handled properly.
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(let ((default-directory tramp-test-temporary-file-directory))
|
|
|
|
|
(shell-command
|
|
|
|
|
(format
|
|
|
|
|
"ln -s %s %s"
|
|
|
|
|
(tramp-file-name-localname
|
|
|
|
|
(tramp-dissect-file-name tmp-name3))
|
|
|
|
|
(tramp-file-name-localname
|
|
|
|
|
(tramp-dissect-file-name tmp-name2)))
|
|
|
|
|
t)))
|
|
|
|
|
(when (file-symlink-p tmp-name2)
|
|
|
|
|
(setq attr (file-attributes tmp-name2))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(tramp-compat-file-attribute-type attr)
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(tramp-file-name-localname
|
|
|
|
|
(tramp-dissect-file-name tmp-name3))))
|
|
|
|
|
(delete-file tmp-name2))
|
|
|
|
|
|
|
|
|
|
(when (tramp--test-sh-p)
|
|
|
|
|
(should (file-ownership-preserved-p tmp-name1 'group)))
|
|
|
|
|
(delete-file tmp-name1)
|
|
|
|
|
(make-directory tmp-name1)
|
|
|
|
|
(should (file-exists-p tmp-name1))
|
|
|
|
|
(should (file-readable-p tmp-name1))
|
|
|
|
|
(should-not (file-regular-p tmp-name1))
|
2019-02-19 14:00:17 +01:00
|
|
|
|
(should-not (access-file tmp-name1 ""))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(when (tramp--test-sh-p)
|
|
|
|
|
(should (file-ownership-preserved-p tmp-name1 'group)))
|
|
|
|
|
(setq attr (file-attributes tmp-name1))
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(should (eq (tramp-compat-file-attribute-type attr) t)))
|
2015-08-24 14:26:57 +02:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-directory tmp-name1))
|
|
|
|
|
(ignore-errors (delete-file tmp-name1))
|
|
|
|
|
(ignore-errors (delete-file tmp-name2))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(defvar tramp--test-start-time nil
|
|
|
|
|
"Keep the start time of the current test, a float number.")
|
|
|
|
|
|
2019-01-22 15:22:52 +01:00
|
|
|
|
(defsubst tramp--test-file-attributes-equal-p (attr1 attr2)
|
|
|
|
|
"Check, whether file attributes ATTR1 and ATTR2 are equal.
|
2019-08-07 16:36:00 +02:00
|
|
|
|
They might differ only in time attributes or directory size."
|
|
|
|
|
(let ((attr1 (copy-sequence attr1))
|
|
|
|
|
(attr2 (copy-sequence attr2))
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(start-time (- tramp--test-start-time 10)))
|
2019-08-26 16:14:16 +02:00
|
|
|
|
;; Link number. For directories, it includes the number of
|
|
|
|
|
;; subdirectories. Set it to 1.
|
|
|
|
|
(when (eq (tramp-compat-file-attribute-type attr1) t)
|
|
|
|
|
(setcar (nthcdr 1 attr1) 1))
|
|
|
|
|
(when (eq (tramp-compat-file-attribute-type attr2) t)
|
|
|
|
|
(setcar (nthcdr 1 attr2) 1))
|
2019-08-07 16:36:00 +02:00
|
|
|
|
;; Access time.
|
|
|
|
|
(setcar (nthcdr 4 attr1) tramp-time-dont-know)
|
|
|
|
|
(setcar (nthcdr 4 attr2) tramp-time-dont-know)
|
|
|
|
|
;; Modification time. If any of the time values is "don't know",
|
|
|
|
|
;; we cannot compare, and we normalize the time stamps. If the
|
|
|
|
|
;; time value is newer than the test start time, normalize it,
|
|
|
|
|
;; because due to caching the time stamps could differ slightly (a
|
2019-08-11 12:06:57 +02:00
|
|
|
|
;; few seconds). We use a test start time minus 10 seconds, in
|
|
|
|
|
;; order to compensate a possible timestamp resolution higher than
|
|
|
|
|
;; a second on the remote machine.
|
|
|
|
|
(when (or (tramp-compat-time-equal-p
|
|
|
|
|
(tramp-compat-file-attribute-modification-time attr1)
|
|
|
|
|
tramp-time-dont-know)
|
|
|
|
|
(tramp-compat-time-equal-p
|
|
|
|
|
(tramp-compat-file-attribute-modification-time attr2)
|
|
|
|
|
tramp-time-dont-know))
|
2019-08-07 16:36:00 +02:00
|
|
|
|
(setcar (nthcdr 5 attr1) tramp-time-dont-know)
|
|
|
|
|
(setcar (nthcdr 5 attr2) tramp-time-dont-know))
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(when (< start-time
|
|
|
|
|
(float-time (tramp-compat-file-attribute-modification-time attr1)))
|
2019-08-07 16:36:00 +02:00
|
|
|
|
(setcar (nthcdr 5 attr1) tramp-time-dont-know))
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(when (< start-time
|
|
|
|
|
(float-time (tramp-compat-file-attribute-modification-time attr2)))
|
2019-08-07 16:36:00 +02:00
|
|
|
|
(setcar (nthcdr 5 attr2) tramp-time-dont-know))
|
|
|
|
|
;; Status change time. Dito.
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(when (or (tramp-compat-time-equal-p
|
|
|
|
|
(tramp-compat-file-attribute-status-change-time attr1)
|
|
|
|
|
tramp-time-dont-know)
|
|
|
|
|
(tramp-compat-time-equal-p
|
|
|
|
|
(tramp-compat-file-attribute-status-change-time attr2)
|
|
|
|
|
tramp-time-dont-know))
|
2019-08-07 16:36:00 +02:00
|
|
|
|
(setcar (nthcdr 6 attr1) tramp-time-dont-know)
|
|
|
|
|
(setcar (nthcdr 6 attr2) tramp-time-dont-know))
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(when
|
|
|
|
|
(< start-time
|
|
|
|
|
(float-time
|
|
|
|
|
(tramp-compat-file-attribute-status-change-time attr1)))
|
2019-08-07 16:36:00 +02:00
|
|
|
|
(setcar (nthcdr 6 attr1) tramp-time-dont-know))
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(when
|
|
|
|
|
(< start-time
|
|
|
|
|
(float-time (tramp-compat-file-attribute-status-change-time attr2)))
|
2019-08-07 16:36:00 +02:00
|
|
|
|
(setcar (nthcdr 6 attr2) tramp-time-dont-know))
|
|
|
|
|
;; Size. Set it to 0 for directories, because it might have
|
|
|
|
|
;; changed. For example the upper directory "../".
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(when (eq (tramp-compat-file-attribute-type attr1) t)
|
|
|
|
|
(setcar (nthcdr 7 attr1) 0))
|
|
|
|
|
(when (eq (tramp-compat-file-attribute-type attr2) t)
|
|
|
|
|
(setcar (nthcdr 7 attr2) 0))
|
2019-08-07 16:36:00 +02:00
|
|
|
|
;; The check.
|
2019-08-08 15:42:45 +02:00
|
|
|
|
(unless (equal attr1 attr2) (tramp--test-message "%S\n%S" attr1 attr2))
|
2019-08-07 16:36:00 +02:00
|
|
|
|
(equal attr1 attr2)))
|
2019-01-22 15:22:52 +01:00
|
|
|
|
|
2019-04-17 21:27:15 +02:00
|
|
|
|
;; This isn't 100% correct, but better than no explainer at all.
|
|
|
|
|
(put #'tramp--test-file-attributes-equal-p 'ert-explainer #'ert--explain-equal)
|
|
|
|
|
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(ert-deftest tramp-test19-directory-files-and-attributes ()
|
|
|
|
|
"Check `directory-files-and-attributes'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; `directory-files-and-attributes' contains also values for
|
|
|
|
|
;; "../". Ensure that this doesn't change during tests, for
|
|
|
|
|
;; example due to handling temporary files.
|
|
|
|
|
(let* ((tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name2 (expand-file-name "bla" tmp-name1))
|
|
|
|
|
attr)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
2019-11-04 17:34:31 +01:00
|
|
|
|
(should-error
|
|
|
|
|
(directory-files-and-attributes tmp-name1)
|
|
|
|
|
:type tramp-file-missing)
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(make-directory tmp-name1)
|
|
|
|
|
(should (file-directory-p tmp-name1))
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(setq tramp--test-start-time
|
|
|
|
|
(float-time
|
|
|
|
|
(tramp-compat-file-attribute-modification-time
|
|
|
|
|
(file-attributes tmp-name1))))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(make-directory tmp-name2)
|
|
|
|
|
(should (file-directory-p tmp-name2))
|
|
|
|
|
(write-region "foo" nil (expand-file-name "foo" tmp-name2))
|
|
|
|
|
(write-region "bar" nil (expand-file-name "bar" tmp-name2))
|
|
|
|
|
(write-region "boz" nil (expand-file-name "boz" tmp-name2))
|
2019-08-06 21:47:57 +02:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(setq attr (directory-files-and-attributes tmp-name2))
|
|
|
|
|
(should (consp attr))
|
|
|
|
|
(dolist (elt attr)
|
2019-08-06 21:47:57 +02:00
|
|
|
|
(should
|
|
|
|
|
(tramp--test-file-attributes-equal-p
|
|
|
|
|
(file-attributes (expand-file-name (car elt) tmp-name2))
|
|
|
|
|
(cdr elt))))
|
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(setq attr (directory-files-and-attributes tmp-name2 'full))
|
2019-08-06 21:47:57 +02:00
|
|
|
|
(should (consp attr))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(dolist (elt attr)
|
2019-08-06 21:47:57 +02:00
|
|
|
|
(should
|
|
|
|
|
(tramp--test-file-attributes-equal-p
|
|
|
|
|
(file-attributes (car elt)) (cdr elt))))
|
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(setq attr (directory-files-and-attributes tmp-name2 nil "^b"))
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(should (equal (mapcar #'car attr) '("bar" "boz"))))
|
2015-06-28 20:51:54 +02:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-directory tmp-name1 'recursive))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test20-file-modes ()
|
|
|
|
|
"Check `file-modes'.
|
|
|
|
|
This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2019-08-04 12:47:43 +02:00
|
|
|
|
(skip-unless
|
|
|
|
|
(or (tramp--test-sh-p) (tramp--test-sudoedit-p)
|
|
|
|
|
;; Not all tramp-gvfs.el methods support changing the file mode.
|
|
|
|
|
(and
|
|
|
|
|
(tramp--test-gvfs-p)
|
|
|
|
|
(string-match-p
|
|
|
|
|
"ftp" (file-remote-p tramp-test-temporary-file-directory 'method)))))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(let ((tmp-name (tramp--test-make-temp-name nil quoted)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(write-region "foo" nil tmp-name)
|
|
|
|
|
(should (file-exists-p tmp-name))
|
|
|
|
|
(set-file-modes tmp-name #o777)
|
|
|
|
|
(should (= (file-modes tmp-name) #o777))
|
|
|
|
|
(should (file-executable-p tmp-name))
|
|
|
|
|
(should (file-writable-p tmp-name))
|
|
|
|
|
(set-file-modes tmp-name #o444)
|
|
|
|
|
(should (= (file-modes tmp-name) #o444))
|
|
|
|
|
(should-not (file-executable-p tmp-name))
|
|
|
|
|
;; A file is always writable for user "root".
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(unless (zerop (tramp-compat-file-attribute-user-id
|
|
|
|
|
(file-attributes tmp-name)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(should-not (file-writable-p tmp-name))))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-file tmp-name))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2018-05-02 12:31:51 +02:00
|
|
|
|
;; Method "smb" could run into "NT_STATUS_REVISION_MISMATCH" error.
|
|
|
|
|
(defmacro tramp--test-ignore-add-name-to-file-error (&rest body)
|
|
|
|
|
"Run BODY, ignoring \"error with add-name-to-file\" file error."
|
2019-06-10 17:53:15 +02:00
|
|
|
|
(declare (indent defun) (debug (body)))
|
2018-05-02 12:31:51 +02:00
|
|
|
|
`(condition-case err
|
|
|
|
|
(progn ,@body)
|
2019-06-30 11:23:06 +02:00
|
|
|
|
(file-error
|
|
|
|
|
(unless (string-match "^error with add-name-to-file"
|
|
|
|
|
(error-message-string err))
|
2018-05-02 12:31:51 +02:00
|
|
|
|
(signal (car err) (cdr err))))))
|
|
|
|
|
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(ert-deftest tramp-test21-file-links ()
|
|
|
|
|
"Check `file-symlink-p'.
|
|
|
|
|
This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2018-05-02 12:31:51 +02:00
|
|
|
|
;; The semantics have changed heavily in Emacs 26.1. We cannot test
|
2017-09-13 20:10:40 +02:00
|
|
|
|
;; older Emacsen, therefore.
|
|
|
|
|
(skip-unless (tramp--test-emacs26-p))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; We must use `file-truename' for the temporary directory,
|
|
|
|
|
;; because it could be located on a symlinked directory. This
|
|
|
|
|
;; would let the test fail.
|
|
|
|
|
(let* ((tramp-test-temporary-file-directory
|
|
|
|
|
(file-truename tramp-test-temporary-file-directory))
|
|
|
|
|
(tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name2 (tramp--test-make-temp-name nil quoted))
|
2017-09-12 11:20:49 +02:00
|
|
|
|
(tmp-name3 (tramp--test-make-temp-name 'local quoted))
|
2017-09-25 17:52:24 +02:00
|
|
|
|
(tmp-name4 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name5
|
2019-10-12 12:20:55 +02:00
|
|
|
|
(expand-file-name (file-name-nondirectory tmp-name1) tmp-name4))
|
|
|
|
|
(tmp-name6 (tramp--test-make-temp-name nil quoted)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Check `make-symbolic-link'.
|
|
|
|
|
(unwind-protect
|
2017-08-28 18:08:16 +02:00
|
|
|
|
(tramp--test-ignore-make-symbolic-link-error
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(write-region "foo" nil tmp-name1)
|
|
|
|
|
(should (file-exists-p tmp-name1))
|
2017-08-28 18:08:16 +02:00
|
|
|
|
(make-symbolic-link tmp-name1 tmp-name2)
|
2017-08-27 19:16:58 +02:00
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-unquote #'identity)
|
2017-08-27 19:16:58 +02:00
|
|
|
|
(file-remote-p tmp-name1 'localname))
|
|
|
|
|
(file-symlink-p tmp-name2)))
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(when (tramp--test-expensive-test)
|
2017-08-27 19:16:58 +02:00
|
|
|
|
(should-error
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(make-symbolic-link tmp-name1 tmp-name2)
|
2017-08-27 19:16:58 +02:00
|
|
|
|
:type 'file-already-exists))
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(when (tramp--test-expensive-test)
|
|
|
|
|
;; A number means interactive case.
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(cl-letf (((symbol-function 'yes-or-no-p) #'ignore))
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(should-error
|
|
|
|
|
(make-symbolic-link tmp-name1 tmp-name2 0)
|
|
|
|
|
:type 'file-already-exists)))
|
2017-08-27 19:16:58 +02:00
|
|
|
|
(cl-letf (((symbol-function 'yes-or-no-p) (lambda (_prompt) t)))
|
|
|
|
|
(make-symbolic-link tmp-name1 tmp-name2 0)
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-unquote #'identity)
|
2017-08-27 19:16:58 +02:00
|
|
|
|
(file-remote-p tmp-name1 'localname))
|
|
|
|
|
(file-symlink-p tmp-name2))))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(make-symbolic-link tmp-name1 tmp-name2 'ok-if-already-exists)
|
2017-08-27 19:16:58 +02:00
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-unquote #'identity)
|
2017-08-27 19:16:58 +02:00
|
|
|
|
(file-remote-p tmp-name1 'localname))
|
|
|
|
|
(file-symlink-p tmp-name2)))
|
|
|
|
|
;; If we use the local part of `tmp-name1', it shall still work.
|
|
|
|
|
(make-symbolic-link
|
|
|
|
|
(file-remote-p tmp-name1 'localname)
|
|
|
|
|
tmp-name2 'ok-if-already-exists)
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-unquote #'identity)
|
2017-08-27 19:16:58 +02:00
|
|
|
|
(file-remote-p tmp-name1 'localname))
|
|
|
|
|
(file-symlink-p tmp-name2)))
|
|
|
|
|
;; `tmp-name3' is a local file name. Therefore, the link
|
|
|
|
|
;; target remains unchanged, even if quoted.
|
2018-01-07 18:50:06 +01:00
|
|
|
|
;; `make-symbolic-link' might not be permitted on w32 systems.
|
|
|
|
|
(unless (tramp--test-windows-nt)
|
|
|
|
|
(make-symbolic-link tmp-name1 tmp-name3)
|
|
|
|
|
(should
|
|
|
|
|
(string-equal tmp-name1 (file-symlink-p tmp-name3))))
|
2017-09-12 11:20:49 +02:00
|
|
|
|
;; Check directory as newname.
|
|
|
|
|
(make-directory tmp-name4)
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(when (tramp--test-expensive-test)
|
|
|
|
|
(should-error
|
|
|
|
|
(make-symbolic-link tmp-name1 tmp-name4)
|
|
|
|
|
:type 'file-already-exists))
|
2017-09-12 11:20:49 +02:00
|
|
|
|
(make-symbolic-link tmp-name1 (file-name-as-directory tmp-name4))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-unquote #'identity)
|
2017-09-12 11:20:49 +02:00
|
|
|
|
(file-remote-p tmp-name1 'localname))
|
2017-09-25 17:52:24 +02:00
|
|
|
|
(file-symlink-p tmp-name5)))
|
2019-10-12 12:20:55 +02:00
|
|
|
|
;; Check, that files in symlinked directories still work.
|
|
|
|
|
(make-symbolic-link tmp-name4 tmp-name6)
|
|
|
|
|
(write-region "foo" nil (expand-file-name "foo" tmp-name6))
|
|
|
|
|
(delete-file (expand-file-name "foo" tmp-name6))
|
|
|
|
|
(should-not (file-exists-p (expand-file-name "foo" tmp-name4)))
|
|
|
|
|
(should-not (file-exists-p (expand-file-name "foo" tmp-name6))))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
2019-10-12 12:20:55 +02:00
|
|
|
|
(ignore-errors (delete-file tmp-name1))
|
|
|
|
|
(ignore-errors (delete-file tmp-name2))
|
|
|
|
|
(ignore-errors (delete-file tmp-name3))
|
|
|
|
|
(ignore-errors (delete-file tmp-name5))
|
|
|
|
|
(ignore-errors (delete-file tmp-name6))
|
|
|
|
|
(ignore-errors (delete-directory tmp-name4 'recursive)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
;; Check `add-name-to-file'.
|
|
|
|
|
(unwind-protect
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(when (tramp--test-expensive-test)
|
2018-05-02 12:31:51 +02:00
|
|
|
|
(tramp--test-ignore-add-name-to-file-error
|
|
|
|
|
(write-region "foo" nil tmp-name1)
|
|
|
|
|
(should (file-exists-p tmp-name1))
|
2017-08-27 19:16:58 +02:00
|
|
|
|
(add-name-to-file tmp-name1 tmp-name2)
|
2018-05-02 12:31:51 +02:00
|
|
|
|
(should (file-regular-p tmp-name2))
|
|
|
|
|
(should-error
|
|
|
|
|
(add-name-to-file tmp-name1 tmp-name2)
|
|
|
|
|
:type 'file-already-exists)
|
|
|
|
|
;; A number means interactive case.
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(cl-letf (((symbol-function 'yes-or-no-p) #'ignore))
|
2018-05-02 12:31:51 +02:00
|
|
|
|
(should-error
|
|
|
|
|
(add-name-to-file tmp-name1 tmp-name2 0)
|
|
|
|
|
:type 'file-already-exists))
|
|
|
|
|
(cl-letf (((symbol-function 'yes-or-no-p) (lambda (_prompt) t)))
|
2017-08-27 19:16:58 +02:00
|
|
|
|
(add-name-to-file tmp-name1 tmp-name2 0)
|
|
|
|
|
(should (file-regular-p tmp-name2)))
|
2018-05-02 12:31:51 +02:00
|
|
|
|
(add-name-to-file tmp-name1 tmp-name2 'ok-if-already-exists)
|
|
|
|
|
(should-not (file-symlink-p tmp-name2))
|
|
|
|
|
(should (file-regular-p tmp-name2))
|
|
|
|
|
;; `tmp-name3' is a local file name.
|
|
|
|
|
(should-error
|
|
|
|
|
(add-name-to-file tmp-name1 tmp-name3)
|
|
|
|
|
:type 'file-error)
|
|
|
|
|
;; Check directory as newname.
|
|
|
|
|
(make-directory tmp-name4)
|
|
|
|
|
(should-error
|
|
|
|
|
(add-name-to-file tmp-name1 tmp-name4)
|
|
|
|
|
:type 'file-already-exists)
|
|
|
|
|
(add-name-to-file tmp-name1 (file-name-as-directory tmp-name4))
|
|
|
|
|
(should
|
|
|
|
|
(file-regular-p
|
|
|
|
|
(expand-file-name
|
|
|
|
|
(file-name-nondirectory tmp-name1) tmp-name4)))))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(delete-file tmp-name1)
|
2017-09-12 11:20:49 +02:00
|
|
|
|
(delete-file tmp-name2)
|
|
|
|
|
(delete-directory tmp-name4 'recursive)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
;; Check `file-truename'.
|
|
|
|
|
(unwind-protect
|
2017-08-28 18:08:16 +02:00
|
|
|
|
(tramp--test-ignore-make-symbolic-link-error
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(write-region "foo" nil tmp-name1)
|
|
|
|
|
(should (file-exists-p tmp-name1))
|
2017-09-04 13:10:52 +02:00
|
|
|
|
(should (string-equal tmp-name1 (file-truename tmp-name1)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(make-symbolic-link tmp-name1 tmp-name2)
|
|
|
|
|
(should (file-symlink-p tmp-name2))
|
|
|
|
|
(should-not (string-equal tmp-name2 (file-truename tmp-name2)))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal (file-truename tmp-name1) (file-truename tmp-name2)))
|
2017-08-26 15:09:55 +02:00
|
|
|
|
(should (file-equal-p tmp-name1 tmp-name2))
|
2017-11-18 14:24:03 +01:00
|
|
|
|
;; Check relative symlink file name.
|
|
|
|
|
(delete-file tmp-name2)
|
|
|
|
|
(let ((default-directory tramp-test-temporary-file-directory))
|
|
|
|
|
(make-symbolic-link (file-name-nondirectory tmp-name1) tmp-name2))
|
|
|
|
|
(should (file-symlink-p tmp-name2))
|
|
|
|
|
(should-not (string-equal tmp-name2 (file-truename tmp-name2)))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal (file-truename tmp-name1) (file-truename tmp-name2)))
|
|
|
|
|
(should (file-equal-p tmp-name1 tmp-name2))
|
2017-08-30 12:00:26 +02:00
|
|
|
|
;; Symbolic links could look like a remote file name.
|
|
|
|
|
;; They must be quoted then.
|
|
|
|
|
(delete-file tmp-name2)
|
2017-12-08 16:37:53 +01:00
|
|
|
|
(make-symbolic-link
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-unquote #'identity)
|
2017-12-08 16:37:53 +01:00
|
|
|
|
"/penguin:motd:")
|
|
|
|
|
tmp-name2)
|
2017-08-30 12:00:26 +02:00
|
|
|
|
(should (file-symlink-p tmp-name2))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-truename tmp-name2)
|
|
|
|
|
(tramp-compat-file-name-quote
|
|
|
|
|
(concat (file-remote-p tmp-name2) "/penguin:motd:"))))
|
2017-08-26 15:09:55 +02:00
|
|
|
|
;; `tmp-name3' is a local file name.
|
2018-01-07 18:50:06 +01:00
|
|
|
|
;; `make-symbolic-link' might not be permitted on w32 systems.
|
|
|
|
|
(unless (tramp--test-windows-nt)
|
|
|
|
|
(make-symbolic-link tmp-name1 tmp-name3)
|
|
|
|
|
(should (file-symlink-p tmp-name3))
|
|
|
|
|
(should-not (string-equal tmp-name3 (file-truename tmp-name3)))
|
|
|
|
|
;; `file-truename' returns a quoted file name for `tmp-name3'.
|
|
|
|
|
;; We must unquote it.
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
2018-06-03 14:30:41 +02:00
|
|
|
|
(file-truename tmp-name1)
|
2018-01-07 18:50:06 +01:00
|
|
|
|
(tramp-compat-file-name-unquote (file-truename tmp-name3))))))
|
2017-08-26 15:09:55 +02:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(ignore-errors
|
|
|
|
|
(delete-file tmp-name1)
|
2017-08-26 15:09:55 +02:00
|
|
|
|
(delete-file tmp-name2)
|
|
|
|
|
(delete-file tmp-name3)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
2017-08-30 12:00:26 +02:00
|
|
|
|
;; Symbolic links could be nested.
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(tramp--test-ignore-make-symbolic-link-error
|
|
|
|
|
(make-directory tmp-name1)
|
|
|
|
|
(should (file-directory-p tmp-name1))
|
|
|
|
|
(let* ((tramp-test-temporary-file-directory
|
|
|
|
|
(file-truename tmp-name1))
|
|
|
|
|
(tmp-name2 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name3 tmp-name2)
|
2017-09-04 13:10:52 +02:00
|
|
|
|
(number-nesting 15))
|
2017-08-30 12:00:26 +02:00
|
|
|
|
(dotimes (_ number-nesting)
|
|
|
|
|
(make-symbolic-link
|
|
|
|
|
tmp-name3
|
|
|
|
|
(setq tmp-name3 (tramp--test-make-temp-name nil quoted))))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-truename tmp-name2)
|
|
|
|
|
(file-truename tmp-name3)))
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(when (tramp--test-expensive-test)
|
|
|
|
|
(should-error
|
|
|
|
|
(with-temp-buffer (insert-file-contents tmp-name2))
|
|
|
|
|
:type tramp-file-missing))
|
|
|
|
|
(when (tramp--test-expensive-test)
|
|
|
|
|
(should-error
|
|
|
|
|
(with-temp-buffer (insert-file-contents tmp-name3))
|
|
|
|
|
:type tramp-file-missing))
|
2017-09-04 13:10:52 +02:00
|
|
|
|
;; `directory-files' does not show symlinks to
|
|
|
|
|
;; non-existing targets in the "smb" case. So we remove
|
|
|
|
|
;; the symlinks manually.
|
|
|
|
|
(while (stringp (setq tmp-name2 (file-symlink-p tmp-name3)))
|
|
|
|
|
(delete-file tmp-name3)
|
|
|
|
|
(setq tmp-name3 (concat (file-remote-p tmp-name3) tmp-name2)))))
|
2017-08-30 12:00:26 +02:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
2019-08-31 10:30:14 -07:00
|
|
|
|
(ignore-errors
|
|
|
|
|
(delete-file tmp-name3)
|
|
|
|
|
(delete-directory tmp-name1 'recursive)))
|
2017-08-30 12:00:26 +02:00
|
|
|
|
|
|
|
|
|
;; Detect cyclic symbolic links.
|
|
|
|
|
(unwind-protect
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(when (tramp--test-expensive-test)
|
|
|
|
|
(tramp--test-ignore-make-symbolic-link-error
|
|
|
|
|
(make-symbolic-link tmp-name2 tmp-name1)
|
|
|
|
|
(should (file-symlink-p tmp-name1))
|
|
|
|
|
(if (tramp-smb-file-name-p tramp-test-temporary-file-directory)
|
|
|
|
|
;; The symlink command of `smbclient' detects the
|
|
|
|
|
;; cycle already.
|
|
|
|
|
(should-error
|
|
|
|
|
(make-symbolic-link tmp-name1 tmp-name2)
|
|
|
|
|
:type 'file-error)
|
|
|
|
|
(make-symbolic-link tmp-name1 tmp-name2)
|
|
|
|
|
(should (file-symlink-p tmp-name2))
|
|
|
|
|
(should-error (file-truename tmp-name1) :type 'file-error))))
|
2017-08-30 12:00:26 +02:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(delete-file tmp-name1)
|
|
|
|
|
(delete-file tmp-name2)))
|
|
|
|
|
|
2018-03-26 14:33:24 +02:00
|
|
|
|
;; `file-truename' shall preserve trailing slash of directories.
|
|
|
|
|
(let* ((dir1
|
|
|
|
|
(directory-file-name
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-quote #'identity)
|
2018-03-26 14:33:24 +02:00
|
|
|
|
tramp-test-temporary-file-directory)))
|
|
|
|
|
(dir2 (file-name-as-directory dir1)))
|
|
|
|
|
(should (string-equal (file-truename dir1) (expand-file-name dir1)))
|
|
|
|
|
(should (string-equal (file-truename dir2) (expand-file-name dir2)))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test22-file-times ()
|
|
|
|
|
"Check `set-file-times' and `file-newer-than-file-p'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2018-12-16 15:49:07 +01:00
|
|
|
|
(skip-unless
|
2019-08-04 12:47:43 +02:00
|
|
|
|
(or (tramp--test-adb-p) (tramp--test-gvfs-p)
|
|
|
|
|
(tramp--test-sh-p) (tramp--test-sudoedit-p)))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name2 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name3 (tramp--test-make-temp-name nil quoted)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(write-region "foo" nil tmp-name1)
|
|
|
|
|
(should (file-exists-p tmp-name1))
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(should (consp (tramp-compat-file-attribute-modification-time
|
|
|
|
|
(file-attributes tmp-name1))))
|
2018-09-29 15:33:48 +02:00
|
|
|
|
;; Skip the test, if the remote handler is not able to set
|
|
|
|
|
;; the correct time.
|
2018-08-29 10:05:34 +02:00
|
|
|
|
(skip-unless (set-file-times tmp-name1 (seconds-to-time 1)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Dumb remote shells without perl(1) or stat(1) are not
|
|
|
|
|
;; able to return the date correctly. They say "don't know".
|
2018-09-29 15:33:48 +02:00
|
|
|
|
(unless (tramp-compat-time-equal-p
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(tramp-compat-file-attribute-modification-time
|
|
|
|
|
(file-attributes tmp-name1))
|
|
|
|
|
tramp-time-dont-know)
|
2018-08-29 10:05:34 +02:00
|
|
|
|
(should
|
2019-08-24 10:10:05 +02:00
|
|
|
|
(tramp-compat-time-equal-p
|
|
|
|
|
(tramp-compat-file-attribute-modification-time
|
|
|
|
|
(file-attributes tmp-name1))
|
|
|
|
|
(seconds-to-time 1)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(write-region "bla" nil tmp-name2)
|
|
|
|
|
(should (file-exists-p tmp-name2))
|
|
|
|
|
(should (file-newer-than-file-p tmp-name2 tmp-name1))
|
|
|
|
|
;; `tmp-name3' does not exist.
|
|
|
|
|
(should (file-newer-than-file-p tmp-name2 tmp-name3))
|
|
|
|
|
(should-not (file-newer-than-file-p tmp-name3 tmp-name1))))
|
2015-06-28 20:51:54 +02:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(delete-file tmp-name1)
|
|
|
|
|
(delete-file tmp-name2))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test23-visited-file-modtime ()
|
|
|
|
|
"Check `set-visited-file-modtime' and `verify-visited-file-modtime'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(let ((tmp-name (tramp--test-make-temp-name nil quoted)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(write-region "foo" nil tmp-name)
|
|
|
|
|
(should (file-exists-p tmp-name))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents tmp-name)
|
|
|
|
|
(should (verify-visited-file-modtime))
|
2018-09-24 19:13:34 -07:00
|
|
|
|
(set-visited-file-modtime (seconds-to-time 1))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(should (verify-visited-file-modtime))
|
2018-09-29 15:33:48 +02:00
|
|
|
|
(should (= 1 (float-time (visited-file-modtime))))
|
|
|
|
|
|
|
|
|
|
;; Checks with deleted file.
|
|
|
|
|
(delete-file tmp-name)
|
|
|
|
|
(dired-uncache tmp-name)
|
|
|
|
|
(should (verify-visited-file-modtime))
|
|
|
|
|
(set-visited-file-modtime (seconds-to-time 1))
|
|
|
|
|
(should (verify-visited-file-modtime))
|
2018-09-24 19:13:34 -07:00
|
|
|
|
(should (= 1 (float-time (visited-file-modtime))))))
|
2015-06-28 20:51:54 +02:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-file tmp-name))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2017-11-14 10:21:55 +01:00
|
|
|
|
;; This test is inspired by Bug#29149.
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(ert-deftest tramp-test24-file-acl ()
|
|
|
|
|
"Check that `file-acl' and `set-file-acl' work proper."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
|
|
|
|
(skip-unless (file-acl tramp-test-temporary-file-directory))
|
|
|
|
|
|
2018-02-01 15:49:18 +01:00
|
|
|
|
;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579.
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (and (tramp--test-expensive-test) (tramp--test-emacs27-p))
|
2017-12-06 20:49:30 +01:00
|
|
|
|
'(nil t) '(nil)))
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name2 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name3 (tramp--test-make-temp-name 'local quoted)))
|
|
|
|
|
;; Both files are remote.
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
;; Two files with same ACLs.
|
|
|
|
|
(write-region "foo" nil tmp-name1)
|
|
|
|
|
(should (file-exists-p tmp-name1))
|
|
|
|
|
(should (file-acl tmp-name1))
|
2017-11-14 10:38:41 +01:00
|
|
|
|
(copy-file tmp-name1 tmp-name2 nil nil nil 'preserve-permissions)
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(should (file-acl tmp-name2))
|
|
|
|
|
(should (string-equal (file-acl tmp-name1) (file-acl tmp-name2)))
|
|
|
|
|
;; Different permissions mean different ACLs.
|
2017-12-06 20:49:30 +01:00
|
|
|
|
(when (not (tramp--test-windows-nt-or-smb-p))
|
|
|
|
|
(set-file-modes tmp-name1 #o777)
|
|
|
|
|
(set-file-modes tmp-name2 #o444)
|
|
|
|
|
(should-not
|
|
|
|
|
(string-equal (file-acl tmp-name1) (file-acl tmp-name2))))
|
|
|
|
|
;; Copy ACL. Not all remote handlers support it, so we test.
|
|
|
|
|
(when (set-file-acl tmp-name2 (file-acl tmp-name1))
|
|
|
|
|
(should (string-equal (file-acl tmp-name1) (file-acl tmp-name2))))
|
2017-11-12 13:05:44 +01:00
|
|
|
|
;; An invalid ACL does not harm.
|
|
|
|
|
(should-not (set-file-acl tmp-name2 "foo")))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-file tmp-name1))
|
|
|
|
|
(ignore-errors (delete-file tmp-name2)))
|
|
|
|
|
|
|
|
|
|
;; Remote and local file.
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(when (and (file-acl temporary-file-directory)
|
|
|
|
|
(not (tramp--test-windows-nt-or-smb-p)))
|
|
|
|
|
;; Two files with same ACLs.
|
|
|
|
|
(write-region "foo" nil tmp-name1)
|
|
|
|
|
(should (file-exists-p tmp-name1))
|
|
|
|
|
(should (file-acl tmp-name1))
|
2017-11-14 10:38:41 +01:00
|
|
|
|
(copy-file tmp-name1 tmp-name3 nil nil nil 'preserve-permissions)
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(should (file-acl tmp-name3))
|
|
|
|
|
(should (string-equal (file-acl tmp-name1) (file-acl tmp-name3)))
|
|
|
|
|
;; Different permissions mean different ACLs.
|
|
|
|
|
(set-file-modes tmp-name1 #o777)
|
|
|
|
|
(set-file-modes tmp-name3 #o444)
|
|
|
|
|
(should-not
|
|
|
|
|
(string-equal (file-acl tmp-name1) (file-acl tmp-name3)))
|
2017-11-19 12:11:18 +01:00
|
|
|
|
;; Copy ACL. Since we don't know whether Emacs is built
|
|
|
|
|
;; with local ACL support, we must check it.
|
|
|
|
|
(when (set-file-acl tmp-name3 (file-acl tmp-name1))
|
|
|
|
|
(should (string-equal (file-acl tmp-name1) (file-acl tmp-name3))))
|
2017-11-12 13:05:44 +01:00
|
|
|
|
|
|
|
|
|
;; Two files with same ACLs.
|
|
|
|
|
(delete-file tmp-name1)
|
2017-11-14 10:38:41 +01:00
|
|
|
|
(copy-file tmp-name3 tmp-name1 nil nil nil 'preserve-permissions)
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(should (file-acl tmp-name1))
|
|
|
|
|
(should (string-equal (file-acl tmp-name1) (file-acl tmp-name3)))
|
|
|
|
|
;; Different permissions mean different ACLs.
|
|
|
|
|
(set-file-modes tmp-name1 #o777)
|
|
|
|
|
(set-file-modes tmp-name3 #o444)
|
|
|
|
|
(should-not
|
|
|
|
|
(string-equal (file-acl tmp-name1) (file-acl tmp-name3)))
|
|
|
|
|
;; Copy ACL.
|
|
|
|
|
(set-file-acl tmp-name1 (file-acl tmp-name3))
|
|
|
|
|
(should (string-equal (file-acl tmp-name1) (file-acl tmp-name3))))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-file tmp-name1))
|
|
|
|
|
(ignore-errors (delete-file tmp-name3))))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test25-file-selinux ()
|
|
|
|
|
"Check `file-selinux-context' and `set-file-selinux-context'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
|
|
|
|
(skip-unless
|
|
|
|
|
(not (equal (file-selinux-context tramp-test-temporary-file-directory)
|
|
|
|
|
'(nil nil nil nil))))
|
|
|
|
|
|
2018-02-01 15:49:18 +01:00
|
|
|
|
;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579.
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (and (tramp--test-expensive-test) (tramp--test-emacs27-p))
|
2017-12-06 20:49:30 +01:00
|
|
|
|
'(nil t) '(nil)))
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name2 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name3 (tramp--test-make-temp-name 'local quoted)))
|
|
|
|
|
;; Both files are remote.
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
2017-11-14 10:21:55 +01:00
|
|
|
|
;; Two files with same SELinux context.
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(write-region "foo" nil tmp-name1)
|
|
|
|
|
(should (file-exists-p tmp-name1))
|
|
|
|
|
(should (file-selinux-context tmp-name1))
|
|
|
|
|
(copy-file tmp-name1 tmp-name2)
|
|
|
|
|
(should (file-selinux-context tmp-name2))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(file-selinux-context tmp-name1)
|
|
|
|
|
(file-selinux-context tmp-name2)))
|
2017-11-14 10:21:55 +01:00
|
|
|
|
;; Check different SELinux context. We cannot support
|
|
|
|
|
;; different ranges in this test; let's assume the most
|
|
|
|
|
;; likely one.
|
|
|
|
|
(let ((context (file-selinux-context tmp-name1)))
|
|
|
|
|
(when (and (string-equal (nth 3 context) "s0")
|
|
|
|
|
(setcar (nthcdr 3 context) "s0:c0")
|
|
|
|
|
(set-file-selinux-context tmp-name1 context))
|
|
|
|
|
(should-not
|
|
|
|
|
(equal
|
|
|
|
|
(file-selinux-context tmp-name1)
|
|
|
|
|
(file-selinux-context tmp-name2)))))
|
|
|
|
|
;; Copy SELinux context.
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(should
|
|
|
|
|
(set-file-selinux-context
|
|
|
|
|
tmp-name2 (file-selinux-context tmp-name1)))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(file-selinux-context tmp-name1)
|
|
|
|
|
(file-selinux-context tmp-name2)))
|
2017-11-14 10:21:55 +01:00
|
|
|
|
;; An invalid SELinux context does not harm.
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(should-not (set-file-selinux-context tmp-name2 "foo")))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-file tmp-name1))
|
|
|
|
|
(ignore-errors (delete-file tmp-name2)))
|
|
|
|
|
|
|
|
|
|
;; Remote and local file.
|
|
|
|
|
(unwind-protect
|
2017-11-14 10:21:55 +01:00
|
|
|
|
(when (and (not
|
|
|
|
|
(or (equal (file-selinux-context temporary-file-directory)
|
|
|
|
|
'(nil nil nil nil))
|
|
|
|
|
(tramp--test-windows-nt-or-smb-p)))
|
|
|
|
|
;; Both users shall use the same SELinux context.
|
|
|
|
|
(string-equal
|
|
|
|
|
(let ((default-directory temporary-file-directory))
|
|
|
|
|
(shell-command-to-string "id -Z"))
|
|
|
|
|
(let ((default-directory
|
|
|
|
|
tramp-test-temporary-file-directory))
|
|
|
|
|
(shell-command-to-string "id -Z"))))
|
|
|
|
|
|
|
|
|
|
;; Two files with same SELinux context.
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(write-region "foo" nil tmp-name1)
|
|
|
|
|
(should (file-exists-p tmp-name1))
|
|
|
|
|
(should (file-selinux-context tmp-name1))
|
|
|
|
|
(copy-file tmp-name1 tmp-name3)
|
|
|
|
|
(should (file-selinux-context tmp-name3))
|
2017-11-14 10:21:55 +01:00
|
|
|
|
;; We cannot expect that copying over file system
|
|
|
|
|
;; boundaries keeps SELinux context. So we copy it
|
2017-11-16 00:00:31 -08:00
|
|
|
|
;; explicitly.
|
2017-11-14 10:21:55 +01:00
|
|
|
|
(should
|
|
|
|
|
(set-file-selinux-context
|
|
|
|
|
tmp-name3 (file-selinux-context tmp-name1)))
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(file-selinux-context tmp-name1)
|
|
|
|
|
(file-selinux-context tmp-name3)))
|
2017-11-14 10:21:55 +01:00
|
|
|
|
;; Check different SELinux context. We cannot support
|
|
|
|
|
;; different ranges in this test; let's assume the most
|
|
|
|
|
;; likely one.
|
|
|
|
|
(let ((context (file-selinux-context tmp-name1)))
|
|
|
|
|
(when (and (string-equal (nth 3 context) "s0")
|
|
|
|
|
(setcar (nthcdr 3 context) "s0:c0")
|
|
|
|
|
(set-file-selinux-context tmp-name1 context))
|
|
|
|
|
(should-not
|
|
|
|
|
(equal
|
|
|
|
|
(file-selinux-context tmp-name1)
|
|
|
|
|
(file-selinux-context tmp-name3)))))
|
|
|
|
|
;; Copy SELinux context.
|
|
|
|
|
(should
|
|
|
|
|
(set-file-selinux-context
|
|
|
|
|
tmp-name3 (file-selinux-context tmp-name1)))
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(file-selinux-context tmp-name1)
|
|
|
|
|
(file-selinux-context tmp-name3)))
|
|
|
|
|
|
2017-11-14 10:21:55 +01:00
|
|
|
|
;; Two files with same SELinux context.
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(delete-file tmp-name1)
|
|
|
|
|
(copy-file tmp-name3 tmp-name1)
|
|
|
|
|
(should (file-selinux-context tmp-name1))
|
2017-11-14 10:21:55 +01:00
|
|
|
|
;; We cannot expect that copying over file system
|
|
|
|
|
;; boundaries keeps SELinux context. So we copy it
|
2017-11-16 00:00:31 -08:00
|
|
|
|
;; explicitly.
|
2017-11-14 10:21:55 +01:00
|
|
|
|
(should
|
|
|
|
|
(set-file-selinux-context
|
|
|
|
|
tmp-name1 (file-selinux-context tmp-name3)))
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(file-selinux-context tmp-name1)
|
|
|
|
|
(file-selinux-context tmp-name3)))
|
2017-11-14 10:21:55 +01:00
|
|
|
|
;; Check different SELinux context. We cannot support
|
|
|
|
|
;; different ranges in this test; let's assume the most
|
|
|
|
|
;; likely one.
|
|
|
|
|
(let ((context (file-selinux-context tmp-name3)))
|
|
|
|
|
(when (and (string-equal (nth 3 context) "s0")
|
|
|
|
|
(setcar (nthcdr 3 context) "s0:c0")
|
|
|
|
|
(set-file-selinux-context tmp-name3 context))
|
|
|
|
|
(should-not
|
|
|
|
|
(equal
|
|
|
|
|
(file-selinux-context tmp-name1)
|
|
|
|
|
(file-selinux-context tmp-name3)))))
|
|
|
|
|
;; Copy SELinux context.
|
|
|
|
|
(should
|
|
|
|
|
(set-file-selinux-context
|
|
|
|
|
tmp-name1 (file-selinux-context tmp-name3)))
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(file-selinux-context tmp-name1)
|
|
|
|
|
(file-selinux-context tmp-name3))))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-file tmp-name1))
|
|
|
|
|
(ignore-errors (delete-file tmp-name3))))))
|
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test26-file-name-completion ()
|
2013-11-05 15:46:57 +01:00
|
|
|
|
"Check `file-name-completion' and `file-name-all-completions'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2017-05-02 16:30:55 +02:00
|
|
|
|
;; Method and host name in completion mode. This kind of completion
|
|
|
|
|
;; does not work on MS Windows.
|
|
|
|
|
(when (not (memq system-type '(cygwin windows-nt)))
|
|
|
|
|
(let ((method (file-remote-p tramp-test-temporary-file-directory 'method))
|
|
|
|
|
(host (file-remote-p tramp-test-temporary-file-directory 'host))
|
2018-10-20 13:38:31 +02:00
|
|
|
|
(vec (tramp-dissect-file-name tramp-test-temporary-file-directory))
|
2017-05-02 16:30:55 +02:00
|
|
|
|
(orig-syntax tramp-syntax))
|
2017-06-11 23:16:13 +02:00
|
|
|
|
(when (and (stringp host) (string-match tramp-host-with-port-regexp host))
|
|
|
|
|
(setq host (match-string 1 host)))
|
2017-05-02 16:30:55 +02:00
|
|
|
|
|
|
|
|
|
(unwind-protect
|
2017-06-05 12:59:26 +02:00
|
|
|
|
(dolist
|
|
|
|
|
(syntax
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(if (tramp--test-expensive-test)
|
2017-06-05 12:59:26 +02:00
|
|
|
|
(tramp-syntax-values) `(,orig-syntax)))
|
2017-05-02 16:30:55 +02:00
|
|
|
|
(tramp-change-syntax syntax)
|
2018-10-20 13:38:31 +02:00
|
|
|
|
;; This has cleaned up all connection data, which are used
|
|
|
|
|
;; for completion. We must refill the cache.
|
|
|
|
|
(tramp-set-connection-property vec "property" nil)
|
|
|
|
|
|
2017-05-02 16:30:55 +02:00
|
|
|
|
(let ;; This is needed for the `simplified' syntax.
|
|
|
|
|
((method-marker
|
2017-09-11 17:12:32 +02:00
|
|
|
|
(if (zerop (length tramp-method-regexp))
|
2017-05-02 16:30:55 +02:00
|
|
|
|
"" tramp-default-method-marker))
|
|
|
|
|
;; This is needed for the `separate' syntax.
|
2017-09-11 17:12:32 +02:00
|
|
|
|
(prefix-format (substring tramp-prefix-format 1)))
|
2017-05-02 16:30:55 +02:00
|
|
|
|
;; Complete method name.
|
|
|
|
|
(unless (or (zerop (length method))
|
2017-09-11 17:12:32 +02:00
|
|
|
|
(zerop (length tramp-method-regexp)))
|
2017-05-02 16:30:55 +02:00
|
|
|
|
(should
|
|
|
|
|
(member
|
2017-09-11 17:12:32 +02:00
|
|
|
|
(concat prefix-format method tramp-postfix-method-format)
|
2017-05-02 16:30:55 +02:00
|
|
|
|
(file-name-all-completions
|
|
|
|
|
(concat prefix-format (substring method 0 1)) "/"))))
|
2017-06-05 12:59:26 +02:00
|
|
|
|
;; Complete host name for default method. With gvfs
|
|
|
|
|
;; based methods, host name will be determined as
|
|
|
|
|
;; host.local, so we omit the test.
|
|
|
|
|
(let ((tramp-default-method (or method tramp-default-method)))
|
|
|
|
|
(unless (or (zerop (length host))
|
|
|
|
|
(tramp--test-gvfs-p tramp-default-method))
|
2017-05-02 16:30:55 +02:00
|
|
|
|
(should
|
|
|
|
|
(member
|
|
|
|
|
(concat
|
2017-09-11 17:12:32 +02:00
|
|
|
|
prefix-format method-marker tramp-postfix-method-format
|
|
|
|
|
host tramp-postfix-host-format)
|
2017-05-02 16:30:55 +02:00
|
|
|
|
(file-name-all-completions
|
|
|
|
|
(concat
|
2017-09-11 17:12:32 +02:00
|
|
|
|
prefix-format method-marker tramp-postfix-method-format
|
2017-05-02 16:30:55 +02:00
|
|
|
|
(substring host 0 1))
|
|
|
|
|
"/")))))
|
|
|
|
|
;; Complete host name.
|
|
|
|
|
(unless (or (zerop (length method))
|
2017-09-11 17:12:32 +02:00
|
|
|
|
(zerop (length tramp-method-regexp))
|
2017-06-05 12:59:26 +02:00
|
|
|
|
(zerop (length host))
|
|
|
|
|
(tramp--test-gvfs-p method))
|
2017-05-02 16:30:55 +02:00
|
|
|
|
(should
|
|
|
|
|
(member
|
|
|
|
|
(concat
|
2017-09-11 17:12:32 +02:00
|
|
|
|
prefix-format method tramp-postfix-method-format
|
|
|
|
|
host tramp-postfix-host-format)
|
2017-05-02 16:30:55 +02:00
|
|
|
|
(file-name-all-completions
|
2017-09-11 17:12:32 +02:00
|
|
|
|
(concat prefix-format method tramp-postfix-method-format)
|
2017-05-02 16:30:55 +02:00
|
|
|
|
"/"))))))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(tramp-change-syntax orig-syntax))))
|
|
|
|
|
|
2016-05-07 22:52:30 +02:00
|
|
|
|
(dolist (n-e '(nil t))
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(let ((non-essential n-e)
|
2017-05-02 16:30:55 +02:00
|
|
|
|
(tmp-name (tramp--test-make-temp-name nil quoted)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
;; Local files.
|
|
|
|
|
(make-directory tmp-name)
|
|
|
|
|
(should (file-directory-p tmp-name))
|
|
|
|
|
(write-region "foo" nil (expand-file-name "foo" tmp-name))
|
|
|
|
|
(should (file-exists-p (expand-file-name "foo" tmp-name)))
|
|
|
|
|
(write-region "bar" nil (expand-file-name "bold" tmp-name))
|
|
|
|
|
(should (file-exists-p (expand-file-name "bold" tmp-name)))
|
|
|
|
|
(make-directory (expand-file-name "boz" tmp-name))
|
|
|
|
|
(should (file-directory-p (expand-file-name "boz" tmp-name)))
|
2016-05-30 15:00:14 +02:00
|
|
|
|
(should (equal (file-name-completion "fo" tmp-name) "foo"))
|
|
|
|
|
(should (equal (file-name-completion "foo" tmp-name) t))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(should (equal (file-name-completion "b" tmp-name) "bo"))
|
|
|
|
|
(should-not (file-name-completion "a" tmp-name))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(file-name-completion "b" tmp-name #'file-directory-p) "boz/"))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(should
|
|
|
|
|
(equal (file-name-all-completions "fo" tmp-name) '("foo")))
|
2016-05-30 15:00:14 +02:00
|
|
|
|
(should
|
|
|
|
|
(equal
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(sort (file-name-all-completions "b" tmp-name) #'string-lessp)
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
'("bold" "boz/")))
|
|
|
|
|
(should-not (file-name-all-completions "a" tmp-name))
|
|
|
|
|
;; `completion-regexp-list' restricts the completion to
|
|
|
|
|
;; files which match all expressions in this list.
|
|
|
|
|
(let ((completion-regexp-list
|
|
|
|
|
`(,directory-files-no-dot-files-regexp "b")))
|
|
|
|
|
(should
|
|
|
|
|
(equal (file-name-completion "" tmp-name) "bo"))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(sort (file-name-all-completions "" tmp-name) #'string-lessp)
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
'("bold" "boz/"))))
|
|
|
|
|
;; `file-name-completion' ignores file names that end in
|
|
|
|
|
;; any string in `completion-ignored-extensions'.
|
|
|
|
|
(let ((completion-ignored-extensions '(".ext")))
|
|
|
|
|
(write-region "foo" nil (expand-file-name "foo.ext" tmp-name))
|
|
|
|
|
(should (file-exists-p (expand-file-name "foo.ext" tmp-name)))
|
|
|
|
|
(should (equal (file-name-completion "fo" tmp-name) "foo"))
|
|
|
|
|
(should (equal (file-name-completion "foo" tmp-name) t))
|
|
|
|
|
(should
|
|
|
|
|
(equal (file-name-completion "foo." tmp-name) "foo.ext"))
|
|
|
|
|
(should (equal (file-name-completion "foo.ext" tmp-name) t))
|
|
|
|
|
;; `file-name-all-completions' is not affected.
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(sort (file-name-all-completions "" tmp-name) #'string-lessp)
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
'("../" "./" "bold" "boz/" "foo" "foo.ext")))))
|
2015-06-28 20:51:54 +02:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-directory tmp-name 'recursive)))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(ert-deftest tramp-test27-load ()
|
2013-11-05 15:46:57 +01:00
|
|
|
|
"Check `load'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(let ((tmp-name (tramp--test-make-temp-name nil quoted)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(load tmp-name 'noerror 'nomessage)
|
|
|
|
|
(should-not (featurep 'tramp-test-load))
|
|
|
|
|
(write-region "(provide 'tramp-test-load)" nil tmp-name)
|
|
|
|
|
;; `load' in lread.c does not pass `must-suffix'. Why?
|
|
|
|
|
;;(should-error
|
2017-09-12 11:20:49 +02:00
|
|
|
|
;; (load tmp-name nil 'nomessage 'nosuffix 'must-suffix)
|
|
|
|
|
;; :type 'file-error)
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(load tmp-name nil 'nomessage 'nosuffix)
|
|
|
|
|
(should (featurep 'tramp-test-load)))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(and (featurep 'tramp-test-load) (unload-feature 'tramp-test-load))
|
|
|
|
|
(delete-file tmp-name))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(ert-deftest tramp-test28-process-file ()
|
2013-11-05 15:46:57 +01:00
|
|
|
|
"Check `process-file'."
|
2016-01-04 23:28:07 +01:00
|
|
|
|
:tags '(:expensive-test)
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(skip-unless (tramp--test-enabled))
|
Add `make-nearby-temp-file' and `temporary-file-directory'
* doc/lispref/files.texi (Unique File Names):
Introduce `make-nearby-temp-file' and `temporary-file-directory'.
(Magic File Names): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* etc/NEWS (provided): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* lisp/files.el (mounted-file-systems): New defcustom.
(temporary-file-directory, make-nearby-temp-file): New defuns.
(normal-backup-enable-predicate): Fix docstring.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
<make-nearby-temp-file, temporary-file-directory>: Add handler.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `make-nearby-temp-file' and `temporary-file-directory'.
(tramp-get-remote-tmpdir): Remove compatibility code.
(tramp-handle-temporary-file-directory)
(tramp-handle-make-nearby-temp-file): New defuns.
* lisp/org/ob-core.el (org-babel-local-file-name):
* lisp/progmodes/gud.el (gud-common-init):
* lisp/vc/vc-hooks.el (vc-user-login-name): Use `file-remote-p'.
* lisp/vc/vc-git.el (vc-git-checkin): Handle remote log message.
* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name):
Check `tramp--test-enabled'.
(tramp-test18-file-attributes): Add tests for
`file-ownership-preserved-p'.
(tramp-test27-start-file-process, tramp-test28-shell-command):
Reduce timeouts in `accept-process-output'.
(tramp-test--shell-command-to-string-asynchronously): Add timeout.
(tramp-test29-environment-variables): Remove additional sleep calls.
(tramp-test32-make-nearby-temp-file): New test.
(tramp--test-special-characters, tramp--test-utf8): Adapt docstring.
(tramp-test33-special-characters)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls, tramp-test34-utf8)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests)
(tramp-test36-recursive-load, tramp-test37-unload): Rename.
(tramp--test-ftp-p): Simplify check.
(tramp--test-sh-p): New defun.
(tramp-test20-file-modes, tramp-test22-file-times)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command)
(tramp-test29-environment-variables)
(tramp-test30-vc-registered)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests): Use it.
2016-08-07 13:57:23 +02:00
|
|
|
|
(skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
|
2019-06-26 10:24:59 -04:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(let* ((tmp-name (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(fnnd (file-name-nondirectory tmp-name))
|
|
|
|
|
(default-directory tramp-test-temporary-file-directory)
|
|
|
|
|
kill-buffer-query-functions)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
;; We cannot use "/bin/true" and "/bin/false"; those paths
|
|
|
|
|
;; do not exist on hydra.
|
|
|
|
|
(should (zerop (process-file "true")))
|
|
|
|
|
(should-not (zerop (process-file "false")))
|
|
|
|
|
(should-not (zerop (process-file "binary-does-not-exist")))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(write-region "foo" nil tmp-name)
|
|
|
|
|
(should (file-exists-p tmp-name))
|
|
|
|
|
(should (zerop (process-file "ls" nil t nil fnnd)))
|
|
|
|
|
;; `ls' could produce colorized output.
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while
|
|
|
|
|
(re-search-forward tramp-display-escape-sequence-regexp nil t)
|
|
|
|
|
(replace-match "" nil nil))
|
|
|
|
|
(should (string-equal (format "%s\n" fnnd) (buffer-string)))
|
|
|
|
|
(should-not (get-buffer-window (current-buffer) t))
|
|
|
|
|
|
|
|
|
|
;; Second run. The output must be appended.
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(should (zerop (process-file "ls" nil t t fnnd)))
|
|
|
|
|
;; `ls' could produce colorized output.
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while
|
|
|
|
|
(re-search-forward tramp-display-escape-sequence-regexp nil t)
|
|
|
|
|
(replace-match "" nil nil))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal (format "%s\n%s\n" fnnd fnnd) (buffer-string)))
|
|
|
|
|
;; A non-nil DISPLAY must not raise the buffer.
|
|
|
|
|
(should-not (get-buffer-window (current-buffer) t))))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-file tmp-name))))))
|
|
|
|
|
|
2019-02-03 11:07:36 +01:00
|
|
|
|
;; Must be a command, because used as `sigusr' handler.
|
|
|
|
|
(defun tramp--test-timeout-handler (&rest _ignore)
|
|
|
|
|
"Timeout handler, reporting a failed test."
|
|
|
|
|
(interactive)
|
2019-04-29 17:24:53 +02:00
|
|
|
|
(let ((proc (get-buffer-process (current-buffer))))
|
|
|
|
|
(when (processp proc)
|
|
|
|
|
(tramp--test-message
|
2019-10-27 09:36:56 +01:00
|
|
|
|
"cmd: %s\nbuf:\n%s\n---" (process-command proc) (buffer-string))))
|
2019-02-03 11:07:36 +01:00
|
|
|
|
(ert-fail (format "`%s' timed out" (ert-test-name (ert-running-test)))))
|
|
|
|
|
|
2017-11-12 13:05:44 +01:00
|
|
|
|
(ert-deftest tramp-test29-start-file-process ()
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
"Check `start-file-process'."
|
|
|
|
|
:tags '(:expensive-test)
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2019-04-03 21:36:40 +02:00
|
|
|
|
(skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(let ((default-directory tramp-test-temporary-file-directory)
|
|
|
|
|
(tmp-name (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
kill-buffer-query-functions proc)
|
2019-04-03 21:36:40 +02:00
|
|
|
|
|
|
|
|
|
;; Simple process.
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(setq proc (start-file-process "test1" (current-buffer) "cat"))
|
|
|
|
|
(should (processp proc))
|
|
|
|
|
(should (equal (process-status proc) 'run))
|
|
|
|
|
(process-send-string proc "foo")
|
|
|
|
|
(process-send-eof proc)
|
|
|
|
|
;; Read output.
|
2019-02-03 11:07:36 +01:00
|
|
|
|
(with-timeout (10 (tramp--test-timeout-handler))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(while (< (- (point-max) (point-min)) (length "foo"))
|
2019-01-29 17:26:14 +01:00
|
|
|
|
(while (accept-process-output proc 0 nil t))))
|
2019-04-03 21:36:40 +02:00
|
|
|
|
;; We cannot use `string-equal', because tramp-adb.el
|
|
|
|
|
;; echoes also the sent string.
|
|
|
|
|
(should (string-match "\\`foo" (buffer-string))))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-process proc)))
|
|
|
|
|
|
2019-04-03 21:36:40 +02:00
|
|
|
|
;; Simple process using a file.
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(write-region "foo" nil tmp-name)
|
|
|
|
|
(should (file-exists-p tmp-name))
|
|
|
|
|
(setq proc
|
|
|
|
|
(start-file-process
|
|
|
|
|
"test2" (current-buffer)
|
|
|
|
|
"cat" (file-name-nondirectory tmp-name)))
|
|
|
|
|
(should (processp proc))
|
|
|
|
|
;; Read output.
|
2019-02-03 11:07:36 +01:00
|
|
|
|
(with-timeout (10 (tramp--test-timeout-handler))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(while (< (- (point-max) (point-min)) (length "foo"))
|
2019-01-29 17:26:14 +01:00
|
|
|
|
(while (accept-process-output proc 0 nil t))))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(should (string-equal (buffer-string) "foo")))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(delete-process proc)
|
|
|
|
|
(delete-file tmp-name)))
|
|
|
|
|
|
2019-04-03 21:36:40 +02:00
|
|
|
|
;; Process filter.
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(setq proc (start-file-process "test3" (current-buffer) "cat"))
|
|
|
|
|
(should (processp proc))
|
|
|
|
|
(should (equal (process-status proc) 'run))
|
|
|
|
|
(set-process-filter
|
|
|
|
|
proc
|
|
|
|
|
(lambda (p s) (with-current-buffer (process-buffer p) (insert s))))
|
|
|
|
|
(process-send-string proc "foo")
|
|
|
|
|
(process-send-eof proc)
|
|
|
|
|
;; Read output.
|
2019-02-03 11:07:36 +01:00
|
|
|
|
(with-timeout (10 (tramp--test-timeout-handler))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(while (< (- (point-max) (point-min)) (length "foo"))
|
2019-01-29 17:26:14 +01:00
|
|
|
|
(while (accept-process-output proc 0 nil t))))
|
2019-04-03 21:36:40 +02:00
|
|
|
|
;; We cannot use `string-equal', because tramp-adb.el
|
|
|
|
|
;; echoes also the sent string.
|
|
|
|
|
(should (string-match "\\`foo" (buffer-string))))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
2019-01-24 14:36:38 +01:00
|
|
|
|
(ignore-errors (delete-process proc))))))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test30-make-process ()
|
|
|
|
|
"Check `make-process'."
|
|
|
|
|
:tags '(:expensive-test)
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2019-04-03 21:36:40 +02:00
|
|
|
|
(skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
|
2019-05-18 16:04:58 +02:00
|
|
|
|
;; `make-process' has been inserted in Emacs 25.1. It supports file
|
|
|
|
|
;; name handlers since Emacs 27.
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(skip-unless (tramp--test-emacs27-p))
|
|
|
|
|
|
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
|
|
|
|
(let ((default-directory tramp-test-temporary-file-directory)
|
|
|
|
|
(tmp-name (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
kill-buffer-query-functions proc)
|
2019-05-18 16:04:58 +02:00
|
|
|
|
(should-not (with-no-warnings (make-process)))
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
|
|
|
|
|
;; Simple process.
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(setq proc
|
2019-05-18 16:04:58 +02:00
|
|
|
|
(with-no-warnings
|
|
|
|
|
(make-process
|
|
|
|
|
:name "test1" :buffer (current-buffer) :command '("cat")
|
|
|
|
|
:file-handler t)))
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(should (processp proc))
|
|
|
|
|
(should (equal (process-status proc) 'run))
|
|
|
|
|
(process-send-string proc "foo")
|
|
|
|
|
(process-send-eof proc)
|
|
|
|
|
;; Read output.
|
2019-02-03 11:07:36 +01:00
|
|
|
|
(with-timeout (10 (tramp--test-timeout-handler))
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(while (< (- (point-max) (point-min)) (length "foo"))
|
2019-01-29 17:26:14 +01:00
|
|
|
|
(while (accept-process-output proc 0 nil t))))
|
2019-04-03 21:36:40 +02:00
|
|
|
|
;; We cannot use `string-equal', because tramp-adb.el
|
|
|
|
|
;; echoes also the sent string.
|
|
|
|
|
(should (string-match "\\`foo" (buffer-string))))
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-process proc)))
|
|
|
|
|
|
|
|
|
|
;; Simple process using a file.
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(write-region "foo" nil tmp-name)
|
|
|
|
|
(should (file-exists-p tmp-name))
|
|
|
|
|
(setq proc
|
2019-05-18 16:04:58 +02:00
|
|
|
|
(with-no-warnings
|
|
|
|
|
(make-process
|
|
|
|
|
:name "test2" :buffer (current-buffer)
|
|
|
|
|
:command `("cat" ,(file-name-nondirectory tmp-name))
|
|
|
|
|
:file-handler t)))
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(should (processp proc))
|
|
|
|
|
;; Read output.
|
2019-02-03 11:07:36 +01:00
|
|
|
|
(with-timeout (10 (tramp--test-timeout-handler))
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(while (< (- (point-max) (point-min)) (length "foo"))
|
2019-01-29 17:26:14 +01:00
|
|
|
|
(while (accept-process-output proc 0 nil t))))
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(should (string-equal (buffer-string) "foo")))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(delete-process proc)
|
|
|
|
|
(delete-file tmp-name)))
|
|
|
|
|
|
|
|
|
|
;; Process filter.
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(setq proc
|
2019-05-18 16:04:58 +02:00
|
|
|
|
(with-no-warnings
|
|
|
|
|
(make-process
|
|
|
|
|
:name "test3" :buffer (current-buffer) :command '("cat")
|
|
|
|
|
:filter
|
|
|
|
|
(lambda (p s)
|
|
|
|
|
(with-current-buffer (process-buffer p) (insert s)))
|
|
|
|
|
:file-handler t)))
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(should (processp proc))
|
|
|
|
|
(should (equal (process-status proc) 'run))
|
|
|
|
|
(process-send-string proc "foo")
|
|
|
|
|
(process-send-eof proc)
|
|
|
|
|
;; Read output.
|
2019-02-03 11:07:36 +01:00
|
|
|
|
(with-timeout (10 (tramp--test-timeout-handler))
|
2019-04-03 21:36:40 +02:00
|
|
|
|
(while (not (string-match "foo" (buffer-string)))
|
2019-01-29 17:26:14 +01:00
|
|
|
|
(while (accept-process-output proc 0 nil t))))
|
2019-04-03 21:36:40 +02:00
|
|
|
|
;; We cannot use `string-equal', because tramp-adb.el
|
|
|
|
|
;; echoes also the sent string.
|
|
|
|
|
(should (string-match "\\`foo" (buffer-string))))
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-process proc)))
|
|
|
|
|
|
|
|
|
|
;; Process sentinel.
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(setq proc
|
2019-05-18 16:04:58 +02:00
|
|
|
|
(with-no-warnings
|
|
|
|
|
(make-process
|
|
|
|
|
:name "test4" :buffer (current-buffer) :command '("cat")
|
|
|
|
|
:sentinel
|
|
|
|
|
(lambda (p s)
|
|
|
|
|
(with-current-buffer (process-buffer p) (insert s)))
|
|
|
|
|
:file-handler t)))
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(should (processp proc))
|
|
|
|
|
(should (equal (process-status proc) 'run))
|
|
|
|
|
(process-send-string proc "foo")
|
|
|
|
|
(process-send-eof proc)
|
|
|
|
|
(delete-process proc)
|
|
|
|
|
;; Read output.
|
2019-02-03 11:07:36 +01:00
|
|
|
|
(with-timeout (10 (tramp--test-timeout-handler))
|
2019-01-29 17:26:14 +01:00
|
|
|
|
(while (accept-process-output proc 0 nil t)))
|
2019-04-03 21:36:40 +02:00
|
|
|
|
;; We cannot use `string-equal', because tramp-adb.el
|
2019-08-24 10:10:05 +02:00
|
|
|
|
;; echoes also the sent string. And a remote macOS sends
|
|
|
|
|
;; a slightly modified string.
|
|
|
|
|
(should (string-match "killed.*\n\\'" (buffer-string))))
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-process proc)))
|
|
|
|
|
|
2019-04-03 21:36:40 +02:00
|
|
|
|
;; Process with stderr. tramp-adb.el doesn't support it (yet).
|
|
|
|
|
(unless (tramp--test-adb-p)
|
|
|
|
|
(let ((stderr
|
|
|
|
|
(generate-new-buffer (generate-new-buffer-name "stderr"))))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(setq proc
|
2019-05-18 16:04:58 +02:00
|
|
|
|
(with-no-warnings
|
|
|
|
|
(make-process
|
|
|
|
|
:name "test5" :buffer (current-buffer)
|
|
|
|
|
:command '("cat" "/")
|
|
|
|
|
:stderr stderr
|
|
|
|
|
:file-handler t)))
|
2019-04-03 21:36:40 +02:00
|
|
|
|
(should (processp proc))
|
|
|
|
|
;; Read stderr.
|
|
|
|
|
(with-current-buffer stderr
|
|
|
|
|
(with-timeout (10 (tramp--test-timeout-handler))
|
|
|
|
|
(while (= (point-min) (point-max))
|
|
|
|
|
(while (accept-process-output proc 0 nil t))))
|
|
|
|
|
(should
|
2019-04-05 13:27:06 +02:00
|
|
|
|
(string-match "^cat:.* Is a directory" (buffer-string)))))
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
|
2019-04-03 21:36:40 +02:00
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-process proc))
|
2019-06-04 12:51:45 +02:00
|
|
|
|
(ignore-errors (kill-buffer stderr))))))))
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
|
|
|
|
|
(ert-deftest tramp-test31-interrupt-process ()
|
2017-08-20 21:18:05 +02:00
|
|
|
|
"Check `interrupt-process'."
|
|
|
|
|
:tags '(:expensive-test)
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
|
|
|
|
(skip-unless (tramp--test-sh-p))
|
2017-08-22 16:22:33 +02:00
|
|
|
|
;; Since Emacs 26.1.
|
|
|
|
|
(skip-unless (boundp 'interrupt-process-functions))
|
2017-08-20 21:18:05 +02:00
|
|
|
|
|
2019-06-04 12:51:45 +02:00
|
|
|
|
;; We must use `file-truename' for the temporary directory, in
|
|
|
|
|
;; order to establish the connection prior running an asynchronous
|
|
|
|
|
;; process.
|
|
|
|
|
(let ((default-directory (file-truename tramp-test-temporary-file-directory))
|
2017-08-20 21:18:05 +02:00
|
|
|
|
kill-buffer-query-functions proc)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(setq proc (start-file-process "test" (current-buffer) "sleep" "10"))
|
|
|
|
|
(should (processp proc))
|
2017-08-24 15:53:56 +02:00
|
|
|
|
(should (process-live-p proc))
|
2017-08-20 21:18:05 +02:00
|
|
|
|
(should (equal (process-status proc) 'run))
|
2017-09-17 19:16:59 +02:00
|
|
|
|
(should (numberp (process-get proc 'remote-pid)))
|
2017-08-24 15:53:56 +02:00
|
|
|
|
(should (interrupt-process proc))
|
|
|
|
|
;; Let the process accept the interrupt.
|
2019-06-15 11:33:16 +02:00
|
|
|
|
(with-timeout (10 (tramp--test-timeout-handler))
|
|
|
|
|
(while (accept-process-output proc nil nil 0)))
|
2017-08-24 15:53:56 +02:00
|
|
|
|
(should-not (process-live-p proc))
|
|
|
|
|
;; An interrupted process cannot be interrupted, again.
|
2017-09-17 19:16:59 +02:00
|
|
|
|
(should-error (interrupt-process proc) :type 'error))
|
2017-08-20 21:18:05 +02:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-process proc)))))
|
|
|
|
|
|
2019-04-17 11:42:06 +02:00
|
|
|
|
(defun tramp--test-shell-command-to-string-asynchronously (command)
|
|
|
|
|
"Like `shell-command-to-string', but for asynchronous processes."
|
|
|
|
|
(with-temp-buffer
|
2019-04-19 14:18:59 +02:00
|
|
|
|
(async-shell-command command (current-buffer))
|
|
|
|
|
(with-timeout
|
|
|
|
|
((if (getenv "EMACS_EMBA_CI") 30 10) (tramp--test-timeout-handler))
|
|
|
|
|
(while (accept-process-output
|
|
|
|
|
(get-buffer-process (current-buffer)) nil nil t)))
|
2019-04-17 11:42:06 +02:00
|
|
|
|
(buffer-substring-no-properties (point-min) (point-max))))
|
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test32-shell-command ()
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
"Check `shell-command'."
|
|
|
|
|
:tags '(:expensive-test)
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2019-03-22 14:38:06 +01:00
|
|
|
|
;; Prior Emacs 27, `shell-file-name' was hard coded as "/bin/sh" for
|
|
|
|
|
;; remote processes in Emacs. That doesn't work for tramp-adb.el.
|
|
|
|
|
(skip-unless (or (and (tramp--test-adb-p) (tramp--test-emacs27-p))
|
|
|
|
|
(tramp--test-sh-p)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(let ((tmp-name (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(default-directory tramp-test-temporary-file-directory)
|
2017-06-29 18:22:38 +02:00
|
|
|
|
;; Suppress nasty messages.
|
|
|
|
|
(inhibit-message t)
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
kill-buffer-query-functions)
|
2019-04-17 11:42:06 +02:00
|
|
|
|
|
|
|
|
|
;; Test ordinary `shell-command'.
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(unwind-protect
|
2013-11-13 16:36:12 +01:00
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(write-region "foo" nil tmp-name)
|
2014-02-07 16:47:18 +01:00
|
|
|
|
(should (file-exists-p tmp-name))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(shell-command
|
|
|
|
|
(format "ls %s" (file-name-nondirectory tmp-name))
|
|
|
|
|
(current-buffer))
|
2014-06-24 09:48:19 +02:00
|
|
|
|
;; `ls' could produce colorized output.
|
|
|
|
|
(goto-char (point-min))
|
2016-05-28 12:14:58 +02:00
|
|
|
|
(while
|
|
|
|
|
(re-search-forward tramp-display-escape-sequence-regexp nil t)
|
2014-06-24 09:48:19 +02:00
|
|
|
|
(replace-match "" nil nil))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(format "%s\n" (file-name-nondirectory tmp-name))
|
|
|
|
|
(buffer-string))))
|
2014-06-24 09:48:19 +02:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-file tmp-name)))
|
|
|
|
|
|
2019-04-17 11:42:06 +02:00
|
|
|
|
;; Test ordinary `async-shell-command'.
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(write-region "foo" nil tmp-name)
|
|
|
|
|
(should (file-exists-p tmp-name))
|
|
|
|
|
(async-shell-command
|
|
|
|
|
(format "ls %s" (file-name-nondirectory tmp-name))
|
|
|
|
|
(current-buffer))
|
|
|
|
|
;; Read output.
|
2019-02-03 11:07:36 +01:00
|
|
|
|
(with-timeout (10 (tramp--test-timeout-handler))
|
2019-01-29 17:26:14 +01:00
|
|
|
|
(while (accept-process-output
|
|
|
|
|
(get-buffer-process (current-buffer)) nil nil t)))
|
2014-02-19 20:28:32 +01:00
|
|
|
|
;; `ls' could produce colorized output.
|
|
|
|
|
(goto-char (point-min))
|
2016-05-28 12:14:58 +02:00
|
|
|
|
(while
|
|
|
|
|
(re-search-forward tramp-display-escape-sequence-regexp nil t)
|
2014-02-19 20:28:32 +01:00
|
|
|
|
(replace-match "" nil nil))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; There might be a nasty "Process *Async Shell* finished" message.
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(forward-line)
|
|
|
|
|
(narrow-to-region (point-min) (point))
|
2014-02-07 16:47:18 +01:00
|
|
|
|
(should
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(string-equal
|
|
|
|
|
(format "%s\n" (file-name-nondirectory tmp-name))
|
|
|
|
|
(buffer-string))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Cleanup.
|
2019-04-03 21:36:40 +02:00
|
|
|
|
(ignore-errors (delete-file tmp-name)))
|
2013-11-16 12:46:37 +01:00
|
|
|
|
|
2019-04-17 11:42:06 +02:00
|
|
|
|
;; Test sending string to `async-shell-command'.
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(write-region "foo" nil tmp-name)
|
|
|
|
|
(should (file-exists-p tmp-name))
|
|
|
|
|
(async-shell-command "read line; ls $line" (current-buffer))
|
|
|
|
|
(process-send-string
|
|
|
|
|
(get-buffer-process (current-buffer))
|
|
|
|
|
(format "%s\n" (file-name-nondirectory tmp-name)))
|
|
|
|
|
;; Read output.
|
2019-02-03 11:07:36 +01:00
|
|
|
|
(with-timeout (10 (tramp--test-timeout-handler))
|
2019-01-29 17:26:14 +01:00
|
|
|
|
(while (accept-process-output
|
|
|
|
|
(get-buffer-process (current-buffer)) nil nil t)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; `ls' could produce colorized output.
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while
|
|
|
|
|
(re-search-forward tramp-display-escape-sequence-regexp nil t)
|
|
|
|
|
(replace-match "" nil nil))
|
|
|
|
|
;; There might be a nasty "Process *Async Shell* finished" message.
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(forward-line)
|
|
|
|
|
(narrow-to-region (point-min) (point))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(format "%s\n" (file-name-nondirectory tmp-name))
|
|
|
|
|
(buffer-string))))
|
2015-06-28 20:51:54 +02:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Cleanup.
|
2019-04-17 11:42:06 +02:00
|
|
|
|
(ignore-errors (delete-file tmp-name)))
|
2013-11-15 09:03:19 +01:00
|
|
|
|
|
2019-05-05 22:27:33 +03:00
|
|
|
|
;; Test `async-shell-command-width'. Since Emacs 27.1.
|
2019-06-11 20:28:31 +02:00
|
|
|
|
(when (ignore-errors
|
|
|
|
|
(and (boundp 'async-shell-command-width)
|
|
|
|
|
(zerop (call-process "tput" nil nil nil "cols"))
|
|
|
|
|
(zerop (process-file "tput" nil nil nil "cols"))))
|
2019-05-05 22:27:33 +03:00
|
|
|
|
(let (async-shell-command-width)
|
2019-04-17 11:42:06 +02:00
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(format "%s\n" (car (process-lines "tput" "cols")))
|
|
|
|
|
(tramp--test-shell-command-to-string-asynchronously
|
|
|
|
|
"tput cols")))
|
2019-05-05 22:27:33 +03:00
|
|
|
|
(setq async-shell-command-width 1024)
|
2019-04-17 11:42:06 +02:00
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
"1024\n"
|
|
|
|
|
(tramp--test-shell-command-to-string-asynchronously
|
|
|
|
|
"tput cols"))))))))
|
2016-07-14 10:10:53 +02:00
|
|
|
|
|
|
|
|
|
;; This test is inspired by Bug#23952.
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test33-environment-variables ()
|
2016-07-14 10:10:53 +02:00
|
|
|
|
"Check that remote processes set / unset environment variables properly."
|
|
|
|
|
:tags '(:expensive-test)
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
Add `make-nearby-temp-file' and `temporary-file-directory'
* doc/lispref/files.texi (Unique File Names):
Introduce `make-nearby-temp-file' and `temporary-file-directory'.
(Magic File Names): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* etc/NEWS (provided): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* lisp/files.el (mounted-file-systems): New defcustom.
(temporary-file-directory, make-nearby-temp-file): New defuns.
(normal-backup-enable-predicate): Fix docstring.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
<make-nearby-temp-file, temporary-file-directory>: Add handler.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `make-nearby-temp-file' and `temporary-file-directory'.
(tramp-get-remote-tmpdir): Remove compatibility code.
(tramp-handle-temporary-file-directory)
(tramp-handle-make-nearby-temp-file): New defuns.
* lisp/org/ob-core.el (org-babel-local-file-name):
* lisp/progmodes/gud.el (gud-common-init):
* lisp/vc/vc-hooks.el (vc-user-login-name): Use `file-remote-p'.
* lisp/vc/vc-git.el (vc-git-checkin): Handle remote log message.
* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name):
Check `tramp--test-enabled'.
(tramp-test18-file-attributes): Add tests for
`file-ownership-preserved-p'.
(tramp-test27-start-file-process, tramp-test28-shell-command):
Reduce timeouts in `accept-process-output'.
(tramp-test--shell-command-to-string-asynchronously): Add timeout.
(tramp-test29-environment-variables): Remove additional sleep calls.
(tramp-test32-make-nearby-temp-file): New test.
(tramp--test-special-characters, tramp--test-utf8): Adapt docstring.
(tramp-test33-special-characters)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls, tramp-test34-utf8)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests)
(tramp-test36-recursive-load, tramp-test37-unload): Rename.
(tramp--test-ftp-p): Simplify check.
(tramp--test-sh-p): New defun.
(tramp-test20-file-modes, tramp-test22-file-times)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command)
(tramp-test29-environment-variables)
(tramp-test30-vc-registered)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests): Use it.
2016-08-07 13:57:23 +02:00
|
|
|
|
(skip-unless (tramp--test-sh-p))
|
2016-07-14 10:10:53 +02:00
|
|
|
|
|
|
|
|
|
(dolist (this-shell-command-to-string
|
|
|
|
|
'(;; Synchronously.
|
|
|
|
|
shell-command-to-string
|
|
|
|
|
;; Asynchronously.
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
tramp--test-shell-command-to-string-asynchronously))
|
2016-07-14 10:10:53 +02:00
|
|
|
|
|
|
|
|
|
(let ((default-directory tramp-test-temporary-file-directory)
|
|
|
|
|
(shell-file-name "/bin/sh")
|
|
|
|
|
(envvar (concat "VAR_" (upcase (md5 (current-time-string)))))
|
|
|
|
|
kill-buffer-query-functions)
|
|
|
|
|
|
|
|
|
|
(unwind-protect
|
|
|
|
|
;; Set a value.
|
|
|
|
|
(let ((process-environment
|
|
|
|
|
(cons (concat envvar "=foo") process-environment)))
|
|
|
|
|
;; Default value.
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
"foo"
|
|
|
|
|
(funcall
|
|
|
|
|
this-shell-command-to-string
|
2019-09-13 12:08:34 +02:00
|
|
|
|
(format "echo -n ${%s:-bla}" envvar))))))
|
2016-07-14 10:10:53 +02:00
|
|
|
|
|
|
|
|
|
(unwind-protect
|
|
|
|
|
;; Set the empty value.
|
|
|
|
|
(let ((process-environment
|
|
|
|
|
(cons (concat envvar "=") process-environment)))
|
|
|
|
|
;; Value is null.
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
"bla"
|
|
|
|
|
(funcall
|
|
|
|
|
this-shell-command-to-string
|
2019-09-13 12:08:34 +02:00
|
|
|
|
(format "echo -n ${%s:-bla}" envvar))))
|
2016-07-14 10:10:53 +02:00
|
|
|
|
;; Variable is set.
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
(regexp-quote envvar)
|
2016-07-14 12:27:41 +02:00
|
|
|
|
(funcall this-shell-command-to-string "set")))))
|
2016-07-14 10:10:53 +02:00
|
|
|
|
|
|
|
|
|
;; We force a reconnect, in order to have a clean environment.
|
|
|
|
|
(tramp-cleanup-connection
|
|
|
|
|
(tramp-dissect-file-name tramp-test-temporary-file-directory)
|
|
|
|
|
'keep-debug 'keep-password)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
;; Unset the variable.
|
|
|
|
|
(let ((tramp-remote-process-environment
|
|
|
|
|
(cons (concat envvar "=foo")
|
|
|
|
|
tramp-remote-process-environment)))
|
|
|
|
|
;; Set the initial value, we want to unset below.
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
"foo"
|
|
|
|
|
(funcall
|
|
|
|
|
this-shell-command-to-string
|
2019-09-13 12:08:34 +02:00
|
|
|
|
(format "echo -n ${%s:-bla}" envvar))))
|
2016-07-14 10:10:53 +02:00
|
|
|
|
(let ((process-environment
|
|
|
|
|
(cons envvar process-environment)))
|
|
|
|
|
;; Variable is unset.
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
"bla"
|
|
|
|
|
(funcall
|
|
|
|
|
this-shell-command-to-string
|
2019-09-13 12:08:34 +02:00
|
|
|
|
(format "echo -n ${%s:-bla}" envvar))))
|
2016-07-14 10:10:53 +02:00
|
|
|
|
;; Variable is unset.
|
|
|
|
|
(should-not
|
|
|
|
|
(string-match
|
|
|
|
|
(regexp-quote envvar)
|
2019-09-13 12:08:34 +02:00
|
|
|
|
;; We must remove PS1, the output is truncated otherwise.
|
|
|
|
|
(funcall
|
|
|
|
|
this-shell-command-to-string "printenv | grep -v PS1")))))))))
|
2016-07-14 10:10:53 +02:00
|
|
|
|
|
2017-05-23 09:25:03 +02:00
|
|
|
|
;; This test is inspired by Bug#27009.
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test33-environment-variables-and-port-numbers ()
|
2017-05-23 09:25:03 +02:00
|
|
|
|
"Check that two connections with separate ports are different."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
|
|
|
|
;; We test it only for the mock-up connection; otherwise there might
|
|
|
|
|
;; be problems with the used ports.
|
2017-11-27 13:31:53 +01:00
|
|
|
|
(skip-unless (and (eq tramp-syntax 'default)
|
|
|
|
|
(tramp--test-mock-p)))
|
2017-05-23 09:25:03 +02:00
|
|
|
|
|
|
|
|
|
;; We force a reconnect, in order to have a clean environment.
|
2017-05-24 16:17:59 +02:00
|
|
|
|
(dolist (dir `(,tramp-test-temporary-file-directory
|
|
|
|
|
"/mock:localhost#11111:" "/mock:localhost#22222:"))
|
2017-05-23 09:25:03 +02:00
|
|
|
|
(tramp-cleanup-connection
|
|
|
|
|
(tramp-dissect-file-name dir) 'keep-debug 'keep-password))
|
|
|
|
|
|
2017-05-24 16:17:59 +02:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(dolist (port '(11111 22222))
|
|
|
|
|
(let* ((default-directory
|
|
|
|
|
(format "/mock:localhost#%d:%s" port temporary-file-directory))
|
|
|
|
|
(shell-file-name "/bin/sh")
|
|
|
|
|
(envvar (concat "VAR_" (upcase (md5 (current-time-string)))))
|
|
|
|
|
;; We cannot use `process-environment', because this
|
|
|
|
|
;; would be applied in `process-file'.
|
|
|
|
|
(tramp-remote-process-environment
|
|
|
|
|
(cons
|
|
|
|
|
(format "%s=%d" envvar port)
|
|
|
|
|
tramp-remote-process-environment)))
|
|
|
|
|
(should
|
2017-12-16 16:40:03 +01:00
|
|
|
|
(string-match
|
2017-05-24 16:17:59 +02:00
|
|
|
|
(number-to-string port)
|
|
|
|
|
(shell-command-to-string (format "echo -n $%s" envvar))))))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(dolist (dir '("/mock:localhost#11111:" "/mock:localhost#22222:"))
|
|
|
|
|
(tramp-cleanup-connection (tramp-dissect-file-name dir)))))
|
2017-05-23 09:25:03 +02:00
|
|
|
|
|
2019-03-09 16:44:24 +01:00
|
|
|
|
;; Connection-local variables are enabled per default since Emacs 27.1.
|
|
|
|
|
(ert-deftest tramp-test34-connection-local-variables ()
|
|
|
|
|
"Check that connection-local variables are enabled."
|
|
|
|
|
:tags '(:expensive-test)
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
|
|
|
|
;; Since Emacs 27.1.
|
|
|
|
|
(skip-unless (fboundp 'with-connection-local-variables))
|
|
|
|
|
|
|
|
|
|
;; `connection-local-set-profile-variables' and
|
|
|
|
|
;; `connection-local-set-profiles' exist since Emacs 26.1. We don't
|
|
|
|
|
;; want to see compiler warnings for older Emacsen.
|
|
|
|
|
(let* ((default-directory tramp-test-temporary-file-directory)
|
|
|
|
|
(tmp-name1 (tramp--test-make-temp-name))
|
|
|
|
|
(tmp-name2 (expand-file-name "foo" tmp-name1))
|
|
|
|
|
(enable-local-variables :all)
|
|
|
|
|
(enable-remote-dir-locals t)
|
|
|
|
|
kill-buffer-query-functions
|
|
|
|
|
connection-local-profile-alist connection-local-criteria-alist)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(make-directory tmp-name1)
|
|
|
|
|
(should (file-directory-p tmp-name1))
|
|
|
|
|
|
|
|
|
|
;; `local-variable' is buffer-local due to explicit setting.
|
|
|
|
|
(with-no-warnings
|
|
|
|
|
(defvar-local local-variable 'buffer))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(should (eq local-variable 'buffer)))
|
|
|
|
|
|
|
|
|
|
;; `local-variable' is connection-local due to Tramp.
|
|
|
|
|
(write-region "foo" nil tmp-name2)
|
|
|
|
|
(should (file-exists-p tmp-name2))
|
|
|
|
|
(with-no-warnings
|
|
|
|
|
(connection-local-set-profile-variables
|
|
|
|
|
'local-variable-profile
|
|
|
|
|
'((local-variable . connect)))
|
|
|
|
|
(connection-local-set-profiles
|
|
|
|
|
`(:application tramp
|
|
|
|
|
:protocol ,(file-remote-p default-directory 'method)
|
|
|
|
|
:user ,(file-remote-p default-directory 'user)
|
|
|
|
|
:machine ,(file-remote-p default-directory 'host))
|
|
|
|
|
'local-variable-profile))
|
|
|
|
|
(with-current-buffer (find-file-noselect tmp-name2)
|
|
|
|
|
(should (eq local-variable 'connect))
|
|
|
|
|
(kill-buffer (current-buffer)))
|
|
|
|
|
|
|
|
|
|
;; `local-variable' is dir-local due to existence of .dir-locals.el.
|
|
|
|
|
(write-region
|
|
|
|
|
"((nil . ((local-variable . dir))))" nil
|
|
|
|
|
(expand-file-name ".dir-locals.el" tmp-name1))
|
|
|
|
|
(should (file-exists-p (expand-file-name ".dir-locals.el" tmp-name1)))
|
|
|
|
|
(with-current-buffer (find-file-noselect tmp-name2)
|
|
|
|
|
(should (eq local-variable 'dir))
|
|
|
|
|
(kill-buffer (current-buffer)))
|
|
|
|
|
|
|
|
|
|
;; `local-variable' is file-local due to specifying as file variable.
|
|
|
|
|
(write-region
|
|
|
|
|
"-*- mode: comint; local-variable: file; -*-" nil tmp-name2)
|
|
|
|
|
(should (file-exists-p tmp-name2))
|
|
|
|
|
(with-current-buffer (find-file-noselect tmp-name2)
|
|
|
|
|
(should (eq local-variable 'file))
|
|
|
|
|
(kill-buffer (current-buffer))))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-directory tmp-name1 'recursive)))))
|
|
|
|
|
|
2017-04-03 14:04:06 +02:00
|
|
|
|
;; The functions were introduced in Emacs 26.1.
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test34-explicit-shell-file-name ()
|
2017-04-03 14:04:06 +02:00
|
|
|
|
"Check that connection-local `explicit-shell-file-name' is set."
|
2019-04-03 21:36:40 +02:00
|
|
|
|
:tags '(:expensive-test)
|
2017-04-03 14:04:06 +02:00
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2019-04-05 13:27:06 +02:00
|
|
|
|
;; Prior Emacs 27, `shell-file-name' was hard coded as "/bin/sh" for
|
|
|
|
|
;; remote processes in Emacs. That doesn't work for tramp-adb.el.
|
|
|
|
|
(skip-unless (or (and (tramp--test-adb-p) (tramp--test-emacs27-p))
|
|
|
|
|
(tramp--test-sh-p)))
|
2017-07-31 14:32:24 +02:00
|
|
|
|
;; Since Emacs 26.1.
|
2017-04-03 14:04:06 +02:00
|
|
|
|
(skip-unless (and (fboundp 'connection-local-set-profile-variables)
|
|
|
|
|
(fboundp 'connection-local-set-profiles)))
|
|
|
|
|
|
|
|
|
|
;; `connection-local-set-profile-variables' and
|
2017-11-14 10:21:55 +01:00
|
|
|
|
;; `connection-local-set-profiles' exist since Emacs 26.1. We don't
|
2017-04-03 14:04:06 +02:00
|
|
|
|
;; want to see compiler warnings for older Emacsen.
|
|
|
|
|
(let ((default-directory tramp-test-temporary-file-directory)
|
2019-03-09 16:44:24 +01:00
|
|
|
|
explicit-shell-file-name kill-buffer-query-functions
|
|
|
|
|
connection-local-profile-alist connection-local-criteria-alist)
|
2017-04-03 14:04:06 +02:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
;; `shell-mode' would ruin our test, because it deletes all
|
2019-04-03 21:36:40 +02:00
|
|
|
|
;; buffer local variables. Not needed in Emacs 27.1.
|
2017-04-03 14:04:06 +02:00
|
|
|
|
(put 'explicit-shell-file-name 'permanent-local t)
|
2019-04-03 21:36:40 +02:00
|
|
|
|
;; Declare connection-local variables `explicit-shell-file-name'
|
|
|
|
|
;; and `explicit-sh-args'.
|
2017-04-03 14:04:06 +02:00
|
|
|
|
(with-no-warnings
|
|
|
|
|
(connection-local-set-profile-variables
|
|
|
|
|
'remote-sh
|
2019-03-09 16:44:24 +01:00
|
|
|
|
`((explicit-shell-file-name
|
|
|
|
|
. ,(if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh"))
|
2019-04-03 21:36:40 +02:00
|
|
|
|
(explicit-sh-args . ("-c" "echo foo"))))
|
2017-04-03 14:04:06 +02:00
|
|
|
|
(connection-local-set-profiles
|
|
|
|
|
`(:application tramp
|
|
|
|
|
:protocol ,(file-remote-p default-directory 'method)
|
|
|
|
|
:user ,(file-remote-p default-directory 'user)
|
|
|
|
|
:machine ,(file-remote-p default-directory 'host))
|
|
|
|
|
'remote-sh))
|
2019-03-09 16:44:24 +01:00
|
|
|
|
(put 'explicit-shell-file-name 'safe-local-variable #'identity)
|
|
|
|
|
(put 'explicit-sh-args 'safe-local-variable #'identity)
|
2017-04-03 14:04:06 +02:00
|
|
|
|
|
2019-04-03 21:36:40 +02:00
|
|
|
|
;; Run `shell' interactively. Since the default directory
|
|
|
|
|
;; is remote, `explicit-shell-file-name' shall be set in
|
|
|
|
|
;; order to avoid a question. `explicit-sh-args' echoes the
|
|
|
|
|
;; test data.
|
2017-04-03 14:04:06 +02:00
|
|
|
|
(with-current-buffer (get-buffer-create "*shell*")
|
|
|
|
|
(ignore-errors (kill-process (current-buffer)))
|
|
|
|
|
(should-not explicit-shell-file-name)
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(call-interactively #'shell)
|
2019-04-03 21:36:40 +02:00
|
|
|
|
(with-timeout (10)
|
|
|
|
|
(while (accept-process-output
|
|
|
|
|
(get-buffer-process (current-buffer)) nil nil t)))
|
|
|
|
|
(should (string-match "^foo$" (buffer-string)))))
|
2017-04-03 14:04:06 +02:00
|
|
|
|
|
2019-03-09 16:44:24 +01:00
|
|
|
|
;; Cleanup.
|
2017-04-03 14:04:06 +02:00
|
|
|
|
(put 'explicit-shell-file-name 'permanent-local nil)
|
|
|
|
|
(kill-buffer "*shell*"))))
|
|
|
|
|
|
2018-06-22 16:17:17 +02:00
|
|
|
|
;; `exec-path' was introduced in Emacs 27.1. `executable-find' has
|
|
|
|
|
;; changed the number of parameters, so we use `apply' for older
|
|
|
|
|
;; Emacsen.
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test35-exec-path ()
|
2018-06-20 12:13:56 +02:00
|
|
|
|
"Check `exec-path' and `executable-find'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
|
|
|
|
(skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
|
|
|
|
|
;; Since Emacs 27.1.
|
2018-06-22 16:17:17 +02:00
|
|
|
|
(skip-unless (fboundp 'exec-path))
|
2018-06-20 12:13:56 +02:00
|
|
|
|
|
|
|
|
|
(let ((tmp-name (tramp--test-make-temp-name))
|
|
|
|
|
(default-directory tramp-test-temporary-file-directory))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(should (consp (with-no-warnings (exec-path))))
|
|
|
|
|
;; Last element is the `exec-directory'.
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(car (last (with-no-warnings (exec-path))))
|
2018-06-22 16:17:17 +02:00
|
|
|
|
(file-remote-p default-directory 'localname)))
|
2018-06-20 12:13:56 +02:00
|
|
|
|
;; The shell "sh" shall always exist.
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(should (apply #'executable-find '("sh" remote)))
|
2018-06-20 12:13:56 +02:00
|
|
|
|
;; Since the last element in `exec-path' is the current
|
|
|
|
|
;; directory, an executable file in that directory will be
|
|
|
|
|
;; found.
|
|
|
|
|
(write-region "foo" nil tmp-name)
|
|
|
|
|
(should (file-exists-p tmp-name))
|
|
|
|
|
(set-file-modes tmp-name #o777)
|
|
|
|
|
(should (file-executable-p tmp-name))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
2018-06-22 16:17:17 +02:00
|
|
|
|
(apply
|
2019-02-28 10:33:05 +01:00
|
|
|
|
#'executable-find `(,(file-name-nondirectory tmp-name) remote))
|
2018-06-22 16:17:17 +02:00
|
|
|
|
(file-remote-p tmp-name 'localname)))
|
2018-06-20 12:13:56 +02:00
|
|
|
|
(should-not
|
2018-06-22 16:17:17 +02:00
|
|
|
|
(apply
|
2019-02-28 10:33:05 +01:00
|
|
|
|
#'executable-find
|
2018-06-22 16:17:17 +02:00
|
|
|
|
`(,(concat (file-name-nondirectory tmp-name) "foo") remote))))
|
2018-06-20 12:13:56 +02:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-file tmp-name)))))
|
|
|
|
|
|
2018-12-20 11:07:15 +01:00
|
|
|
|
;; This test is inspired by Bug#33781.
|
|
|
|
|
;; `exec-path' was introduced in Emacs 27.1. `executable-find' has
|
|
|
|
|
;; changed the number of parameters, so we use `apply' for older
|
|
|
|
|
;; Emacsen.
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test35-remote-path ()
|
2018-12-20 11:07:15 +01:00
|
|
|
|
"Check loooong `tramp-remote-path'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
|
|
|
|
(skip-unless (tramp--test-sh-p))
|
|
|
|
|
;; Since Emacs 27.1.
|
|
|
|
|
(skip-unless (fboundp 'exec-path))
|
|
|
|
|
|
|
|
|
|
(let* ((tmp-name (tramp--test-make-temp-name))
|
|
|
|
|
(default-directory tramp-test-temporary-file-directory)
|
2019-02-03 11:07:36 +01:00
|
|
|
|
(orig-exec-path (with-no-warnings (exec-path)))
|
2018-12-20 11:07:15 +01:00
|
|
|
|
(tramp-remote-path tramp-remote-path)
|
|
|
|
|
(orig-tramp-remote-path tramp-remote-path))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
;; Non existing directories are removed.
|
|
|
|
|
(setq tramp-remote-path
|
|
|
|
|
(cons (file-remote-p tmp-name 'localname) tramp-remote-path))
|
|
|
|
|
(tramp-cleanup-connection
|
|
|
|
|
(tramp-dissect-file-name tramp-test-temporary-file-directory)
|
|
|
|
|
'keep-debug 'keep-password)
|
|
|
|
|
(should (equal (with-no-warnings (exec-path)) orig-exec-path))
|
|
|
|
|
(setq tramp-remote-path orig-tramp-remote-path)
|
|
|
|
|
|
|
|
|
|
;; Double entries are removed.
|
|
|
|
|
(setq tramp-remote-path (append '("/" "/") tramp-remote-path))
|
|
|
|
|
(tramp-cleanup-connection
|
|
|
|
|
(tramp-dissect-file-name tramp-test-temporary-file-directory)
|
|
|
|
|
'keep-debug 'keep-password)
|
|
|
|
|
(should
|
|
|
|
|
(equal (with-no-warnings (exec-path)) (cons "/" orig-exec-path)))
|
|
|
|
|
(setq tramp-remote-path orig-tramp-remote-path)
|
|
|
|
|
|
|
|
|
|
;; We make a super long `tramp-remote-path'.
|
|
|
|
|
(make-directory tmp-name)
|
|
|
|
|
(should (file-directory-p tmp-name))
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(while (< (length (mapconcat #'identity orig-exec-path ":")) 5000)
|
2018-12-20 11:07:15 +01:00
|
|
|
|
(let ((dir (make-temp-file (file-name-as-directory tmp-name) 'dir)))
|
|
|
|
|
(should (file-directory-p dir))
|
|
|
|
|
(setq tramp-remote-path
|
|
|
|
|
(cons (file-remote-p dir 'localname) tramp-remote-path)
|
|
|
|
|
orig-exec-path
|
|
|
|
|
(cons (file-remote-p dir 'localname) orig-exec-path))))
|
|
|
|
|
(tramp-cleanup-connection
|
|
|
|
|
(tramp-dissect-file-name tramp-test-temporary-file-directory)
|
|
|
|
|
'keep-debug 'keep-password)
|
|
|
|
|
(should (equal (with-no-warnings (exec-path)) orig-exec-path))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
;; Ignore trailing newline.
|
|
|
|
|
(substring (shell-command-to-string "echo $PATH") nil -1)
|
|
|
|
|
;; The last element of `exec-path' is `exec-directory'.
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(mapconcat #'identity (butlast orig-exec-path) ":")))
|
2018-12-20 11:07:15 +01:00
|
|
|
|
;; The shell "sh" shall always exist.
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(should (apply #'executable-find '("sh" remote))))
|
2018-12-20 11:07:15 +01:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(tramp-cleanup-connection
|
|
|
|
|
(tramp-dissect-file-name tramp-test-temporary-file-directory)
|
|
|
|
|
'keep-debug 'keep-password)
|
|
|
|
|
(setq tramp-remote-path orig-tramp-remote-path)
|
|
|
|
|
(ignore-errors (delete-directory tmp-name 'recursive)))))
|
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test36-vc-registered ()
|
2014-02-11 09:31:39 +01:00
|
|
|
|
"Check `vc-registered'."
|
2016-01-04 23:28:07 +01:00
|
|
|
|
:tags '(:expensive-test)
|
2014-02-11 09:31:39 +01:00
|
|
|
|
(skip-unless (tramp--test-enabled))
|
Add `make-nearby-temp-file' and `temporary-file-directory'
* doc/lispref/files.texi (Unique File Names):
Introduce `make-nearby-temp-file' and `temporary-file-directory'.
(Magic File Names): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* etc/NEWS (provided): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* lisp/files.el (mounted-file-systems): New defcustom.
(temporary-file-directory, make-nearby-temp-file): New defuns.
(normal-backup-enable-predicate): Fix docstring.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
<make-nearby-temp-file, temporary-file-directory>: Add handler.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `make-nearby-temp-file' and `temporary-file-directory'.
(tramp-get-remote-tmpdir): Remove compatibility code.
(tramp-handle-temporary-file-directory)
(tramp-handle-make-nearby-temp-file): New defuns.
* lisp/org/ob-core.el (org-babel-local-file-name):
* lisp/progmodes/gud.el (gud-common-init):
* lisp/vc/vc-hooks.el (vc-user-login-name): Use `file-remote-p'.
* lisp/vc/vc-git.el (vc-git-checkin): Handle remote log message.
* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name):
Check `tramp--test-enabled'.
(tramp-test18-file-attributes): Add tests for
`file-ownership-preserved-p'.
(tramp-test27-start-file-process, tramp-test28-shell-command):
Reduce timeouts in `accept-process-output'.
(tramp-test--shell-command-to-string-asynchronously): Add timeout.
(tramp-test29-environment-variables): Remove additional sleep calls.
(tramp-test32-make-nearby-temp-file): New test.
(tramp--test-special-characters, tramp--test-utf8): Adapt docstring.
(tramp-test33-special-characters)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls, tramp-test34-utf8)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests)
(tramp-test36-recursive-load, tramp-test37-unload): Rename.
(tramp--test-ftp-p): Simplify check.
(tramp--test-sh-p): New defun.
(tramp-test20-file-modes, tramp-test22-file-times)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command)
(tramp-test29-environment-variables)
(tramp-test30-vc-registered)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests): Use it.
2016-08-07 13:57:23 +02:00
|
|
|
|
(skip-unless (tramp--test-sh-p))
|
2014-02-11 09:31:39 +01:00
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
2019-06-04 12:51:45 +02:00
|
|
|
|
;; We must use `file-truename' for the temporary directory, in
|
|
|
|
|
;; order to establish the connection prior running an asynchronous
|
|
|
|
|
;; process.
|
|
|
|
|
(let* ((default-directory
|
|
|
|
|
(file-truename tramp-test-temporary-file-directory))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name2 (expand-file-name "foo" tmp-name1))
|
|
|
|
|
(tramp-remote-process-environment tramp-remote-process-environment)
|
|
|
|
|
(vc-handled-backends
|
|
|
|
|
(with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
|
|
|
|
|
(cond
|
|
|
|
|
((tramp-find-executable
|
|
|
|
|
v vc-git-program (tramp-get-remote-path v))
|
|
|
|
|
'(Git))
|
|
|
|
|
((tramp-find-executable
|
|
|
|
|
v vc-hg-program (tramp-get-remote-path v))
|
|
|
|
|
'(Hg))
|
|
|
|
|
((tramp-find-executable
|
|
|
|
|
v vc-bzr-program (tramp-get-remote-path v))
|
|
|
|
|
(setq tramp-remote-process-environment
|
|
|
|
|
(cons (format "BZR_HOME=%s"
|
|
|
|
|
(file-remote-p tmp-name1 'localname))
|
|
|
|
|
tramp-remote-process-environment))
|
|
|
|
|
;; We must force a reconnect, in order to activate $BZR_HOME.
|
|
|
|
|
(tramp-cleanup-connection
|
|
|
|
|
(tramp-dissect-file-name tramp-test-temporary-file-directory)
|
2017-06-29 18:22:38 +02:00
|
|
|
|
'keep-debug 'keep-password)
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
'(Bzr))
|
2017-06-29 18:22:38 +02:00
|
|
|
|
(t nil))))
|
|
|
|
|
;; Suppress nasty messages.
|
|
|
|
|
(inhibit-message t))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(skip-unless vc-handled-backends)
|
2017-06-29 18:22:38 +02:00
|
|
|
|
(unless quoted (tramp--test-message "%s" vc-handled-backends))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(make-directory tmp-name1)
|
|
|
|
|
(write-region "foo" nil tmp-name2)
|
|
|
|
|
(should (file-directory-p tmp-name1))
|
|
|
|
|
(should (file-exists-p tmp-name2))
|
|
|
|
|
(should-not (vc-registered tmp-name1))
|
|
|
|
|
(should-not (vc-registered tmp-name2))
|
|
|
|
|
|
|
|
|
|
(let ((default-directory tmp-name1))
|
|
|
|
|
;; Create empty repository, and register the file.
|
|
|
|
|
;; Sometimes, creation of repository fails (bzr!); we
|
|
|
|
|
;; skip the test then.
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(vc-create-repo (car vc-handled-backends))
|
2019-04-13 10:58:17 +02:00
|
|
|
|
(error (ert-skip "`vc-create-repo' not supported")))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; The structure of VC-FILESET is not documented. Let's
|
|
|
|
|
;; hope it won't change.
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(vc-register
|
|
|
|
|
(list (car vc-handled-backends)
|
|
|
|
|
(list (file-name-nondirectory tmp-name2))))
|
2017-12-17 11:31:23 +01:00
|
|
|
|
;; `vc-register' has changed its arguments in Emacs
|
|
|
|
|
;; 25.1. Let's skip it for older Emacsen.
|
2018-06-03 14:30:41 +02:00
|
|
|
|
(error (skip-unless (tramp--test-emacs25-p))))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; vc-git uses an own process sentinel, Tramp's sentinel
|
|
|
|
|
;; for flushing the cache isn't used.
|
|
|
|
|
(dired-uncache (concat (file-remote-p default-directory) "/"))
|
|
|
|
|
(should (vc-registered (file-name-nondirectory tmp-name2)))))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-directory tmp-name1 'recursive))))))
|
2014-02-11 09:31:39 +01:00
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test37-make-auto-save-file-name ()
|
2015-05-27 15:48:13 +02:00
|
|
|
|
"Check `make-auto-save-file-name'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name2 (tramp--test-make-temp-name nil quoted)))
|
2015-05-27 15:48:13 +02:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
;; Use default `auto-save-file-name-transforms' mechanism.
|
|
|
|
|
(let (tramp-auto-save-directory)
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(setq buffer-file-name tmp-name1)
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(make-auto-save-file-name)
|
|
|
|
|
;; This is taken from original `make-auto-save-file-name'.
|
2017-01-17 17:35:23 +01:00
|
|
|
|
;; We call `convert-standard-filename', because on
|
|
|
|
|
;; MS Windows the (local) colons must be replaced by
|
|
|
|
|
;; exclamation marks.
|
|
|
|
|
(convert-standard-filename
|
|
|
|
|
(expand-file-name
|
|
|
|
|
(format
|
|
|
|
|
"#%s#"
|
|
|
|
|
(subst-char-in-string
|
|
|
|
|
?/ ?! (replace-regexp-in-string "!" "!!" tmp-name1)))
|
|
|
|
|
temporary-file-directory))))))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
;; No mapping.
|
|
|
|
|
(let (tramp-auto-save-directory auto-save-file-name-transforms)
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(setq buffer-file-name tmp-name1)
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(make-auto-save-file-name)
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-quote #'identity)
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(expand-file-name
|
|
|
|
|
(format "#%s#" (file-name-nondirectory tmp-name1))
|
|
|
|
|
tramp-test-temporary-file-directory))))))
|
|
|
|
|
|
|
|
|
|
;; Use default `tramp-auto-save-directory' mechanism.
|
|
|
|
|
(let ((tramp-auto-save-directory tmp-name2))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(setq buffer-file-name tmp-name1)
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(make-auto-save-file-name)
|
|
|
|
|
;; This is taken from Tramp.
|
|
|
|
|
(expand-file-name
|
|
|
|
|
(format
|
|
|
|
|
"#%s#"
|
|
|
|
|
(tramp-subst-strs-in-string
|
|
|
|
|
'(("_" . "|")
|
|
|
|
|
("/" . "_a")
|
|
|
|
|
(":" . "_b")
|
|
|
|
|
("|" . "__")
|
|
|
|
|
("[" . "_l")
|
|
|
|
|
("]" . "_r"))
|
2016-12-09 19:54:20 +01:00
|
|
|
|
(tramp-compat-file-name-unquote tmp-name1)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
tmp-name2)))
|
|
|
|
|
(should (file-directory-p tmp-name2))))
|
|
|
|
|
|
|
|
|
|
;; Relative file names shall work, too.
|
|
|
|
|
(let ((tramp-auto-save-directory "."))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(setq buffer-file-name tmp-name1
|
|
|
|
|
default-directory tmp-name2)
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(make-auto-save-file-name)
|
|
|
|
|
;; This is taken from Tramp.
|
|
|
|
|
(expand-file-name
|
|
|
|
|
(format
|
|
|
|
|
"#%s#"
|
|
|
|
|
(tramp-subst-strs-in-string
|
|
|
|
|
'(("_" . "|")
|
|
|
|
|
("/" . "_a")
|
|
|
|
|
(":" . "_b")
|
|
|
|
|
("|" . "__")
|
|
|
|
|
("[" . "_l")
|
|
|
|
|
("]" . "_r"))
|
2016-12-09 19:54:20 +01:00
|
|
|
|
(tramp-compat-file-name-unquote tmp-name1)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
tmp-name2)))
|
|
|
|
|
(should (file-directory-p tmp-name2)))))
|
2015-05-27 15:48:13 +02:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-file tmp-name1))
|
|
|
|
|
(ignore-errors (delete-directory tmp-name2 'recursive))))))
|
2015-05-27 15:48:13 +02:00
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test38-find-backup-file-name ()
|
2017-10-26 16:24:28 +02:00
|
|
|
|
"Check `find-backup-file-name'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
|
|
|
|
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
|
2017-10-26 16:24:28 +02:00
|
|
|
|
(let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name2 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
;; These settings are not used by Tramp, so we ignore them.
|
|
|
|
|
version-control delete-old-versions
|
|
|
|
|
(kept-old-versions (default-toplevel-value 'kept-old-versions))
|
|
|
|
|
(kept-new-versions (default-toplevel-value 'kept-new-versions)))
|
|
|
|
|
|
|
|
|
|
(unwind-protect
|
|
|
|
|
;; Use default `backup-directory-alist' mechanism.
|
|
|
|
|
(let (backup-directory-alist tramp-backup-directory-alist)
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(find-backup-file-name tmp-name1)
|
|
|
|
|
(list
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-quote #'identity)
|
2017-10-26 16:24:28 +02:00
|
|
|
|
(expand-file-name
|
|
|
|
|
(format "%s~" (file-name-nondirectory tmp-name1))
|
|
|
|
|
tramp-test-temporary-file-directory)))))))
|
|
|
|
|
|
|
|
|
|
(unwind-protect
|
|
|
|
|
;; Map `backup-directory-alist'.
|
|
|
|
|
(let ((backup-directory-alist `(("." . ,tmp-name2)))
|
|
|
|
|
tramp-backup-directory-alist)
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(find-backup-file-name tmp-name1)
|
|
|
|
|
(list
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-quote #'identity)
|
2017-10-26 16:24:28 +02:00
|
|
|
|
(expand-file-name
|
|
|
|
|
(format
|
|
|
|
|
"%s~"
|
2018-01-07 18:50:06 +01:00
|
|
|
|
;; This is taken from `make-backup-file-name-1'. We
|
|
|
|
|
;; call `convert-standard-filename', because on MS
|
|
|
|
|
;; Windows the (local) colons must be replaced by
|
|
|
|
|
;; exclamation marks.
|
2017-10-26 16:24:28 +02:00
|
|
|
|
(subst-char-in-string
|
2018-01-07 18:50:06 +01:00
|
|
|
|
?/ ?!
|
|
|
|
|
(replace-regexp-in-string
|
|
|
|
|
"!" "!!" (convert-standard-filename tmp-name1))))
|
2017-10-26 16:24:28 +02:00
|
|
|
|
tmp-name2)))))
|
|
|
|
|
;; The backup directory is created.
|
|
|
|
|
(should (file-directory-p tmp-name2)))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-directory tmp-name2 'recursive)))
|
|
|
|
|
|
|
|
|
|
(unwind-protect
|
|
|
|
|
;; Map `tramp-backup-directory-alist'.
|
|
|
|
|
(let ((tramp-backup-directory-alist `(("." . ,tmp-name2)))
|
|
|
|
|
backup-directory-alist)
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(find-backup-file-name tmp-name1)
|
|
|
|
|
(list
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-quote #'identity)
|
2017-10-26 16:24:28 +02:00
|
|
|
|
(expand-file-name
|
|
|
|
|
(format
|
|
|
|
|
"%s~"
|
2018-01-07 18:50:06 +01:00
|
|
|
|
;; This is taken from `make-backup-file-name-1'. We
|
|
|
|
|
;; call `convert-standard-filename', because on MS
|
|
|
|
|
;; Windows the (local) colons must be replaced by
|
|
|
|
|
;; exclamation marks.
|
2017-10-26 16:24:28 +02:00
|
|
|
|
(subst-char-in-string
|
2018-01-07 18:50:06 +01:00
|
|
|
|
?/ ?!
|
|
|
|
|
(replace-regexp-in-string
|
|
|
|
|
"!" "!!" (convert-standard-filename tmp-name1))))
|
2017-10-26 16:24:28 +02:00
|
|
|
|
tmp-name2)))))
|
|
|
|
|
;; The backup directory is created.
|
|
|
|
|
(should (file-directory-p tmp-name2)))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-directory tmp-name2 'recursive)))
|
|
|
|
|
|
|
|
|
|
(unwind-protect
|
|
|
|
|
;; Map `tramp-backup-directory-alist' with local file name.
|
|
|
|
|
(let ((tramp-backup-directory-alist
|
|
|
|
|
`(("." . ,(file-remote-p tmp-name2 'localname))))
|
|
|
|
|
backup-directory-alist)
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(find-backup-file-name tmp-name1)
|
|
|
|
|
(list
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-quote #'identity)
|
2017-10-26 16:24:28 +02:00
|
|
|
|
(expand-file-name
|
|
|
|
|
(format
|
|
|
|
|
"%s~"
|
2018-01-07 18:50:06 +01:00
|
|
|
|
;; This is taken from `make-backup-file-name-1'. We
|
|
|
|
|
;; call `convert-standard-filename', because on MS
|
|
|
|
|
;; Windows the (local) colons must be replaced by
|
|
|
|
|
;; exclamation marks.
|
2017-10-26 16:24:28 +02:00
|
|
|
|
(subst-char-in-string
|
2018-01-07 18:50:06 +01:00
|
|
|
|
?/ ?!
|
|
|
|
|
(replace-regexp-in-string
|
|
|
|
|
"!" "!!" (convert-standard-filename tmp-name1))))
|
2017-10-26 16:24:28 +02:00
|
|
|
|
tmp-name2)))))
|
|
|
|
|
;; The backup directory is created.
|
|
|
|
|
(should (file-directory-p tmp-name2)))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-directory tmp-name2 'recursive))))))
|
|
|
|
|
|
2016-11-17 22:50:40 -08:00
|
|
|
|
;; The functions were introduced in Emacs 26.1.
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test39-make-nearby-temp-file ()
|
Add `make-nearby-temp-file' and `temporary-file-directory'
* doc/lispref/files.texi (Unique File Names):
Introduce `make-nearby-temp-file' and `temporary-file-directory'.
(Magic File Names): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* etc/NEWS (provided): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* lisp/files.el (mounted-file-systems): New defcustom.
(temporary-file-directory, make-nearby-temp-file): New defuns.
(normal-backup-enable-predicate): Fix docstring.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
<make-nearby-temp-file, temporary-file-directory>: Add handler.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `make-nearby-temp-file' and `temporary-file-directory'.
(tramp-get-remote-tmpdir): Remove compatibility code.
(tramp-handle-temporary-file-directory)
(tramp-handle-make-nearby-temp-file): New defuns.
* lisp/org/ob-core.el (org-babel-local-file-name):
* lisp/progmodes/gud.el (gud-common-init):
* lisp/vc/vc-hooks.el (vc-user-login-name): Use `file-remote-p'.
* lisp/vc/vc-git.el (vc-git-checkin): Handle remote log message.
* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name):
Check `tramp--test-enabled'.
(tramp-test18-file-attributes): Add tests for
`file-ownership-preserved-p'.
(tramp-test27-start-file-process, tramp-test28-shell-command):
Reduce timeouts in `accept-process-output'.
(tramp-test--shell-command-to-string-asynchronously): Add timeout.
(tramp-test29-environment-variables): Remove additional sleep calls.
(tramp-test32-make-nearby-temp-file): New test.
(tramp--test-special-characters, tramp--test-utf8): Adapt docstring.
(tramp-test33-special-characters)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls, tramp-test34-utf8)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests)
(tramp-test36-recursive-load, tramp-test37-unload): Rename.
(tramp--test-ftp-p): Simplify check.
(tramp--test-sh-p): New defun.
(tramp-test20-file-modes, tramp-test22-file-times)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command)
(tramp-test29-environment-variables)
(tramp-test30-vc-registered)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests): Use it.
2016-08-07 13:57:23 +02:00
|
|
|
|
"Check `make-nearby-temp-file' and `temporary-file-directory'."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2017-07-31 14:32:24 +02:00
|
|
|
|
;; Since Emacs 26.1.
|
2016-08-10 12:10:26 +02:00
|
|
|
|
(skip-unless
|
|
|
|
|
(and (fboundp 'make-nearby-temp-file) (fboundp 'temporary-file-directory)))
|
Add `make-nearby-temp-file' and `temporary-file-directory'
* doc/lispref/files.texi (Unique File Names):
Introduce `make-nearby-temp-file' and `temporary-file-directory'.
(Magic File Names): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* etc/NEWS (provided): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* lisp/files.el (mounted-file-systems): New defcustom.
(temporary-file-directory, make-nearby-temp-file): New defuns.
(normal-backup-enable-predicate): Fix docstring.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
<make-nearby-temp-file, temporary-file-directory>: Add handler.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `make-nearby-temp-file' and `temporary-file-directory'.
(tramp-get-remote-tmpdir): Remove compatibility code.
(tramp-handle-temporary-file-directory)
(tramp-handle-make-nearby-temp-file): New defuns.
* lisp/org/ob-core.el (org-babel-local-file-name):
* lisp/progmodes/gud.el (gud-common-init):
* lisp/vc/vc-hooks.el (vc-user-login-name): Use `file-remote-p'.
* lisp/vc/vc-git.el (vc-git-checkin): Handle remote log message.
* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name):
Check `tramp--test-enabled'.
(tramp-test18-file-attributes): Add tests for
`file-ownership-preserved-p'.
(tramp-test27-start-file-process, tramp-test28-shell-command):
Reduce timeouts in `accept-process-output'.
(tramp-test--shell-command-to-string-asynchronously): Add timeout.
(tramp-test29-environment-variables): Remove additional sleep calls.
(tramp-test32-make-nearby-temp-file): New test.
(tramp--test-special-characters, tramp--test-utf8): Adapt docstring.
(tramp-test33-special-characters)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls, tramp-test34-utf8)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests)
(tramp-test36-recursive-load, tramp-test37-unload): Rename.
(tramp--test-ftp-p): Simplify check.
(tramp--test-sh-p): New defun.
(tramp-test20-file-modes, tramp-test22-file-times)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command)
(tramp-test29-environment-variables)
(tramp-test30-vc-registered)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests): Use it.
2016-08-07 13:57:23 +02:00
|
|
|
|
|
2017-03-23 14:58:04 +01:00
|
|
|
|
;; `make-nearby-temp-file' and `temporary-file-directory' exists
|
2017-11-14 10:21:55 +01:00
|
|
|
|
;; since Emacs 26.1. We don't want to see compiler warnings for
|
|
|
|
|
;; older Emacsen.
|
Add `make-nearby-temp-file' and `temporary-file-directory'
* doc/lispref/files.texi (Unique File Names):
Introduce `make-nearby-temp-file' and `temporary-file-directory'.
(Magic File Names): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* etc/NEWS (provided): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* lisp/files.el (mounted-file-systems): New defcustom.
(temporary-file-directory, make-nearby-temp-file): New defuns.
(normal-backup-enable-predicate): Fix docstring.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
<make-nearby-temp-file, temporary-file-directory>: Add handler.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `make-nearby-temp-file' and `temporary-file-directory'.
(tramp-get-remote-tmpdir): Remove compatibility code.
(tramp-handle-temporary-file-directory)
(tramp-handle-make-nearby-temp-file): New defuns.
* lisp/org/ob-core.el (org-babel-local-file-name):
* lisp/progmodes/gud.el (gud-common-init):
* lisp/vc/vc-hooks.el (vc-user-login-name): Use `file-remote-p'.
* lisp/vc/vc-git.el (vc-git-checkin): Handle remote log message.
* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name):
Check `tramp--test-enabled'.
(tramp-test18-file-attributes): Add tests for
`file-ownership-preserved-p'.
(tramp-test27-start-file-process, tramp-test28-shell-command):
Reduce timeouts in `accept-process-output'.
(tramp-test--shell-command-to-string-asynchronously): Add timeout.
(tramp-test29-environment-variables): Remove additional sleep calls.
(tramp-test32-make-nearby-temp-file): New test.
(tramp--test-special-characters, tramp--test-utf8): Adapt docstring.
(tramp-test33-special-characters)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls, tramp-test34-utf8)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests)
(tramp-test36-recursive-load, tramp-test37-unload): Rename.
(tramp--test-ftp-p): Simplify check.
(tramp--test-sh-p): New defun.
(tramp-test20-file-modes, tramp-test22-file-times)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command)
(tramp-test29-environment-variables)
(tramp-test30-vc-registered)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests): Use it.
2016-08-07 13:57:23 +02:00
|
|
|
|
(let ((default-directory tramp-test-temporary-file-directory)
|
|
|
|
|
tmp-file)
|
2016-08-21 04:17:30 -07:00
|
|
|
|
;; The remote host shall know a temporary file directory.
|
2017-03-23 14:58:04 +01:00
|
|
|
|
(should (stringp (with-no-warnings (temporary-file-directory))))
|
Add `make-nearby-temp-file' and `temporary-file-directory'
* doc/lispref/files.texi (Unique File Names):
Introduce `make-nearby-temp-file' and `temporary-file-directory'.
(Magic File Names): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* etc/NEWS (provided): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* lisp/files.el (mounted-file-systems): New defcustom.
(temporary-file-directory, make-nearby-temp-file): New defuns.
(normal-backup-enable-predicate): Fix docstring.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
<make-nearby-temp-file, temporary-file-directory>: Add handler.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `make-nearby-temp-file' and `temporary-file-directory'.
(tramp-get-remote-tmpdir): Remove compatibility code.
(tramp-handle-temporary-file-directory)
(tramp-handle-make-nearby-temp-file): New defuns.
* lisp/org/ob-core.el (org-babel-local-file-name):
* lisp/progmodes/gud.el (gud-common-init):
* lisp/vc/vc-hooks.el (vc-user-login-name): Use `file-remote-p'.
* lisp/vc/vc-git.el (vc-git-checkin): Handle remote log message.
* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name):
Check `tramp--test-enabled'.
(tramp-test18-file-attributes): Add tests for
`file-ownership-preserved-p'.
(tramp-test27-start-file-process, tramp-test28-shell-command):
Reduce timeouts in `accept-process-output'.
(tramp-test--shell-command-to-string-asynchronously): Add timeout.
(tramp-test29-environment-variables): Remove additional sleep calls.
(tramp-test32-make-nearby-temp-file): New test.
(tramp--test-special-characters, tramp--test-utf8): Adapt docstring.
(tramp-test33-special-characters)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls, tramp-test34-utf8)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests)
(tramp-test36-recursive-load, tramp-test37-unload): Rename.
(tramp--test-ftp-p): Simplify check.
(tramp--test-sh-p): New defun.
(tramp-test20-file-modes, tramp-test22-file-times)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command)
(tramp-test29-environment-variables)
(tramp-test30-vc-registered)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests): Use it.
2016-08-07 13:57:23 +02:00
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p default-directory)
|
2017-03-23 14:58:04 +01:00
|
|
|
|
(file-remote-p (with-no-warnings (temporary-file-directory)))))
|
Add `make-nearby-temp-file' and `temporary-file-directory'
* doc/lispref/files.texi (Unique File Names):
Introduce `make-nearby-temp-file' and `temporary-file-directory'.
(Magic File Names): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* etc/NEWS (provided): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* lisp/files.el (mounted-file-systems): New defcustom.
(temporary-file-directory, make-nearby-temp-file): New defuns.
(normal-backup-enable-predicate): Fix docstring.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
<make-nearby-temp-file, temporary-file-directory>: Add handler.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `make-nearby-temp-file' and `temporary-file-directory'.
(tramp-get-remote-tmpdir): Remove compatibility code.
(tramp-handle-temporary-file-directory)
(tramp-handle-make-nearby-temp-file): New defuns.
* lisp/org/ob-core.el (org-babel-local-file-name):
* lisp/progmodes/gud.el (gud-common-init):
* lisp/vc/vc-hooks.el (vc-user-login-name): Use `file-remote-p'.
* lisp/vc/vc-git.el (vc-git-checkin): Handle remote log message.
* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name):
Check `tramp--test-enabled'.
(tramp-test18-file-attributes): Add tests for
`file-ownership-preserved-p'.
(tramp-test27-start-file-process, tramp-test28-shell-command):
Reduce timeouts in `accept-process-output'.
(tramp-test--shell-command-to-string-asynchronously): Add timeout.
(tramp-test29-environment-variables): Remove additional sleep calls.
(tramp-test32-make-nearby-temp-file): New test.
(tramp--test-special-characters, tramp--test-utf8): Adapt docstring.
(tramp-test33-special-characters)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls, tramp-test34-utf8)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests)
(tramp-test36-recursive-load, tramp-test37-unload): Rename.
(tramp--test-ftp-p): Simplify check.
(tramp--test-sh-p): New defun.
(tramp-test20-file-modes, tramp-test22-file-times)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command)
(tramp-test29-environment-variables)
(tramp-test30-vc-registered)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests): Use it.
2016-08-07 13:57:23 +02:00
|
|
|
|
|
|
|
|
|
;; The temporary file shall be located on the remote host.
|
2017-03-23 14:58:04 +01:00
|
|
|
|
(setq tmp-file (with-no-warnings (make-nearby-temp-file "tramp-test")))
|
Add `make-nearby-temp-file' and `temporary-file-directory'
* doc/lispref/files.texi (Unique File Names):
Introduce `make-nearby-temp-file' and `temporary-file-directory'.
(Magic File Names): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* etc/NEWS (provided): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* lisp/files.el (mounted-file-systems): New defcustom.
(temporary-file-directory, make-nearby-temp-file): New defuns.
(normal-backup-enable-predicate): Fix docstring.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
<make-nearby-temp-file, temporary-file-directory>: Add handler.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `make-nearby-temp-file' and `temporary-file-directory'.
(tramp-get-remote-tmpdir): Remove compatibility code.
(tramp-handle-temporary-file-directory)
(tramp-handle-make-nearby-temp-file): New defuns.
* lisp/org/ob-core.el (org-babel-local-file-name):
* lisp/progmodes/gud.el (gud-common-init):
* lisp/vc/vc-hooks.el (vc-user-login-name): Use `file-remote-p'.
* lisp/vc/vc-git.el (vc-git-checkin): Handle remote log message.
* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name):
Check `tramp--test-enabled'.
(tramp-test18-file-attributes): Add tests for
`file-ownership-preserved-p'.
(tramp-test27-start-file-process, tramp-test28-shell-command):
Reduce timeouts in `accept-process-output'.
(tramp-test--shell-command-to-string-asynchronously): Add timeout.
(tramp-test29-environment-variables): Remove additional sleep calls.
(tramp-test32-make-nearby-temp-file): New test.
(tramp--test-special-characters, tramp--test-utf8): Adapt docstring.
(tramp-test33-special-characters)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls, tramp-test34-utf8)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests)
(tramp-test36-recursive-load, tramp-test37-unload): Rename.
(tramp--test-ftp-p): Simplify check.
(tramp--test-sh-p): New defun.
(tramp-test20-file-modes, tramp-test22-file-times)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command)
(tramp-test29-environment-variables)
(tramp-test30-vc-registered)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests): Use it.
2016-08-07 13:57:23 +02:00
|
|
|
|
(should (file-exists-p tmp-file))
|
|
|
|
|
(should (file-regular-p tmp-file))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(file-remote-p default-directory)
|
|
|
|
|
(file-remote-p tmp-file)))
|
|
|
|
|
(delete-file tmp-file)
|
|
|
|
|
(should-not (file-exists-p tmp-file))
|
|
|
|
|
|
2017-03-23 14:58:04 +01:00
|
|
|
|
(setq tmp-file (with-no-warnings (make-nearby-temp-file "tramp-test" 'dir)))
|
Add `make-nearby-temp-file' and `temporary-file-directory'
* doc/lispref/files.texi (Unique File Names):
Introduce `make-nearby-temp-file' and `temporary-file-directory'.
(Magic File Names): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* etc/NEWS (provided): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* lisp/files.el (mounted-file-systems): New defcustom.
(temporary-file-directory, make-nearby-temp-file): New defuns.
(normal-backup-enable-predicate): Fix docstring.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
<make-nearby-temp-file, temporary-file-directory>: Add handler.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `make-nearby-temp-file' and `temporary-file-directory'.
(tramp-get-remote-tmpdir): Remove compatibility code.
(tramp-handle-temporary-file-directory)
(tramp-handle-make-nearby-temp-file): New defuns.
* lisp/org/ob-core.el (org-babel-local-file-name):
* lisp/progmodes/gud.el (gud-common-init):
* lisp/vc/vc-hooks.el (vc-user-login-name): Use `file-remote-p'.
* lisp/vc/vc-git.el (vc-git-checkin): Handle remote log message.
* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name):
Check `tramp--test-enabled'.
(tramp-test18-file-attributes): Add tests for
`file-ownership-preserved-p'.
(tramp-test27-start-file-process, tramp-test28-shell-command):
Reduce timeouts in `accept-process-output'.
(tramp-test--shell-command-to-string-asynchronously): Add timeout.
(tramp-test29-environment-variables): Remove additional sleep calls.
(tramp-test32-make-nearby-temp-file): New test.
(tramp--test-special-characters, tramp--test-utf8): Adapt docstring.
(tramp-test33-special-characters)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls, tramp-test34-utf8)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests)
(tramp-test36-recursive-load, tramp-test37-unload): Rename.
(tramp--test-ftp-p): Simplify check.
(tramp--test-sh-p): New defun.
(tramp-test20-file-modes, tramp-test22-file-times)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command)
(tramp-test29-environment-variables)
(tramp-test30-vc-registered)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests): Use it.
2016-08-07 13:57:23 +02:00
|
|
|
|
(should (file-exists-p tmp-file))
|
|
|
|
|
(should (file-directory-p tmp-file))
|
|
|
|
|
(delete-directory tmp-file)
|
|
|
|
|
(should-not (file-exists-p tmp-file))))
|
|
|
|
|
|
2018-06-03 14:30:41 +02:00
|
|
|
|
(defun tramp--test-emacs25-p ()
|
|
|
|
|
"Check for Emacs version >= 25.1.
|
|
|
|
|
Some semantics has been changed for there, w/o new functions or
|
|
|
|
|
variables, so we check the Emacs version directly."
|
|
|
|
|
(>= emacs-major-version 25))
|
|
|
|
|
|
2017-09-13 20:10:40 +02:00
|
|
|
|
(defun tramp--test-emacs26-p ()
|
|
|
|
|
"Check for Emacs version >= 26.1.
|
|
|
|
|
Some semantics has been changed for there, w/o new functions or
|
2017-10-23 12:46:32 +02:00
|
|
|
|
variables, so we check the Emacs version directly."
|
2017-09-13 20:10:40 +02:00
|
|
|
|
(>= emacs-major-version 26))
|
|
|
|
|
|
2018-02-01 15:49:18 +01:00
|
|
|
|
(defun tramp--test-emacs27-p ()
|
|
|
|
|
"Check for Emacs version >= 27.1.
|
|
|
|
|
Some semantics has been changed for there, w/o new functions or
|
|
|
|
|
variables, so we check the Emacs version directly."
|
|
|
|
|
(>= emacs-major-version 27))
|
|
|
|
|
|
2015-03-04 11:46:06 +01:00
|
|
|
|
(defun tramp--test-adb-p ()
|
|
|
|
|
"Check, whether the remote host runs Android.
|
|
|
|
|
This requires restrictions of file name syntax."
|
2015-07-21 14:59:18 +02:00
|
|
|
|
(tramp-adb-file-name-p tramp-test-temporary-file-directory))
|
|
|
|
|
|
2016-12-12 11:12:34 +01:00
|
|
|
|
(defun tramp--test-docker-p ()
|
|
|
|
|
"Check, whether the docker method is used.
|
|
|
|
|
This does not support some special file names."
|
|
|
|
|
(string-equal
|
|
|
|
|
"docker" (file-remote-p tramp-test-temporary-file-directory 'method)))
|
|
|
|
|
|
2015-07-21 14:59:18 +02:00
|
|
|
|
(defun tramp--test-ftp-p ()
|
|
|
|
|
"Check, whether an FTP-like method is used.
|
|
|
|
|
This does not support globbing characters in file names (yet)."
|
|
|
|
|
;; Globbing characters are ??, ?* and ?\[.
|
Add `make-nearby-temp-file' and `temporary-file-directory'
* doc/lispref/files.texi (Unique File Names):
Introduce `make-nearby-temp-file' and `temporary-file-directory'.
(Magic File Names): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* etc/NEWS (provided): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* lisp/files.el (mounted-file-systems): New defcustom.
(temporary-file-directory, make-nearby-temp-file): New defuns.
(normal-backup-enable-predicate): Fix docstring.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
<make-nearby-temp-file, temporary-file-directory>: Add handler.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `make-nearby-temp-file' and `temporary-file-directory'.
(tramp-get-remote-tmpdir): Remove compatibility code.
(tramp-handle-temporary-file-directory)
(tramp-handle-make-nearby-temp-file): New defuns.
* lisp/org/ob-core.el (org-babel-local-file-name):
* lisp/progmodes/gud.el (gud-common-init):
* lisp/vc/vc-hooks.el (vc-user-login-name): Use `file-remote-p'.
* lisp/vc/vc-git.el (vc-git-checkin): Handle remote log message.
* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name):
Check `tramp--test-enabled'.
(tramp-test18-file-attributes): Add tests for
`file-ownership-preserved-p'.
(tramp-test27-start-file-process, tramp-test28-shell-command):
Reduce timeouts in `accept-process-output'.
(tramp-test--shell-command-to-string-asynchronously): Add timeout.
(tramp-test29-environment-variables): Remove additional sleep calls.
(tramp-test32-make-nearby-temp-file): New test.
(tramp--test-special-characters, tramp--test-utf8): Adapt docstring.
(tramp-test33-special-characters)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls, tramp-test34-utf8)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests)
(tramp-test36-recursive-load, tramp-test37-unload): Rename.
(tramp--test-ftp-p): Simplify check.
(tramp--test-sh-p): New defun.
(tramp-test20-file-modes, tramp-test22-file-times)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command)
(tramp-test29-environment-variables)
(tramp-test30-vc-registered)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests): Use it.
2016-08-07 13:57:23 +02:00
|
|
|
|
(string-match
|
|
|
|
|
"ftp$" (file-remote-p tramp-test-temporary-file-directory 'method)))
|
|
|
|
|
|
2017-06-05 12:59:26 +02:00
|
|
|
|
(defun tramp--test-gvfs-p (&optional method)
|
Add `make-nearby-temp-file' and `temporary-file-directory'
* doc/lispref/files.texi (Unique File Names):
Introduce `make-nearby-temp-file' and `temporary-file-directory'.
(Magic File Names): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* etc/NEWS (provided): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* lisp/files.el (mounted-file-systems): New defcustom.
(temporary-file-directory, make-nearby-temp-file): New defuns.
(normal-backup-enable-predicate): Fix docstring.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
<make-nearby-temp-file, temporary-file-directory>: Add handler.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `make-nearby-temp-file' and `temporary-file-directory'.
(tramp-get-remote-tmpdir): Remove compatibility code.
(tramp-handle-temporary-file-directory)
(tramp-handle-make-nearby-temp-file): New defuns.
* lisp/org/ob-core.el (org-babel-local-file-name):
* lisp/progmodes/gud.el (gud-common-init):
* lisp/vc/vc-hooks.el (vc-user-login-name): Use `file-remote-p'.
* lisp/vc/vc-git.el (vc-git-checkin): Handle remote log message.
* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name):
Check `tramp--test-enabled'.
(tramp-test18-file-attributes): Add tests for
`file-ownership-preserved-p'.
(tramp-test27-start-file-process, tramp-test28-shell-command):
Reduce timeouts in `accept-process-output'.
(tramp-test--shell-command-to-string-asynchronously): Add timeout.
(tramp-test29-environment-variables): Remove additional sleep calls.
(tramp-test32-make-nearby-temp-file): New test.
(tramp--test-special-characters, tramp--test-utf8): Adapt docstring.
(tramp-test33-special-characters)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls, tramp-test34-utf8)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests)
(tramp-test36-recursive-load, tramp-test37-unload): Rename.
(tramp--test-ftp-p): Simplify check.
(tramp--test-sh-p): New defun.
(tramp-test20-file-modes, tramp-test22-file-times)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command)
(tramp-test29-environment-variables)
(tramp-test30-vc-registered)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests): Use it.
2016-08-07 13:57:23 +02:00
|
|
|
|
"Check, whether the remote host runs a GVFS based method.
|
|
|
|
|
This requires restrictions of file name syntax."
|
2017-06-05 12:59:26 +02:00
|
|
|
|
(or (member method tramp-gvfs-methods)
|
|
|
|
|
(tramp-gvfs-file-name-p tramp-test-temporary-file-directory)))
|
2015-07-21 14:59:18 +02:00
|
|
|
|
|
2016-12-17 19:52:38 +01:00
|
|
|
|
(defun tramp--test-hpux-p ()
|
|
|
|
|
"Check, whether the remote host runs HP-UX.
|
|
|
|
|
Several special characters do not work properly there."
|
|
|
|
|
;; We must refill the cache. `file-truename' does it.
|
|
|
|
|
(with-parsed-tramp-file-name
|
|
|
|
|
(file-truename tramp-test-temporary-file-directory) nil
|
|
|
|
|
(string-match "^HP-UX" (tramp-get-connection-property v "uname" ""))))
|
|
|
|
|
|
2019-09-26 09:33:47 +02:00
|
|
|
|
(defun tramp--test-ksh-p ()
|
|
|
|
|
"Check, whether the remote shell is ksh.
|
|
|
|
|
ksh93 makes some strange conversions of non-latin characters into
|
|
|
|
|
a $'' syntax."
|
|
|
|
|
;; We must refill the cache. `file-truename' does it.
|
|
|
|
|
(with-parsed-tramp-file-name
|
|
|
|
|
(file-truename tramp-test-temporary-file-directory) nil
|
|
|
|
|
(string-match "ksh$" (tramp-get-connection-property v "remote-shell" ""))))
|
|
|
|
|
|
2017-11-27 13:31:53 +01:00
|
|
|
|
(defun tramp--test-mock-p ()
|
|
|
|
|
"Check, whether the mock method is used.
|
|
|
|
|
This does not support external Emacs calls."
|
|
|
|
|
(string-equal
|
|
|
|
|
"mock" (file-remote-p tramp-test-temporary-file-directory 'method)))
|
|
|
|
|
|
2018-08-04 12:05:28 +02:00
|
|
|
|
(defun tramp--test-nextcloud-p ()
|
|
|
|
|
"Check, whether the nextcloud method is used."
|
Add new Tramp connection method "owncloud"
* doc/misc/tramp.texi (all): Use @acronym{GNOME} thoroughly.
(Using GNOME Online Accounts based methods): Rename from
"Using Google Drive". Add `owncloud'.
(GVFS based methods): Add `owncloud'.
* etc/NEWS: Add Tramp connection method "owncloud".
* lisp/net/tramp-gvfs.el (tramp-gvfs-methods): Add "owncloud".
Remove goa methods if not supported.
(tramp-goa-methods, tramp-goa-service, tramp-goa-path)
(tramp-goa-path-accounts, tramp-goa-interface-documents)
(tramp-goa-interface-printers, tramp-goa-interface-files)
(tramp-goa-interface-contacts, tramp-goa-interface-calendar)
(tramp-goa-interface-oauth2based)
(tramp-goa-interface-account, tramp-goa-identity-regexp)
(tramp-goa-interface-mail, tramp-goa-interface-chat)
(tramp-goa-interface-photos, tramp-goa-path-manager)
(tramp-goa-interface-documents)
(tramp-gvfs-owncloud-default-prefix)
(tramp-gvfs-owncloud-default-prefix-regexp): New defconst.
(tramp-goa-name): New defstruct.
(tramp-gvfs-stringify-dbus-message): Handle all consp messages.
(tramp-dbus-function, tramp-gvfs-get-remote-prefix)
(tramp-get-goa-accounts): New defun.
(with-tramp-dbus-call-method): Use it.
(with-tramp-dbus-get-all-properties): New defmacro.
(tramp-gvfs-url-file-name)
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p, tramp-gvfs-mount-spec):
Map between "owncloud" and "davs".
(tramp-gvfs-maybe-open-connection): Set "vector" connection property.
* test/lisp/net/tramp-tests.el (tramp-gvfs-handler-askquestion):
Suppress run in tests.
(tramp--test-owncloud-p): New defun.
(tramp-test11-copy-file, tramp-test12-rename-file): Use it.
2018-01-05 21:04:39 +01:00
|
|
|
|
(string-equal
|
2018-08-04 12:05:28 +02:00
|
|
|
|
"nextcloud" (file-remote-p tramp-test-temporary-file-directory 'method)))
|
Add new Tramp connection method "owncloud"
* doc/misc/tramp.texi (all): Use @acronym{GNOME} thoroughly.
(Using GNOME Online Accounts based methods): Rename from
"Using Google Drive". Add `owncloud'.
(GVFS based methods): Add `owncloud'.
* etc/NEWS: Add Tramp connection method "owncloud".
* lisp/net/tramp-gvfs.el (tramp-gvfs-methods): Add "owncloud".
Remove goa methods if not supported.
(tramp-goa-methods, tramp-goa-service, tramp-goa-path)
(tramp-goa-path-accounts, tramp-goa-interface-documents)
(tramp-goa-interface-printers, tramp-goa-interface-files)
(tramp-goa-interface-contacts, tramp-goa-interface-calendar)
(tramp-goa-interface-oauth2based)
(tramp-goa-interface-account, tramp-goa-identity-regexp)
(tramp-goa-interface-mail, tramp-goa-interface-chat)
(tramp-goa-interface-photos, tramp-goa-path-manager)
(tramp-goa-interface-documents)
(tramp-gvfs-owncloud-default-prefix)
(tramp-gvfs-owncloud-default-prefix-regexp): New defconst.
(tramp-goa-name): New defstruct.
(tramp-gvfs-stringify-dbus-message): Handle all consp messages.
(tramp-dbus-function, tramp-gvfs-get-remote-prefix)
(tramp-get-goa-accounts): New defun.
(with-tramp-dbus-call-method): Use it.
(with-tramp-dbus-get-all-properties): New defmacro.
(tramp-gvfs-url-file-name)
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p, tramp-gvfs-mount-spec):
Map between "owncloud" and "davs".
(tramp-gvfs-maybe-open-connection): Set "vector" connection property.
* test/lisp/net/tramp-tests.el (tramp-gvfs-handler-askquestion):
Suppress run in tests.
(tramp--test-owncloud-p): New defun.
(tramp-test11-copy-file, tramp-test12-rename-file): Use it.
2018-01-05 21:04:39 +01:00
|
|
|
|
|
2018-12-06 16:11:27 +01:00
|
|
|
|
(defun tramp--test-rclone-p ()
|
|
|
|
|
"Check, whether the remote host is offered by rclone.
|
|
|
|
|
This requires restrictions of file name syntax."
|
|
|
|
|
(tramp-rclone-file-name-p tramp-test-temporary-file-directory))
|
|
|
|
|
|
2016-06-26 12:30:21 +02:00
|
|
|
|
(defun tramp--test-rsync-p ()
|
|
|
|
|
"Check, whether the rsync method is used.
|
|
|
|
|
This does not support special file names."
|
|
|
|
|
(string-equal
|
|
|
|
|
"rsync" (file-remote-p tramp-test-temporary-file-directory 'method)))
|
|
|
|
|
|
Add `make-nearby-temp-file' and `temporary-file-directory'
* doc/lispref/files.texi (Unique File Names):
Introduce `make-nearby-temp-file' and `temporary-file-directory'.
(Magic File Names): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* etc/NEWS (provided): Mention `make-nearby-temp-file' and
`temporary-file-directory'.
* lisp/files.el (mounted-file-systems): New defcustom.
(temporary-file-directory, make-nearby-temp-file): New defuns.
(normal-backup-enable-predicate): Fix docstring.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
<make-nearby-temp-file, temporary-file-directory>: Add handler.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `make-nearby-temp-file' and `temporary-file-directory'.
(tramp-get-remote-tmpdir): Remove compatibility code.
(tramp-handle-temporary-file-directory)
(tramp-handle-make-nearby-temp-file): New defuns.
* lisp/org/ob-core.el (org-babel-local-file-name):
* lisp/progmodes/gud.el (gud-common-init):
* lisp/vc/vc-hooks.el (vc-user-login-name): Use `file-remote-p'.
* lisp/vc/vc-git.el (vc-git-checkin): Handle remote log message.
* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name):
Check `tramp--test-enabled'.
(tramp-test18-file-attributes): Add tests for
`file-ownership-preserved-p'.
(tramp-test27-start-file-process, tramp-test28-shell-command):
Reduce timeouts in `accept-process-output'.
(tramp-test--shell-command-to-string-asynchronously): Add timeout.
(tramp-test29-environment-variables): Remove additional sleep calls.
(tramp-test32-make-nearby-temp-file): New test.
(tramp--test-special-characters, tramp--test-utf8): Adapt docstring.
(tramp-test33-special-characters)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls, tramp-test34-utf8)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests)
(tramp-test36-recursive-load, tramp-test37-unload): Rename.
(tramp--test-ftp-p): Simplify check.
(tramp--test-sh-p): New defun.
(tramp-test20-file-modes, tramp-test22-file-times)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command)
(tramp-test29-environment-variables)
(tramp-test30-vc-registered)
(tramp-test33-special-characters-with-stat)
(tramp-test33-special-characters-with-perl)
(tramp-test33-special-characters-with-ls)
(tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl)
(tramp-test34-utf8-with-ls)
(tramp-test35-asynchronous-requests): Use it.
2016-08-07 13:57:23 +02:00
|
|
|
|
(defun tramp--test-sh-p ()
|
|
|
|
|
"Check, whether the remote host runs a based method from tramp-sh.el."
|
|
|
|
|
(eq
|
|
|
|
|
(tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
|
|
|
|
|
'tramp-sh-file-name-handler))
|
2015-03-04 11:46:06 +01:00
|
|
|
|
|
2018-12-16 15:49:07 +01:00
|
|
|
|
(defun tramp--test-sudoedit-p ()
|
|
|
|
|
"Check, whether the sudoedit method is used."
|
|
|
|
|
(tramp-sudoedit-file-name-p tramp-test-temporary-file-directory))
|
|
|
|
|
|
2018-01-07 18:50:06 +01:00
|
|
|
|
(defun tramp--test-windows-nt ()
|
|
|
|
|
"Check, whether the locale host runs MS Windows."
|
|
|
|
|
(eq system-type 'windows-nt))
|
|
|
|
|
|
2016-12-17 19:52:38 +01:00
|
|
|
|
(defun tramp--test-windows-nt-and-batch ()
|
|
|
|
|
"Check, whether the locale host runs MS Windows in batch mode.
|
2016-12-22 10:13:46 -08:00
|
|
|
|
This does not support special characters."
|
2016-12-17 19:52:38 +01:00
|
|
|
|
(and (eq system-type 'windows-nt) noninteractive))
|
|
|
|
|
|
|
|
|
|
(defun tramp--test-windows-nt-and-pscp-psftp-p ()
|
|
|
|
|
"Check, whether the locale host runs MS Windows, and ps{cp,ftp} is used.
|
|
|
|
|
This does not support utf8 based file transfer."
|
|
|
|
|
(and (eq system-type 'windows-nt)
|
|
|
|
|
(string-match
|
|
|
|
|
(regexp-opt '("pscp" "psftp"))
|
|
|
|
|
(file-remote-p tramp-test-temporary-file-directory 'method))))
|
|
|
|
|
|
|
|
|
|
(defun tramp--test-windows-nt-or-smb-p ()
|
2014-12-30 12:45:48 +01:00
|
|
|
|
"Check, whether the locale or remote host runs MS Windows.
|
|
|
|
|
This requires restrictions of file name syntax."
|
|
|
|
|
(or (eq system-type 'windows-nt)
|
2015-07-21 14:59:18 +02:00
|
|
|
|
(tramp-smb-file-name-p tramp-test-temporary-file-directory)))
|
2014-12-30 12:45:48 +01:00
|
|
|
|
|
2014-04-18 20:58:13 +02:00
|
|
|
|
(defun tramp--test-check-files (&rest files)
|
2015-03-04 11:46:06 +01:00
|
|
|
|
"Run a simple but comprehensive test over every file in FILES."
|
2018-02-01 15:49:18 +01:00
|
|
|
|
;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579.
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(dolist (quoted (if (and (tramp--test-expensive-test) (tramp--test-emacs27-p))
|
2017-12-06 20:49:30 +01:00
|
|
|
|
'(nil t) '(nil)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; We must use `file-truename' for the temporary directory,
|
|
|
|
|
;; because it could be located on a symlinked directory. This
|
|
|
|
|
;; would let the test fail.
|
|
|
|
|
(let* ((tramp-test-temporary-file-directory
|
|
|
|
|
(file-truename tramp-test-temporary-file-directory))
|
|
|
|
|
(tmp-name1 (tramp--test-make-temp-name nil quoted))
|
|
|
|
|
(tmp-name2 (tramp--test-make-temp-name 'local quoted))
|
2016-12-17 19:52:38 +01:00
|
|
|
|
(files (delq nil files))
|
2019-08-30 13:54:42 +02:00
|
|
|
|
(process-environment process-environment)
|
|
|
|
|
(sorted-files (sort (copy-sequence files) #'string-lessp)))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(make-directory tmp-name1)
|
|
|
|
|
(make-directory tmp-name2)
|
2016-12-17 19:52:38 +01:00
|
|
|
|
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(dolist (elt files)
|
|
|
|
|
(let* ((file1 (expand-file-name elt tmp-name1))
|
|
|
|
|
(file2 (expand-file-name elt tmp-name2))
|
|
|
|
|
(file3 (expand-file-name (concat elt "foo") tmp-name1)))
|
|
|
|
|
(write-region elt nil file1)
|
|
|
|
|
(should (file-exists-p file1))
|
|
|
|
|
|
|
|
|
|
;; Check file contents.
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents file1)
|
|
|
|
|
(should (string-equal (buffer-string) elt)))
|
|
|
|
|
|
|
|
|
|
;; Copy file both directions.
|
2017-09-10 15:39:24 -07:00
|
|
|
|
(copy-file file1 (file-name-as-directory tmp-name2))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(should (file-exists-p file2))
|
|
|
|
|
(delete-file file1)
|
|
|
|
|
(should-not (file-exists-p file1))
|
2017-09-10 15:39:24 -07:00
|
|
|
|
(copy-file file2 (file-name-as-directory tmp-name1))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(should (file-exists-p file1))
|
|
|
|
|
|
2017-08-28 18:08:16 +02:00
|
|
|
|
(tramp--test-ignore-make-symbolic-link-error
|
|
|
|
|
(make-symbolic-link file1 file3)
|
|
|
|
|
(should (file-symlink-p file3))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(expand-file-name file1) (file-truename file3)))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-quote #'identity)
|
2019-08-11 12:06:57 +02:00
|
|
|
|
(tramp-compat-file-attribute-type (file-attributes file3)))
|
2017-08-28 18:08:16 +02:00
|
|
|
|
(file-remote-p (file-truename file1) 'localname)))
|
|
|
|
|
;; Check file contents.
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents file3)
|
|
|
|
|
(should (string-equal (buffer-string) elt)))
|
|
|
|
|
(delete-file file3))))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
;; Check file names.
|
|
|
|
|
(should (equal (directory-files
|
|
|
|
|
tmp-name1 nil directory-files-no-dot-files-regexp)
|
2019-08-30 13:54:42 +02:00
|
|
|
|
sorted-files))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
(should (equal (directory-files
|
|
|
|
|
tmp-name2 nil directory-files-no-dot-files-regexp)
|
2019-08-30 13:54:42 +02:00
|
|
|
|
sorted-files))
|
|
|
|
|
(should (equal (mapcar
|
|
|
|
|
#'car
|
|
|
|
|
(directory-files-and-attributes
|
|
|
|
|
tmp-name1 nil directory-files-no-dot-files-regexp))
|
|
|
|
|
sorted-files))
|
|
|
|
|
(should (equal (mapcar
|
|
|
|
|
#'car
|
|
|
|
|
(directory-files-and-attributes
|
|
|
|
|
tmp-name2 nil directory-files-no-dot-files-regexp))
|
|
|
|
|
sorted-files))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
;; `substitute-in-file-name' could return different
|
|
|
|
|
;; values. For `adb', there could be strange file
|
|
|
|
|
;; permissions preventing overwriting a file. We don't
|
|
|
|
|
;; care in this testcase.
|
|
|
|
|
(dolist (elt files)
|
|
|
|
|
(let ((file1
|
|
|
|
|
(substitute-in-file-name (expand-file-name elt tmp-name1)))
|
|
|
|
|
(file2
|
|
|
|
|
(substitute-in-file-name
|
|
|
|
|
(expand-file-name elt tmp-name2))))
|
|
|
|
|
(ignore-errors (write-region elt nil file1))
|
|
|
|
|
(should (file-exists-p file1))
|
|
|
|
|
(ignore-errors (write-region elt nil file2 nil 'nomessage))
|
|
|
|
|
(should (file-exists-p file2))))
|
|
|
|
|
|
|
|
|
|
(should (equal (directory-files
|
|
|
|
|
tmp-name1 nil directory-files-no-dot-files-regexp)
|
|
|
|
|
(directory-files
|
|
|
|
|
tmp-name2 nil directory-files-no-dot-files-regexp)))
|
|
|
|
|
|
|
|
|
|
;; Check directory creation. We use a subdirectory "foo"
|
|
|
|
|
;; in order to avoid conflicts with previous file name tests.
|
|
|
|
|
(dolist (elt files)
|
|
|
|
|
(let* ((elt1 (concat elt "foo"))
|
|
|
|
|
(file1 (expand-file-name (concat "foo/" elt) tmp-name1))
|
|
|
|
|
(file2 (expand-file-name elt file1))
|
|
|
|
|
(file3 (expand-file-name elt1 file1)))
|
|
|
|
|
(make-directory file1 'parents)
|
|
|
|
|
(should (file-directory-p file1))
|
|
|
|
|
(write-region elt nil file2)
|
|
|
|
|
(should (file-exists-p file2))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(directory-files
|
|
|
|
|
file1 nil directory-files-no-dot-files-regexp)
|
|
|
|
|
`(,elt)))
|
|
|
|
|
(should
|
|
|
|
|
(equal
|
|
|
|
|
(caar (directory-files-and-attributes
|
|
|
|
|
file1 nil directory-files-no-dot-files-regexp))
|
|
|
|
|
elt))
|
|
|
|
|
|
|
|
|
|
;; Check symlink in `directory-files-and-attributes'.
|
2017-09-04 13:10:52 +02:00
|
|
|
|
;; It does not work in the "smb" case, only relative
|
|
|
|
|
;; symlinks to existing files are shown there.
|
2017-08-28 18:08:16 +02:00
|
|
|
|
(tramp--test-ignore-make-symbolic-link-error
|
2017-09-04 13:10:52 +02:00
|
|
|
|
(unless
|
|
|
|
|
(tramp-smb-file-name-p tramp-test-temporary-file-directory)
|
|
|
|
|
(make-symbolic-link file2 file3)
|
|
|
|
|
(should (file-symlink-p file3))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(caar (directory-files-and-attributes
|
|
|
|
|
file1 nil (regexp-quote elt1)))
|
|
|
|
|
elt1))
|
|
|
|
|
(should
|
|
|
|
|
(string-equal
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if quoted #'tramp-compat-file-name-quote #'identity)
|
2017-09-04 13:10:52 +02:00
|
|
|
|
(cadr (car (directory-files-and-attributes
|
|
|
|
|
file1 nil (regexp-quote elt1)))))
|
|
|
|
|
(file-remote-p (file-truename file2) 'localname)))
|
|
|
|
|
(delete-file file3)
|
|
|
|
|
(should-not (file-exists-p file3))))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
(delete-file file2)
|
|
|
|
|
(should-not (file-exists-p file2))
|
|
|
|
|
(delete-directory file1)
|
2016-12-15 09:37:35 +01:00
|
|
|
|
(should-not (file-exists-p file1))))
|
|
|
|
|
|
|
|
|
|
;; Check, that environment variables are set correctly.
|
2019-08-27 18:53:26 +02:00
|
|
|
|
;; We do not run on macOS due to encoding problems. See
|
|
|
|
|
;; Bug#36940.
|
|
|
|
|
(when (and (tramp--test-expensive-test) (tramp--test-sh-p)
|
|
|
|
|
(not (eq system-type 'darwin)))
|
2016-12-23 09:31:23 +01:00
|
|
|
|
(dolist (elt files)
|
|
|
|
|
(let ((envvar (concat "VAR_" (upcase (md5 elt))))
|
2018-03-28 18:05:58 +02:00
|
|
|
|
(elt (encode-coding-string elt coding-system-for-read))
|
2016-12-23 09:31:23 +01:00
|
|
|
|
(default-directory tramp-test-temporary-file-directory)
|
|
|
|
|
(process-environment process-environment))
|
|
|
|
|
(setenv envvar elt)
|
|
|
|
|
;; The value of PS1 could confuse Tramp's detection
|
|
|
|
|
;; of process output. So we unset it temporarily.
|
|
|
|
|
(setenv "PS1")
|
|
|
|
|
(with-temp-buffer
|
2019-09-13 12:08:34 +02:00
|
|
|
|
(should (zerop (process-file "printenv" nil t nil)))
|
2016-12-23 09:31:23 +01:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(should
|
|
|
|
|
(re-search-forward
|
2019-08-27 18:53:26 +02:00
|
|
|
|
(format
|
|
|
|
|
"^%s=%s$"
|
|
|
|
|
(regexp-quote envvar)
|
|
|
|
|
(regexp-quote (getenv envvar))))))))))
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
|
|
|
|
(ignore-errors (delete-directory tmp-name1 'recursive))
|
|
|
|
|
(ignore-errors (delete-directory tmp-name2 'recursive))))))
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2015-03-04 11:46:06 +01:00
|
|
|
|
(defun tramp--test-special-characters ()
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
"Perform the test in `tramp-test40-special-characters*'."
|
2015-03-16 12:25:42 -04:00
|
|
|
|
;; Newlines, slashes and backslashes in file names are not
|
|
|
|
|
;; supported. So we don't test. And we don't test the tab
|
|
|
|
|
;; character on Windows or Cygwin, because the backslash is
|
|
|
|
|
;; interpreted as a path separator, preventing "\t" from being
|
|
|
|
|
;; expanded to <TAB>.
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(let ((files
|
|
|
|
|
(list
|
2018-12-06 16:11:27 +01:00
|
|
|
|
(if (or (tramp--test-gvfs-p)
|
|
|
|
|
(tramp--test-rclone-p)
|
2018-12-16 15:49:07 +01:00
|
|
|
|
(tramp--test-sudoedit-p)
|
2018-12-06 16:11:27 +01:00
|
|
|
|
(tramp--test-windows-nt-or-smb-p))
|
2018-03-17 15:10:46 +01:00
|
|
|
|
"foo bar baz"
|
|
|
|
|
(if (or (tramp--test-adb-p)
|
|
|
|
|
(tramp--test-docker-p)
|
|
|
|
|
(eq system-type 'cygwin))
|
|
|
|
|
" foo bar baz "
|
|
|
|
|
" foo\tbar baz\t"))
|
|
|
|
|
"$foo$bar$$baz$"
|
|
|
|
|
"-foo-bar-baz-"
|
|
|
|
|
"%foo%bar%baz%"
|
|
|
|
|
"&foo&bar&baz&"
|
|
|
|
|
(unless (or (tramp--test-ftp-p)
|
|
|
|
|
(tramp--test-gvfs-p)
|
|
|
|
|
(tramp--test-windows-nt-or-smb-p))
|
|
|
|
|
"?foo?bar?baz?")
|
|
|
|
|
(unless (or (tramp--test-ftp-p)
|
|
|
|
|
(tramp--test-gvfs-p)
|
|
|
|
|
(tramp--test-windows-nt-or-smb-p))
|
|
|
|
|
"*foo*bar*baz*")
|
|
|
|
|
(if (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p))
|
|
|
|
|
"'foo'bar'baz'"
|
|
|
|
|
"'foo\"bar'baz\"")
|
|
|
|
|
"#foo~bar#baz~"
|
|
|
|
|
(if (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p))
|
|
|
|
|
"!foo!bar!baz!"
|
|
|
|
|
"!foo|bar!baz|")
|
2018-12-06 16:11:27 +01:00
|
|
|
|
(if (or (tramp--test-gvfs-p)
|
|
|
|
|
(tramp--test-rclone-p)
|
|
|
|
|
(tramp--test-windows-nt-or-smb-p))
|
2018-03-17 15:10:46 +01:00
|
|
|
|
";foo;bar;baz;"
|
|
|
|
|
":foo;bar:baz;")
|
|
|
|
|
(unless (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p))
|
|
|
|
|
"<foo>bar<baz>")
|
|
|
|
|
"(foo)bar(baz)"
|
|
|
|
|
(unless (or (tramp--test-ftp-p) (tramp--test-gvfs-p)) "[foo]bar[baz]")
|
|
|
|
|
"{foo}bar{baz}")))
|
|
|
|
|
;; Simplify test in order to speed up.
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(apply #'tramp--test-check-files
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(if (tramp--test-expensive-test)
|
2019-02-28 10:33:05 +01:00
|
|
|
|
files (list (mapconcat #'identity files ""))))))
|
2014-04-18 20:58:13 +02:00
|
|
|
|
|
2015-03-04 11:46:06 +01:00
|
|
|
|
;; These tests are inspired by Bug#17238.
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test40-special-characters ()
|
2015-03-04 11:46:06 +01:00
|
|
|
|
"Check special characters in file names."
|
2014-04-18 20:58:13 +02:00
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2016-06-26 12:30:21 +02:00
|
|
|
|
(skip-unless (not (tramp--test-rsync-p)))
|
2016-12-17 19:52:38 +01:00
|
|
|
|
(skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p)))
|
2014-04-18 20:58:13 +02:00
|
|
|
|
|
2015-03-04 11:46:06 +01:00
|
|
|
|
(tramp--test-special-characters))
|
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test40-special-characters-with-stat ()
|
2015-03-04 11:46:06 +01:00
|
|
|
|
"Check special characters in file names.
|
|
|
|
|
Use the `stat' command."
|
2016-01-04 23:28:07 +01:00
|
|
|
|
:tags '(:expensive-test)
|
2015-03-04 11:46:06 +01:00
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2016-12-17 19:52:38 +01:00
|
|
|
|
(skip-unless (tramp--test-sh-p))
|
|
|
|
|
(skip-unless (not (tramp--test-rsync-p)))
|
|
|
|
|
(skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p)))
|
2015-03-04 11:46:06 +01:00
|
|
|
|
(with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
|
|
|
|
|
(skip-unless (tramp-get-remote-stat v)))
|
|
|
|
|
|
2015-07-24 20:02:59 +02:00
|
|
|
|
(let ((tramp-connection-properties
|
|
|
|
|
(append
|
|
|
|
|
`((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
|
|
|
|
|
"perl" nil))
|
|
|
|
|
tramp-connection-properties)))
|
|
|
|
|
(tramp--test-special-characters)))
|
2015-03-04 11:46:06 +01:00
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test40-special-characters-with-perl ()
|
2015-03-04 11:46:06 +01:00
|
|
|
|
"Check special characters in file names.
|
|
|
|
|
Use the `perl' command."
|
2016-01-04 23:28:07 +01:00
|
|
|
|
:tags '(:expensive-test)
|
2015-03-04 11:46:06 +01:00
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2016-12-17 19:52:38 +01:00
|
|
|
|
(skip-unless (tramp--test-sh-p))
|
|
|
|
|
(skip-unless (not (tramp--test-rsync-p)))
|
|
|
|
|
(skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p)))
|
2015-03-04 11:46:06 +01:00
|
|
|
|
(with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
|
|
|
|
|
(skip-unless (tramp-get-remote-perl v)))
|
|
|
|
|
|
2015-07-24 20:02:59 +02:00
|
|
|
|
(let ((tramp-connection-properties
|
|
|
|
|
(append
|
|
|
|
|
`((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
|
2015-12-06 18:55:50 +01:00
|
|
|
|
"stat" nil)
|
|
|
|
|
;; See `tramp-sh-handle-file-truename'.
|
|
|
|
|
(,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
|
|
|
|
|
"readlink" nil))
|
2015-07-24 20:02:59 +02:00
|
|
|
|
tramp-connection-properties)))
|
|
|
|
|
(tramp--test-special-characters)))
|
2015-03-04 11:46:06 +01:00
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test40-special-characters-with-ls ()
|
2015-03-04 11:46:06 +01:00
|
|
|
|
"Check special characters in file names.
|
|
|
|
|
Use the `ls' command."
|
2016-01-04 23:28:07 +01:00
|
|
|
|
:tags '(:expensive-test)
|
2015-03-04 11:46:06 +01:00
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2016-12-17 19:52:38 +01:00
|
|
|
|
(skip-unless (tramp--test-sh-p))
|
|
|
|
|
(skip-unless (not (tramp--test-rsync-p)))
|
|
|
|
|
(skip-unless (not (tramp--test-windows-nt-and-batch)))
|
|
|
|
|
(skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p)))
|
2015-03-04 11:46:06 +01:00
|
|
|
|
|
2015-07-24 20:02:59 +02:00
|
|
|
|
(let ((tramp-connection-properties
|
|
|
|
|
(append
|
|
|
|
|
`((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
|
|
|
|
|
"perl" nil)
|
|
|
|
|
(,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
|
2015-12-06 18:55:50 +01:00
|
|
|
|
"stat" nil)
|
|
|
|
|
;; See `tramp-sh-handle-file-truename'.
|
|
|
|
|
(,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
|
|
|
|
|
"readlink" nil))
|
2015-07-24 20:02:59 +02:00
|
|
|
|
tramp-connection-properties)))
|
|
|
|
|
(tramp--test-special-characters)))
|
2015-03-04 11:46:06 +01:00
|
|
|
|
|
|
|
|
|
(defun tramp--test-utf8 ()
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
"Perform the test in `tramp-test41-utf8*'."
|
2016-04-03 10:14:56 +02:00
|
|
|
|
(let* ((utf8 (if (and (eq system-type 'darwin)
|
|
|
|
|
(memq 'utf-8-hfs (coding-system-list)))
|
|
|
|
|
'utf-8-hfs 'utf-8))
|
|
|
|
|
(coding-system-for-read utf8)
|
|
|
|
|
(coding-system-for-write utf8)
|
2017-08-19 17:15:52 -07:00
|
|
|
|
(file-name-coding-system
|
|
|
|
|
(coding-system-change-eol-conversion utf8 'unix)))
|
2018-03-20 16:33:51 +01:00
|
|
|
|
(apply
|
2019-02-28 10:33:05 +01:00
|
|
|
|
#'tramp--test-check-files
|
2018-05-06 12:39:36 +02:00
|
|
|
|
(append
|
|
|
|
|
(list
|
|
|
|
|
(unless (tramp--test-hpux-p) "Γυρίστε το Γαλαξία με Ώτο Στοπ")
|
|
|
|
|
(unless (tramp--test-hpux-p)
|
|
|
|
|
"أصبح بوسعك الآن تنزيل نسخة كاملة من موسوعة ويكيبيديا العربية لتصفحها بلا اتصال بالإنترنت")
|
|
|
|
|
"银河系漫游指南系列"
|
|
|
|
|
"Автостопом по гала́ктике"
|
|
|
|
|
;; Use codepoints without a name. See Bug#31272.
|
|
|
|
|
"bung")
|
|
|
|
|
|
|
|
|
|
(when (tramp--test-expensive-test)
|
|
|
|
|
(delete-dups
|
|
|
|
|
(mapcar
|
|
|
|
|
;; Use all available language specific snippets. Filter out
|
|
|
|
|
;; strings which use unencodable characters.
|
|
|
|
|
(lambda (x)
|
|
|
|
|
(and
|
|
|
|
|
(stringp (setq x (eval (get-language-info (car x) 'sample-text))))
|
|
|
|
|
(not (unencodable-char-position
|
2018-05-11 18:38:46 +02:00
|
|
|
|
0 (length x) file-name-coding-system nil x))
|
2018-05-06 12:39:36 +02:00
|
|
|
|
;; ?\n and ?/ shouldn't be part of any file name. ?\t,
|
|
|
|
|
;; ?. and ?? do not work for "smb" method.
|
|
|
|
|
(replace-regexp-in-string "[\t\n/.?]" "" x)))
|
|
|
|
|
language-info-alist)))))))
|
2014-04-18 20:58:13 +02:00
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test41-utf8 ()
|
2015-03-04 11:46:06 +01:00
|
|
|
|
"Check UTF8 encoding in file names and file contents."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2016-12-12 11:12:34 +01:00
|
|
|
|
(skip-unless (not (tramp--test-docker-p)))
|
2016-06-26 12:30:21 +02:00
|
|
|
|
(skip-unless (not (tramp--test-rsync-p)))
|
2016-12-17 19:52:38 +01:00
|
|
|
|
(skip-unless (not (tramp--test-windows-nt-and-batch)))
|
|
|
|
|
(skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p)))
|
2019-09-26 09:33:47 +02:00
|
|
|
|
(skip-unless (not (tramp--test-ksh-p)))
|
2015-03-04 11:46:06 +01:00
|
|
|
|
|
2018-03-30 12:36:07 +02:00
|
|
|
|
(tramp--test-utf8))
|
2015-03-04 11:46:06 +01:00
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test41-utf8-with-stat ()
|
2015-03-04 11:46:06 +01:00
|
|
|
|
"Check UTF8 encoding in file names and file contents.
|
|
|
|
|
Use the `stat' command."
|
2018-03-28 19:06:42 +02:00
|
|
|
|
:tags '(:expensive-test)
|
2015-03-04 11:46:06 +01:00
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2016-12-17 19:52:38 +01:00
|
|
|
|
(skip-unless (tramp--test-sh-p))
|
2016-12-12 11:12:34 +01:00
|
|
|
|
(skip-unless (not (tramp--test-docker-p)))
|
2016-12-17 19:52:38 +01:00
|
|
|
|
(skip-unless (not (tramp--test-rsync-p)))
|
|
|
|
|
(skip-unless (not (tramp--test-windows-nt-and-batch)))
|
|
|
|
|
(skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p)))
|
2019-09-26 09:33:47 +02:00
|
|
|
|
(skip-unless (not (tramp--test-ksh-p)))
|
2015-03-04 11:46:06 +01:00
|
|
|
|
(with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
|
|
|
|
|
(skip-unless (tramp-get-remote-stat v)))
|
|
|
|
|
|
2015-07-24 20:02:59 +02:00
|
|
|
|
(let ((tramp-connection-properties
|
|
|
|
|
(append
|
|
|
|
|
`((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
|
|
|
|
|
"perl" nil))
|
|
|
|
|
tramp-connection-properties)))
|
|
|
|
|
(tramp--test-utf8)))
|
2015-03-04 11:46:06 +01:00
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test41-utf8-with-perl ()
|
2015-03-04 11:46:06 +01:00
|
|
|
|
"Check UTF8 encoding in file names and file contents.
|
|
|
|
|
Use the `perl' command."
|
2018-03-28 19:06:42 +02:00
|
|
|
|
:tags '(:expensive-test)
|
2015-03-04 11:46:06 +01:00
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2016-12-17 19:52:38 +01:00
|
|
|
|
(skip-unless (tramp--test-sh-p))
|
2016-12-12 11:12:34 +01:00
|
|
|
|
(skip-unless (not (tramp--test-docker-p)))
|
2016-12-17 19:52:38 +01:00
|
|
|
|
(skip-unless (not (tramp--test-rsync-p)))
|
|
|
|
|
(skip-unless (not (tramp--test-windows-nt-and-batch)))
|
|
|
|
|
(skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p)))
|
2019-09-26 09:33:47 +02:00
|
|
|
|
(skip-unless (not (tramp--test-ksh-p)))
|
2015-03-04 11:46:06 +01:00
|
|
|
|
(with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
|
|
|
|
|
(skip-unless (tramp-get-remote-perl v)))
|
|
|
|
|
|
2015-07-24 20:02:59 +02:00
|
|
|
|
(let ((tramp-connection-properties
|
|
|
|
|
(append
|
|
|
|
|
`((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
|
2015-12-06 18:55:50 +01:00
|
|
|
|
"stat" nil)
|
|
|
|
|
;; See `tramp-sh-handle-file-truename'.
|
|
|
|
|
(,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
|
|
|
|
|
"readlink" nil))
|
2015-07-24 20:02:59 +02:00
|
|
|
|
tramp-connection-properties)))
|
|
|
|
|
(tramp--test-utf8)))
|
2015-03-04 11:46:06 +01:00
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test41-utf8-with-ls ()
|
2015-03-04 11:46:06 +01:00
|
|
|
|
"Check UTF8 encoding in file names and file contents.
|
|
|
|
|
Use the `ls' command."
|
2018-03-28 19:06:42 +02:00
|
|
|
|
:tags '(:expensive-test)
|
2015-03-04 11:46:06 +01:00
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2016-12-17 19:52:38 +01:00
|
|
|
|
(skip-unless (tramp--test-sh-p))
|
2016-12-12 11:12:34 +01:00
|
|
|
|
(skip-unless (not (tramp--test-docker-p)))
|
2016-12-17 19:52:38 +01:00
|
|
|
|
(skip-unless (not (tramp--test-rsync-p)))
|
|
|
|
|
(skip-unless (not (tramp--test-windows-nt-and-batch)))
|
|
|
|
|
(skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p)))
|
2019-09-26 09:33:47 +02:00
|
|
|
|
(skip-unless (not (tramp--test-ksh-p)))
|
2015-03-04 11:46:06 +01:00
|
|
|
|
|
2015-07-24 20:02:59 +02:00
|
|
|
|
(let ((tramp-connection-properties
|
|
|
|
|
(append
|
|
|
|
|
`((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
|
|
|
|
|
"perl" nil)
|
|
|
|
|
(,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
|
2015-12-06 18:55:50 +01:00
|
|
|
|
"stat" nil)
|
|
|
|
|
;; See `tramp-sh-handle-file-truename'.
|
|
|
|
|
(,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
|
|
|
|
|
"readlink" nil))
|
2015-07-24 20:02:59 +02:00
|
|
|
|
tramp-connection-properties)))
|
|
|
|
|
(tramp--test-utf8)))
|
2015-03-04 11:46:06 +01:00
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test42-file-system-info ()
|
2017-10-03 16:07:32 +02:00
|
|
|
|
"Check that `file-system-info' returns proper values."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
|
|
|
|
;; Since Emacs 27.1.
|
|
|
|
|
(skip-unless (fboundp 'file-system-info))
|
|
|
|
|
|
2017-11-29 09:37:42 +01:00
|
|
|
|
;; `file-system-info' exists since Emacs 27. We don't want to see
|
|
|
|
|
;; compiler warnings for older Emacsen.
|
2017-10-03 16:07:32 +02:00
|
|
|
|
(let ((fsi (with-no-warnings
|
|
|
|
|
(file-system-info tramp-test-temporary-file-directory))))
|
|
|
|
|
(skip-unless fsi)
|
|
|
|
|
(should (and (consp fsi)
|
|
|
|
|
(= (length fsi) 3)
|
|
|
|
|
(numberp (nth 0 fsi))
|
|
|
|
|
(numberp (nth 1 fsi))
|
|
|
|
|
(numberp (nth 2 fsi))))))
|
|
|
|
|
|
2019-02-03 11:07:36 +01:00
|
|
|
|
;; `tramp-test43-asynchronous-requests' could be blocked. So we set a
|
|
|
|
|
;; timeout of 300 seconds, and we send a SIGUSR1 signal after 300
|
|
|
|
|
;; seconds. Similar check is performed in the timer function.
|
|
|
|
|
(defconst tramp--test-asynchronous-requests-timeout 300
|
|
|
|
|
"Timeout for `tramp-test43-asynchronous-requests'.")
|
2017-07-27 12:51:45 +02:00
|
|
|
|
|
2019-06-10 17:53:15 +02:00
|
|
|
|
(defmacro tramp--test-with-proper-process-name-and-buffer (proc &rest body)
|
|
|
|
|
"Set \"process-name\" and \"process-buffer\" connection properties.
|
|
|
|
|
This is needed in timer functions as well as process filters and sentinels."
|
|
|
|
|
(declare (indent 1) (debug (processp body)))
|
|
|
|
|
`(let* ((v (tramp-get-connection-property ,proc "vector" nil))
|
|
|
|
|
(pname (tramp-get-connection-property v "process-name" nil))
|
|
|
|
|
(pbuffer (tramp-get-connection-property v "process-buffer" nil)))
|
|
|
|
|
(tramp--test-message
|
|
|
|
|
"tramp--test-with-proper-process-name-and-buffer before %s %s"
|
|
|
|
|
(tramp-get-connection-property v "process-name" nil)
|
|
|
|
|
(tramp-get-connection-property v "process-buffer" nil))
|
|
|
|
|
(if (process-name ,proc)
|
|
|
|
|
(tramp-set-connection-property v "process-name" (process-name ,proc))
|
|
|
|
|
(tramp-flush-connection-property v "process-name"))
|
|
|
|
|
(if (process-buffer ,proc)
|
|
|
|
|
(tramp-set-connection-property
|
|
|
|
|
v "process-buffer" (process-buffer ,proc))
|
|
|
|
|
(tramp-flush-connection-property v "process-buffer"))
|
|
|
|
|
(tramp--test-message
|
|
|
|
|
"tramp--test-with-proper-process-name-and-buffer changed %s %s"
|
|
|
|
|
(tramp-get-connection-property v "process-name" nil)
|
|
|
|
|
(tramp-get-connection-property v "process-buffer" nil))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn ,@body)
|
|
|
|
|
(if pname
|
|
|
|
|
(tramp-set-connection-property v "process-name" pname)
|
|
|
|
|
(tramp-flush-connection-property v "process-name"))
|
|
|
|
|
(if pbuffer
|
|
|
|
|
(tramp-set-connection-property v "process-buffer" pbuffer)
|
|
|
|
|
(tramp-flush-connection-property v "process-buffer")))))
|
|
|
|
|
|
2014-03-07 15:11:37 +01:00
|
|
|
|
;; This test is inspired by Bug#16928.
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test43-asynchronous-requests ()
|
2014-03-07 15:11:37 +01:00
|
|
|
|
"Check parallel asynchronous requests.
|
|
|
|
|
Such requests could arrive from timers, process filters and
|
|
|
|
|
process sentinels. They shall not disturb each other."
|
2019-01-16 13:56:38 +01:00
|
|
|
|
;; The test fails from time to time, w/o a reproducible pattern. So
|
|
|
|
|
;; we mark it as unstable.
|
2019-01-30 09:28:43 +01:00
|
|
|
|
:tags '(:expensive-test :unstable)
|
2014-03-07 15:11:37 +01:00
|
|
|
|
(skip-unless (tramp--test-enabled))
|
2019-04-05 13:27:06 +02:00
|
|
|
|
;; Prior Emacs 27, `shell-file-name' was hard coded as "/bin/sh" for
|
|
|
|
|
;; remote processes in Emacs. That doesn't work for tramp-adb.el.
|
|
|
|
|
(skip-unless (or (and (tramp--test-adb-p) (tramp--test-emacs27-p))
|
|
|
|
|
(tramp--test-sh-p)))
|
2014-03-07 15:11:37 +01:00
|
|
|
|
|
2019-02-03 11:07:36 +01:00
|
|
|
|
(with-timeout
|
|
|
|
|
(tramp--test-asynchronous-requests-timeout (tramp--test-timeout-handler))
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(define-key special-event-map [sigusr1] #'tramp--test-timeout-handler)
|
2017-08-17 11:35:41 +02:00
|
|
|
|
(let* (;; For the watchdog.
|
|
|
|
|
(default-directory (expand-file-name temporary-file-directory))
|
2019-04-04 13:41:53 +02:00
|
|
|
|
(shell-file-name (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh"))
|
2019-06-11 20:28:31 +02:00
|
|
|
|
;; It doesn't work on w32 systems.
|
2017-08-17 11:35:41 +02:00
|
|
|
|
(watchdog
|
2019-06-11 20:28:31 +02:00
|
|
|
|
(unless (tramp--test-windows-nt)
|
|
|
|
|
(start-process-shell-command
|
|
|
|
|
"*watchdog*" nil
|
|
|
|
|
(format
|
|
|
|
|
"sleep %d; kill -USR1 %d"
|
|
|
|
|
tramp--test-asynchronous-requests-timeout (emacs-pid)))))
|
2017-07-27 12:51:45 +02:00
|
|
|
|
(tmp-name (tramp--test-make-temp-name))
|
2017-07-03 13:21:39 +02:00
|
|
|
|
(default-directory tmp-name)
|
|
|
|
|
;; Do not cache Tramp properties.
|
|
|
|
|
(remote-file-name-inhibit-cache t)
|
|
|
|
|
(process-file-side-effects t)
|
|
|
|
|
;; Suppress nasty messages.
|
|
|
|
|
(inhibit-message t)
|
2017-07-17 14:12:20 +02:00
|
|
|
|
;; Do not run delayed timers.
|
|
|
|
|
(timer-max-repeats 0)
|
2017-12-16 10:47:06 +01:00
|
|
|
|
;; Number of asynchronous processes for test. Tests on
|
|
|
|
|
;; some machines handle less parallel processes.
|
|
|
|
|
(number-proc
|
2018-03-17 15:10:46 +01:00
|
|
|
|
(cond
|
|
|
|
|
((ignore-errors
|
|
|
|
|
(string-to-number (getenv "REMOTE_PARALLEL_PROCESSES"))))
|
|
|
|
|
((getenv "EMACS_HYDRA_CI") 5)
|
|
|
|
|
(t 10)))
|
2017-07-03 13:21:39 +02:00
|
|
|
|
;; On hydra, timings are bad.
|
|
|
|
|
(timer-repeat
|
|
|
|
|
(cond
|
2017-07-18 12:53:46 -04:00
|
|
|
|
((getenv "EMACS_HYDRA_CI") 10)
|
2017-07-03 13:21:39 +02:00
|
|
|
|
(t 1)))
|
|
|
|
|
;; We must distinguish due to performance reasons.
|
2019-06-10 17:53:15 +02:00
|
|
|
|
;; (timer-operation
|
|
|
|
|
;; (cond
|
|
|
|
|
;; ((tramp--test-mock-p) #'vc-registered)
|
|
|
|
|
;; (t #'file-attributes)))
|
2019-02-03 11:07:36 +01:00
|
|
|
|
;; This is when all timers start. We check inside the
|
|
|
|
|
;; timer function, that we don't exceed timeout.
|
|
|
|
|
(timer-start (current-time))
|
2017-07-03 13:21:39 +02:00
|
|
|
|
timer buffers kill-buffer-query-functions)
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
|
2017-07-03 13:21:39 +02:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(make-directory tmp-name)
|
|
|
|
|
|
|
|
|
|
;; Setup a timer in order to raise an ordinary command
|
|
|
|
|
;; again and again. `vc-registered' is well suited,
|
|
|
|
|
;; because there are many checks.
|
|
|
|
|
(setq
|
|
|
|
|
timer
|
|
|
|
|
(run-at-time
|
|
|
|
|
0 timer-repeat
|
|
|
|
|
(lambda ()
|
2019-06-10 17:53:15 +02:00
|
|
|
|
(tramp--test-with-proper-process-name-and-buffer
|
|
|
|
|
(get-buffer-process
|
|
|
|
|
(tramp-get-buffer
|
|
|
|
|
(tramp-dissect-file-name
|
|
|
|
|
tramp-test-temporary-file-directory)))
|
|
|
|
|
(when (> (- (time-to-seconds) (time-to-seconds timer-start))
|
|
|
|
|
tramp--test-asynchronous-requests-timeout)
|
|
|
|
|
(tramp--test-timeout-handler))
|
|
|
|
|
(when buffers
|
|
|
|
|
(let ((time (float-time))
|
|
|
|
|
(default-directory tmp-name)
|
|
|
|
|
(file
|
|
|
|
|
(buffer-name
|
|
|
|
|
(nth (random (length buffers)) buffers))))
|
|
|
|
|
(tramp--test-message
|
|
|
|
|
"Start timer %s %s" file (current-time-string))
|
|
|
|
|
;; (funcall timer-operation file)
|
2019-02-03 11:07:36 +01:00
|
|
|
|
(tramp--test-message
|
2019-06-10 17:53:15 +02:00
|
|
|
|
"Stop timer %s %s" file (current-time-string))
|
|
|
|
|
;; Adjust timer if it takes too much time.
|
|
|
|
|
(when (> (- (float-time) time) timer-repeat)
|
|
|
|
|
(setq timer-repeat (* 1.1 timer-repeat))
|
|
|
|
|
(setf (timer--repeat-delay timer) timer-repeat)
|
|
|
|
|
(tramp--test-message
|
|
|
|
|
"Increase timer %s" timer-repeat))))))))
|
2017-07-03 13:21:39 +02:00
|
|
|
|
|
|
|
|
|
;; Create temporary buffers. The number of buffers
|
|
|
|
|
;; corresponds to the number of processes; it could be
|
|
|
|
|
;; increased in order to make pressure on Tramp.
|
2017-08-30 12:00:26 +02:00
|
|
|
|
(dotimes (_ number-proc)
|
2017-07-12 14:53:53 +02:00
|
|
|
|
(setq buffers (cons (generate-new-buffer "foo") buffers)))
|
2017-07-03 13:21:39 +02:00
|
|
|
|
|
|
|
|
|
;; Open asynchronous processes. Set process filter and sentinel.
|
|
|
|
|
(dolist (buf buffers)
|
2017-07-05 17:03:42 +02:00
|
|
|
|
;; Activate timer.
|
|
|
|
|
(sit-for 0.01 'nodisp)
|
2017-07-03 13:21:39 +02:00
|
|
|
|
(let ((proc
|
|
|
|
|
(start-file-process-shell-command
|
|
|
|
|
(buffer-name buf) buf
|
|
|
|
|
(concat
|
2019-02-03 11:07:36 +01:00
|
|
|
|
"(read line && echo $line >$line && echo $line);"
|
|
|
|
|
"(read line && cat $line);"
|
|
|
|
|
"(read line && rm -f $line)")))
|
2017-07-03 13:21:39 +02:00
|
|
|
|
(file (expand-file-name (buffer-name buf))))
|
|
|
|
|
;; Remember the file name. Add counter.
|
|
|
|
|
(process-put proc 'foo file)
|
|
|
|
|
(process-put proc 'bar 0)
|
|
|
|
|
;; Add process filter.
|
|
|
|
|
(set-process-filter
|
|
|
|
|
proc
|
|
|
|
|
(lambda (proc string)
|
2019-06-10 17:53:15 +02:00
|
|
|
|
(tramp--test-with-proper-process-name-and-buffer proc
|
|
|
|
|
(tramp--test-message
|
|
|
|
|
"Process filter %s %s %s"
|
|
|
|
|
proc string (current-time-string))
|
|
|
|
|
(with-current-buffer (process-buffer proc)
|
|
|
|
|
(insert string))
|
|
|
|
|
(when (< (process-get proc 'bar) 2)
|
|
|
|
|
(dired-uncache (process-get proc 'foo))
|
|
|
|
|
(should (file-attributes (process-get proc 'foo)))))))
|
2019-02-03 11:07:36 +01:00
|
|
|
|
;; Add process sentinel. It shall not perform remote
|
|
|
|
|
;; operations, triggering Tramp processes. This blocks.
|
2017-07-03 13:21:39 +02:00
|
|
|
|
(set-process-sentinel
|
|
|
|
|
proc
|
|
|
|
|
(lambda (proc _state)
|
2019-06-10 17:53:15 +02:00
|
|
|
|
(tramp--test-with-proper-process-name-and-buffer proc
|
|
|
|
|
(tramp--test-message
|
|
|
|
|
"Process sentinel %s %s" proc (current-time-string)))))))
|
2017-07-03 13:21:39 +02:00
|
|
|
|
|
2019-02-03 11:07:36 +01:00
|
|
|
|
;; Send a string to the processes. Use a random order of
|
|
|
|
|
;; the buffers. Mix with regular operation.
|
2017-07-03 13:21:39 +02:00
|
|
|
|
(let ((buffers (copy-sequence buffers)))
|
|
|
|
|
(while buffers
|
|
|
|
|
(let* ((buf (nth (random (length buffers)) buffers))
|
|
|
|
|
(proc (get-buffer-process buf))
|
|
|
|
|
(file (process-get proc 'foo))
|
|
|
|
|
(count (process-get proc 'bar)))
|
2017-07-12 14:53:53 +02:00
|
|
|
|
(tramp--test-message
|
|
|
|
|
"Start action %d %s %s" count buf (current-time-string))
|
2017-07-31 14:32:24 +02:00
|
|
|
|
;; Regular operation prior process action.
|
2017-12-16 10:47:06 +01:00
|
|
|
|
(dired-uncache file)
|
2017-07-03 13:21:39 +02:00
|
|
|
|
(if (= count 0)
|
|
|
|
|
(should-not (file-attributes file))
|
|
|
|
|
(should (file-attributes file)))
|
|
|
|
|
;; Send string to process.
|
|
|
|
|
(process-send-string proc (format "%s\n" (buffer-name buf)))
|
2019-06-10 17:53:15 +02:00
|
|
|
|
(while (accept-process-output nil 0))
|
2017-12-16 10:47:06 +01:00
|
|
|
|
(tramp--test-message
|
|
|
|
|
"Continue action %d %s %s" count buf (current-time-string))
|
2017-07-31 14:32:24 +02:00
|
|
|
|
;; Regular operation post process action.
|
2017-12-16 10:47:06 +01:00
|
|
|
|
(dired-uncache file)
|
2017-08-02 10:59:57 +02:00
|
|
|
|
(if (= count 2)
|
|
|
|
|
(should-not (file-attributes file))
|
|
|
|
|
(should (file-attributes file)))
|
2017-07-12 14:53:53 +02:00
|
|
|
|
(tramp--test-message
|
|
|
|
|
"Stop action %d %s %s" count buf (current-time-string))
|
2017-07-03 13:21:39 +02:00
|
|
|
|
(process-put proc 'bar (1+ count))
|
|
|
|
|
(unless (process-live-p proc)
|
|
|
|
|
(setq buffers (delq buf buffers))))))
|
|
|
|
|
|
|
|
|
|
;; Checks. All process output shall exists in the
|
|
|
|
|
;; respective buffers. All created files shall be
|
|
|
|
|
;; deleted.
|
2017-07-27 12:51:45 +02:00
|
|
|
|
(tramp--test-message "Check %s" (current-time-string))
|
2017-07-03 13:21:39 +02:00
|
|
|
|
(dolist (buf buffers)
|
|
|
|
|
(with-current-buffer buf
|
2019-02-03 11:07:36 +01:00
|
|
|
|
(should
|
2019-04-04 13:41:53 +02:00
|
|
|
|
(string-equal
|
|
|
|
|
;; tramp-adb.el echoes, so we must add the three strings.
|
|
|
|
|
(if (tramp--test-adb-p)
|
|
|
|
|
(format "%s\n%s\n%s\n%s\n%s\n" buf buf buf buf buf)
|
|
|
|
|
(format "%s\n%s\n" buf buf))
|
|
|
|
|
(buffer-string)))))
|
2017-07-03 13:21:39 +02:00
|
|
|
|
(should-not
|
|
|
|
|
(directory-files
|
|
|
|
|
tmp-name nil directory-files-no-dot-files-regexp)))
|
|
|
|
|
|
|
|
|
|
;; Cleanup.
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(define-key special-event-map [sigusr1] #'ignore)
|
2017-07-27 12:51:45 +02:00
|
|
|
|
(ignore-errors (quit-process watchdog))
|
2017-07-03 13:21:39 +02:00
|
|
|
|
(dolist (buf buffers)
|
|
|
|
|
(ignore-errors (delete-process (get-buffer-process buf)))
|
|
|
|
|
(ignore-errors (kill-buffer buf)))
|
|
|
|
|
(ignore-errors (cancel-timer timer))
|
2019-02-03 11:07:36 +01:00
|
|
|
|
(ignore-errors (delete-directory tmp-name 'recursive))))))
|
2014-03-07 15:11:37 +01:00
|
|
|
|
|
2017-11-30 20:31:33 +01:00
|
|
|
|
;; This test is inspired by Bug#29163.
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test44-auto-load ()
|
2017-11-27 13:31:53 +01:00
|
|
|
|
"Check that Tramp autoloads properly."
|
2018-08-08 19:57:54 +02:00
|
|
|
|
(skip-unless (tramp--test-enabled))
|
|
|
|
|
|
2017-11-29 09:37:42 +01:00
|
|
|
|
(let ((default-directory (expand-file-name temporary-file-directory))
|
|
|
|
|
(code
|
|
|
|
|
(format
|
2019-06-04 12:51:45 +02:00
|
|
|
|
;; Suppress method name check.
|
|
|
|
|
"(let ((non-essential t)) \
|
|
|
|
|
(message \"Tramp loaded: %%s\" (and (file-remote-p %S) t)))"
|
2017-11-29 09:37:42 +01:00
|
|
|
|
tramp-test-temporary-file-directory)))
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
"Tramp loaded: t[\n\r]+"
|
|
|
|
|
(shell-command-to-string
|
|
|
|
|
(format
|
|
|
|
|
"%s -batch -Q -L %s --eval %s"
|
2018-01-07 18:50:06 +01:00
|
|
|
|
(shell-quote-argument
|
|
|
|
|
(expand-file-name invocation-name invocation-directory))
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(mapconcat #'shell-quote-argument load-path " -L ")
|
2017-11-29 09:37:42 +01:00
|
|
|
|
(shell-quote-argument code)))))))
|
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test44-delay-load ()
|
2017-11-29 09:37:42 +01:00
|
|
|
|
"Check that Tramp is loaded lazily, only when needed."
|
2017-12-08 16:37:53 +01:00
|
|
|
|
;; The autoloaded Tramp objects are different since Emacs 26.1. We
|
|
|
|
|
;; cannot test older Emacsen, therefore.
|
|
|
|
|
(skip-unless (tramp--test-emacs26-p))
|
|
|
|
|
|
2017-11-29 09:37:42 +01:00
|
|
|
|
;; Tramp is neither loaded at Emacs startup, nor when completing a
|
|
|
|
|
;; non-Tramp file name like "/foo". Completing a Tramp-alike file
|
|
|
|
|
;; name like "/foo:" autoloads Tramp, when `tramp-mode' is t.
|
|
|
|
|
(let ((default-directory (expand-file-name temporary-file-directory))
|
|
|
|
|
(code
|
|
|
|
|
"(progn \
|
|
|
|
|
(setq tramp-mode %s) \
|
|
|
|
|
(message \"Tramp loaded: %%s\" (featurep 'tramp)) \
|
|
|
|
|
(file-name-all-completions \"/foo\" \"/\") \
|
|
|
|
|
(message \"Tramp loaded: %%s\" (featurep 'tramp)) \
|
|
|
|
|
(file-name-all-completions \"/foo:\" \"/\") \
|
|
|
|
|
(message \"Tramp loaded: %%s\" (featurep 'tramp)))"))
|
2017-12-08 16:37:53 +01:00
|
|
|
|
;; Tramp doesn't load when `tramp-mode' is nil.
|
|
|
|
|
(dolist (tm '(t nil))
|
2017-11-27 13:31:53 +01:00
|
|
|
|
(should
|
|
|
|
|
(string-match
|
2017-11-29 09:37:42 +01:00
|
|
|
|
(format
|
|
|
|
|
"Tramp loaded: nil[\n\r]+Tramp loaded: nil[\n\r]+Tramp loaded: %s[\n\r]+"
|
|
|
|
|
tm)
|
2017-11-27 13:31:53 +01:00
|
|
|
|
(shell-command-to-string
|
|
|
|
|
(format
|
|
|
|
|
"%s -batch -Q -L %s --eval %s"
|
2018-01-07 18:50:06 +01:00
|
|
|
|
(shell-quote-argument
|
|
|
|
|
(expand-file-name invocation-name invocation-directory))
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(mapconcat #'shell-quote-argument load-path " -L ")
|
2017-11-29 09:37:42 +01:00
|
|
|
|
(shell-quote-argument (format code tm)))))))))
|
2017-11-27 13:31:53 +01:00
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test44-recursive-load ()
|
2014-04-18 20:58:13 +02:00
|
|
|
|
"Check that Tramp does not fail due to recursive load."
|
|
|
|
|
(skip-unless (tramp--test-enabled))
|
|
|
|
|
|
2017-07-05 17:03:42 +02:00
|
|
|
|
(let ((default-directory (expand-file-name temporary-file-directory)))
|
|
|
|
|
(dolist (code
|
|
|
|
|
(list
|
|
|
|
|
(format
|
|
|
|
|
"(expand-file-name %S)" tramp-test-temporary-file-directory)
|
|
|
|
|
(format
|
|
|
|
|
"(let ((default-directory %S)) (expand-file-name %S))"
|
|
|
|
|
tramp-test-temporary-file-directory
|
|
|
|
|
temporary-file-directory)))
|
|
|
|
|
(should-not
|
|
|
|
|
(string-match
|
|
|
|
|
"Recursive load"
|
|
|
|
|
(shell-command-to-string
|
|
|
|
|
(format
|
|
|
|
|
"%s -batch -Q -L %s --eval %s"
|
2018-01-07 18:50:06 +01:00
|
|
|
|
(shell-quote-argument
|
|
|
|
|
(expand-file-name invocation-name invocation-directory))
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(mapconcat #'shell-quote-argument load-path " -L ")
|
2017-07-05 17:03:42 +02:00
|
|
|
|
(shell-quote-argument code))))))))
|
2014-04-18 20:58:13 +02:00
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test44-remote-load-path ()
|
2017-06-16 14:46:25 +02:00
|
|
|
|
"Check that Tramp autoloads its packages with remote `load-path'."
|
2017-12-08 16:37:53 +01:00
|
|
|
|
;; The autoloaded Tramp objects are different since Emacs 26.1. We
|
|
|
|
|
;; cannot test older Emacsen, therefore.
|
|
|
|
|
(skip-unless (tramp--test-emacs26-p))
|
|
|
|
|
|
2017-06-16 14:46:25 +02:00
|
|
|
|
;; `tramp-cleanup-all-connections' is autoloaded from tramp-cmds.el.
|
|
|
|
|
;; It shall still work, when a remote file name is in the
|
|
|
|
|
;; `load-path'.
|
2017-07-05 17:03:42 +02:00
|
|
|
|
(let ((default-directory (expand-file-name temporary-file-directory))
|
|
|
|
|
(code
|
|
|
|
|
"(let ((force-load-messages t) \
|
|
|
|
|
(load-path (cons \"/foo:bar:\" load-path))) \
|
2017-06-16 14:46:25 +02:00
|
|
|
|
(tramp-cleanup-all-connections))"))
|
|
|
|
|
(should
|
|
|
|
|
(string-match
|
|
|
|
|
(format
|
|
|
|
|
"Loading %s"
|
2018-12-18 15:34:01 -05:00
|
|
|
|
(regexp-quote
|
|
|
|
|
(expand-file-name
|
|
|
|
|
"tramp-cmds" (file-name-directory (locate-library "tramp")))))
|
2017-06-16 14:46:25 +02:00
|
|
|
|
(shell-command-to-string
|
|
|
|
|
(format
|
|
|
|
|
"%s -batch -Q -L %s -l tramp-sh --eval %s"
|
2018-01-07 18:50:06 +01:00
|
|
|
|
(shell-quote-argument
|
|
|
|
|
(expand-file-name invocation-name invocation-directory))
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(mapconcat #'shell-quote-argument load-path " -L ")
|
2017-06-16 14:46:25 +02:00
|
|
|
|
(shell-quote-argument code)))))))
|
|
|
|
|
|
Provide tramp-sh-handle-make-process
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `tramp-sh-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-sh-handle-make-process): New defun, derived from
`tramp-sh-handle-start-file-process'. (Bug#28691)
* lisp/net/tramp.el (tramp-handle-start-file-process): New defun.
* test/lisp/net/tramp-tests.el (tramp-test30-make-process):
New test.
(tramp-test31-interrupt-process, tramp-test32-shell-command)
(tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test35-remote-path, tramp-test36-vc-registered)
(tramp-test37-make-auto-save-file-name)
(tramp-test38-find-backup-file-name)
(tramp-test39-make-nearby-temp-file)
(tramp-test40-special-characters)
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls, tramp-test41-utf8)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls, tramp-test42-file-system-info)
(tramp-test43-asynchronous-requests, tramp-test44-auto-load)
(tramp-test44-delay-load, tramp-test44-recursive-load)
(tramp-test44-remote-load-path, tramp-test45-unload): Rename.
2018-12-24 14:28:31 +01:00
|
|
|
|
(ert-deftest tramp-test45-unload ()
|
2014-04-18 20:58:13 +02:00
|
|
|
|
"Check that Tramp and its subpackages unload completely.
|
|
|
|
|
Since it unloads Tramp, it shall be the last test to run."
|
2018-08-09 14:08:25 +02:00
|
|
|
|
:tags '(:expensive-test)
|
2017-05-19 13:57:36 +02:00
|
|
|
|
(skip-unless noninteractive)
|
2017-10-23 12:46:32 +02:00
|
|
|
|
;; The autoloaded Tramp objects are different since Emacs 26.1. We
|
|
|
|
|
;; cannot test older Emacsen, therefore.
|
|
|
|
|
(skip-unless (tramp--test-emacs26-p))
|
2017-05-19 13:57:36 +02:00
|
|
|
|
|
2018-08-09 14:08:25 +02:00
|
|
|
|
;; We have autoloaded objects from tramp.el and tramp-archive.el.
|
|
|
|
|
;; In order to remove them, we first need to load both packages.
|
|
|
|
|
(require 'tramp)
|
|
|
|
|
(require 'tramp-archive)
|
|
|
|
|
(should (featurep 'tramp))
|
|
|
|
|
(should (featurep 'tramp-archive))
|
|
|
|
|
;; This unloads also tramp-archive.el and tramp-theme.el if needed.
|
|
|
|
|
(unload-feature 'tramp 'force)
|
|
|
|
|
;; No Tramp feature must be left.
|
|
|
|
|
(should-not (featurep 'tramp))
|
|
|
|
|
(should-not (featurep 'tramp-archive))
|
|
|
|
|
(should-not (featurep 'tramp-theme))
|
|
|
|
|
(should-not
|
|
|
|
|
(all-completions
|
|
|
|
|
"tramp" (delq 'tramp-tests (delq 'tramp-archive-tests features))))
|
|
|
|
|
;; `file-name-handler-alist' must be clean.
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(should-not (all-completions "tramp" (mapcar #'cdr file-name-handler-alist)))
|
2018-08-09 14:08:25 +02:00
|
|
|
|
;; There shouldn't be left a bound symbol, except buffer-local
|
|
|
|
|
;; variables, and autoload functions. We do not regard our test
|
|
|
|
|
;; symbols, and the Tramp unload hooks.
|
|
|
|
|
(mapatoms
|
|
|
|
|
(lambda (x)
|
|
|
|
|
(and (or (and (boundp x) (null (local-variable-if-set-p x)))
|
|
|
|
|
(and (functionp x) (null (autoloadp (symbol-function x)))))
|
|
|
|
|
(string-match "^tramp" (symbol-name x))
|
|
|
|
|
(not (string-match "^tramp\\(-archive\\)?--?test" (symbol-name x)))
|
|
|
|
|
(not (string-match "unload-hook$" (symbol-name x)))
|
|
|
|
|
(ert-fail (format "`%s' still bound" x)))))
|
|
|
|
|
;; The defstruct `tramp-file-name' and all its internal functions
|
|
|
|
|
;; shall be purged.
|
2019-05-18 16:04:58 +02:00
|
|
|
|
(should-not (with-no-warnings (cl--find-class 'tramp-file-name)))
|
2018-08-09 14:08:25 +02:00
|
|
|
|
(mapatoms
|
|
|
|
|
(lambda (x)
|
|
|
|
|
(and (functionp x)
|
|
|
|
|
(string-match "tramp-file-name" (symbol-name x))
|
|
|
|
|
(ert-fail (format "Structure function `%s' still exists" x)))))
|
|
|
|
|
;; There shouldn't be left a hook function containing a Tramp
|
|
|
|
|
;; function. We do not regard the Tramp unload hooks.
|
|
|
|
|
(mapatoms
|
|
|
|
|
(lambda (x)
|
|
|
|
|
(and (boundp x)
|
|
|
|
|
(string-match "-\\(hook\\|function\\)s?$" (symbol-name x))
|
|
|
|
|
(not (string-match "unload-hook$" (symbol-name x)))
|
|
|
|
|
(consp (symbol-value x))
|
|
|
|
|
(ignore-errors (all-completions "tramp" (symbol-value x)))
|
|
|
|
|
(ert-fail (format "Hook `%s' still contains Tramp function" x))))))
|
2014-04-18 20:58:13 +02:00
|
|
|
|
|
2017-11-29 09:37:42 +01:00
|
|
|
|
(defun tramp-test-all (&optional interactive)
|
|
|
|
|
"Run all tests for \\[tramp]."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(funcall
|
2019-02-28 10:33:05 +01:00
|
|
|
|
(if interactive
|
|
|
|
|
#'ert-run-tests-interactively #'ert-run-tests-batch) "^tramp"))
|
2017-11-29 09:37:42 +01:00
|
|
|
|
|
2013-11-05 15:46:57 +01:00
|
|
|
|
;; TODO:
|
|
|
|
|
|
|
|
|
|
;; * dired-compress-file
|
|
|
|
|
;; * dired-uncache
|
2017-12-08 16:37:53 +01:00
|
|
|
|
;; * file-equal-p (partly done in `tramp-test21-file-links')
|
|
|
|
|
;; * file-in-directory-p
|
Implement quoting the local part of a remote file name
* doc/emacs/files.texi (Quoted File Names):
* etc/NEWS: Mention quoting the local part of a remote file name.
* lisp/net/tramp.el (tramp-dissect-file-name): Check with
`tramp-tramp-file-p'.
(tramp-quoted-name-p, tramp-quote-name, tramp-unquote-name):
New defsubst.
(tramp-handle-substitute-in-file-name)
(tramp-handle-make-auto-save-file-name): Handle quoted files.
(tramp-shell-quote-argument): Unquote argument.
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename):
Handle quoted files.
* test/lisp/net/tramp-tests.el (tramp--test-expensive-test): New defvar.
(tramp--test-make-temp-name): New argument QUOTED.
(tramp-test01-file-name-syntax)
(tramp-test02-file-name-dissect)
(tramp-test04-substitute-in-file-name)
(tramp-test05-expand-file-name, tramp-test07-file-exists-p)
(tramp-test08-file-local-copy)
(tramp-test09-insert-file-contents)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test13-make-directory)
(tramp-test14-delete-directory, tramp-test15-copy-directory)
(tramp-test16-directory-files)
(tramp-test17-insert-directory)
(tramp-test18-file-attributes)
(tramp-test19-directory-files-and-attributes)
(tramp-test20-file-modes, tramp-test21-file-links)
(tramp-test22-file-times, tramp-test23-visited-file-modtime)
(tramp-test24-file-name-completion, tramp-test25-load)
(tramp-test26-process-file, tramp-test27-start-file-process)
(tramp-test28-shell-command, tramp-test30-vc-registered)
(tramp-test31-make-auto-save-file-name)
(tramp--test-check-files)
(tramp-test35-asynchronous-requests): Test also quoted file names.
(tramp--test-shell-command-to-string-asynchronously): Rename.
(tramp-test29-environment-variables): Use it.
2016-12-04 12:12:06 +01:00
|
|
|
|
;; * file-name-case-insensitive-p
|
2019-01-22 15:22:52 +01:00
|
|
|
|
;; * tramp-set-file-uid-gid
|
2013-11-05 15:46:57 +01:00
|
|
|
|
|
2014-06-15 17:56:58 +02:00
|
|
|
|
;; * Work on skipped tests. Make a comment, when it is impossible.
|
2018-06-20 12:13:56 +02:00
|
|
|
|
;; * Revisit expensive tests, once problems in `tramp-error' are solved.
|
2017-05-16 14:49:51 +02:00
|
|
|
|
;; * Fix `tramp-test05-expand-file-name-relative' in `expand-file-name'.
|
2016-05-11 10:12:26 +02:00
|
|
|
|
;; * Fix `tramp-test06-directory-file-name' for `ftp'.
|
Add new Tramp connection method "owncloud"
* doc/misc/tramp.texi (all): Use @acronym{GNOME} thoroughly.
(Using GNOME Online Accounts based methods): Rename from
"Using Google Drive". Add `owncloud'.
(GVFS based methods): Add `owncloud'.
* etc/NEWS: Add Tramp connection method "owncloud".
* lisp/net/tramp-gvfs.el (tramp-gvfs-methods): Add "owncloud".
Remove goa methods if not supported.
(tramp-goa-methods, tramp-goa-service, tramp-goa-path)
(tramp-goa-path-accounts, tramp-goa-interface-documents)
(tramp-goa-interface-printers, tramp-goa-interface-files)
(tramp-goa-interface-contacts, tramp-goa-interface-calendar)
(tramp-goa-interface-oauth2based)
(tramp-goa-interface-account, tramp-goa-identity-regexp)
(tramp-goa-interface-mail, tramp-goa-interface-chat)
(tramp-goa-interface-photos, tramp-goa-path-manager)
(tramp-goa-interface-documents)
(tramp-gvfs-owncloud-default-prefix)
(tramp-gvfs-owncloud-default-prefix-regexp): New defconst.
(tramp-goa-name): New defstruct.
(tramp-gvfs-stringify-dbus-message): Handle all consp messages.
(tramp-dbus-function, tramp-gvfs-get-remote-prefix)
(tramp-get-goa-accounts): New defun.
(with-tramp-dbus-call-method): Use it.
(with-tramp-dbus-get-all-properties): New defmacro.
(tramp-gvfs-url-file-name)
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p, tramp-gvfs-mount-spec):
Map between "owncloud" and "davs".
(tramp-gvfs-maybe-open-connection): Set "vector" connection property.
* test/lisp/net/tramp-tests.el (tramp-gvfs-handler-askquestion):
Suppress run in tests.
(tramp--test-owncloud-p): New defun.
(tramp-test11-copy-file, tramp-test12-rename-file): Use it.
2018-01-05 21:04:39 +01:00
|
|
|
|
;; * Investigate, why `tramp-test11-copy-file' and `tramp-test12-rename-file'
|
2018-08-08 15:38:10 +02:00
|
|
|
|
;; do not work properly for `nextcloud'.
|
2019-02-19 14:00:17 +01:00
|
|
|
|
;; * Fix `tramp-test29-start-file-process' and
|
|
|
|
|
;; `tramp-test30-make-process' on MS Windows (`process-send-eof'?).
|
2019-06-04 12:51:45 +02:00
|
|
|
|
;; * Implement `tramp-test31-interrupt-process' for `adb'.
|
2019-06-10 17:53:15 +02:00
|
|
|
|
;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'. A remote
|
|
|
|
|
;; file name operation cannot run in the timer. Remove `:unstable' tag?
|
2013-11-27 15:23:32 +01:00
|
|
|
|
|
2013-11-05 15:46:57 +01:00
|
|
|
|
(provide 'tramp-tests)
|
|
|
|
|
;;; tramp-tests.el ends here
|