* net/tramp-sh.el (tramp-remote-process-environment): Set "LC_ALL" to
[bpt/emacs.git] / test / automated / tramp-tests.el
CommitLineData
a213a541
MA
1;;; tramp-tests.el --- Tests of remote file access
2
3;; Copyright (C) 2013 Free Software Foundation, Inc.
4
5;; Author: Michael Albinus <michael.albinus@gmx.de>
6
7;; This program is free software: you can redistribute it and/or
8;; modify it under the terms of the GNU General Public License as
9;; published by the Free Software Foundation, either version 3 of the
10;; License, or (at your option) any later version.
11;;
12;; This program is distributed in the hope that it will be useful, but
13;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15;; General Public License for more details.
16;;
17;; You should have received a copy of the GNU General Public License
18;; along with this program. If not, see `http://www.gnu.org/licenses/'.
19
20;;; Commentary:
21
1c49d6c2
MA
22;; The tests require a recent ert.el from Emacs 24.4.
23
24;; Some of the tests require access to a remote host files. Set
8ee0219f
MA
25;; $TRAMP_TEST_TEMPORARY_FILE_DIRECTORY to a suitable value in order
26;; to overwrite the default value. If you want to skip tests
27;; accessing a remote host, set this environment variable to
28;; "/dev/null" or whatever is appropriate on your system.
a213a541 29
8ee0219f
MA
30;; When running the tests in batch mode, it must NOT require an
31;; interactive password prompt unless the environment variable
32;; $TRAMP_TEST_ALLOW_PASSWORD is set.
1c49d6c2
MA
33
34;; A whole test run can be performed calling the command `tramp-test-all'.
a213a541
MA
35
36;;; Code:
37
38(require 'ert)
39(require 'tramp)
40
41;; There is no default value on w32 systems, which could work out of the box.
42(defconst tramp-test-temporary-file-directory
8ee0219f
MA
43 (cond
44 ((getenv "TRAMP_TEST_TEMPORARY_FILE_DIRECTORY"))
45 ((eq system-type 'windows-nt) null-device)
46 (t (format "/ssh::%s" temporary-file-directory)))
a213a541
MA
47 "Temporary directory for Tramp tests.")
48
49(setq tramp-verbose 0
50 tramp-message-show-message nil)
8ee0219f
MA
51
52;; Disable interactive passwords in batch mode.
53(when (and noninteractive (not (getenv "TRAMP_TEST_ALLOW_PASSWORD")))
54 (defalias 'tramp-read-passwd 'ignore))
55
1c49d6c2
MA
56;; This shall happen on hydra only.
57(when (getenv "NIX_STORE")
58 (add-to-list 'tramp-remote-path 'tramp-own-remote-path))
a213a541
MA
59
60(defvar tramp--test-enabled-checked nil
61 "Cached result of `tramp--test-enabled'.
62If the function did run, the value is a cons cell, the `cdr'
63being the result.")
64
65(defun tramp--test-enabled ()
66 "Whether remote file access is enabled."
67 (unless (consp tramp--test-enabled-checked)
68 (setq
69 tramp--test-enabled-checked
70 (cons
71 t (ignore-errors
72 (and
73 (file-remote-p tramp-test-temporary-file-directory)
74 (file-directory-p tramp-test-temporary-file-directory)
75 (file-writable-p tramp-test-temporary-file-directory))))))
76 ;; Return result.
77 (cdr tramp--test-enabled-checked))
78
79(defun tramp--test-make-temp-name ()
80 "Create a temporary file name for test."
81 (expand-file-name
82 (make-temp-name "tramp-test") tramp-test-temporary-file-directory))
83
84(ert-deftest tramp-test00-availability ()
85 "Test availability of Tramp functions."
86 :expected-result (if (tramp--test-enabled) :passed :failed)
87 (should (ignore-errors
88 (and
89 (file-remote-p tramp-test-temporary-file-directory)
90 (file-directory-p tramp-test-temporary-file-directory)
91 (file-writable-p tramp-test-temporary-file-directory)))))
92
93(ert-deftest tramp-test01-file-name-syntax ()
94 "Check remote file name syntax."
95 ;; Simple cases.
96 (should (tramp-tramp-file-p "/method::"))
97 (should (tramp-tramp-file-p "/host:"))
98 (should (tramp-tramp-file-p "/user@:"))
99 (should (tramp-tramp-file-p "/user@host:"))
100 (should (tramp-tramp-file-p "/method:host:"))
101 (should (tramp-tramp-file-p "/method:user@:"))
102 (should (tramp-tramp-file-p "/method:user@host:"))
103 (should (tramp-tramp-file-p "/method:user@email@host:"))
104
105 ;; Using a port.
106 (should (tramp-tramp-file-p "/host#1234:"))
107 (should (tramp-tramp-file-p "/user@host#1234:"))
108 (should (tramp-tramp-file-p "/method:host#1234:"))
109 (should (tramp-tramp-file-p "/method:user@host#1234:"))
110
111 ;; Using an IPv4 address.
112 (should (tramp-tramp-file-p "/1.2.3.4:"))
113 (should (tramp-tramp-file-p "/user@1.2.3.4:"))
114 (should (tramp-tramp-file-p "/method:1.2.3.4:"))
115 (should (tramp-tramp-file-p "/method:user@1.2.3.4:"))
116
117 ;; Using an IPv6 address.
118 (should (tramp-tramp-file-p "/[]:"))
119 (should (tramp-tramp-file-p "/[::1]:"))
120 (should (tramp-tramp-file-p "/user@[::1]:"))
121 (should (tramp-tramp-file-p "/method:[::1]:"))
122 (should (tramp-tramp-file-p "/method:user@[::1]:"))
123
124 ;; Local file name part.
125 (should (tramp-tramp-file-p "/host:/:"))
126 (should (tramp-tramp-file-p "/method:::"))
127 (should (tramp-tramp-file-p "/method::/path/to/file"))
128 (should (tramp-tramp-file-p "/method::file"))
129
130 ;; Multihop.
131 (should (tramp-tramp-file-p "/method1:|method2::"))
132 (should (tramp-tramp-file-p "/method1:host1|host2:"))
133 (should (tramp-tramp-file-p "/method1:host1|method2:host2:"))
134 (should (tramp-tramp-file-p "/method1:user1@host1|method2:user2@host2:"))
135 (should (tramp-tramp-file-p
136 "/method1:user1@host1|method2:user2@host2|method3:user3@host3:"))
137
138 ;; No strings.
139 (should-not (tramp-tramp-file-p nil))
140 (should-not (tramp-tramp-file-p 'symbol))
141 ;; "/:" suppresses file name handlers.
142 (should-not (tramp-tramp-file-p "/::"))
143 (should-not (tramp-tramp-file-p "/:@:"))
144 (should-not (tramp-tramp-file-p "/:[]:"))
145 ;; Multihops require a method.
146 (should-not (tramp-tramp-file-p "/host1|host2:"))
147 ;; Methods or hostnames shall be at least two characters on MS Windows.
148 (when (memq system-type '(cygwin windows-nt))
149 (should-not (tramp-tramp-file-p "/c:/path/to/file"))
150 (should-not (tramp-tramp-file-p "/c::/path/to/file"))))
151
152(ert-deftest tramp-test02-file-name-dissect ()
153 "Check remote file name components."
154 (let ((tramp-default-method "default-method")
155 (tramp-default-user "default-user")
156 (tramp-default-host "default-host"))
157 ;; Expand `tramp-default-user' and `tramp-default-host'.
158 (should (string-equal
159 (file-remote-p "/method::")
160 (format "/%s:%s@%s:" "method" "default-user" "default-host")))
161 (should (string-equal (file-remote-p "/method::" 'method) "method"))
162 (should (string-equal (file-remote-p "/method::" 'user) "default-user"))
163 (should (string-equal (file-remote-p "/method::" 'host) "default-host"))
164 (should (string-equal (file-remote-p "/method::" 'localname) ""))
165
166 ;; Expand `tramp-default-method' and `tramp-default-user'.
167 (should (string-equal
168 (file-remote-p "/host:")
169 (format "/%s:%s@%s:" "default-method" "default-user" "host")))
170 (should (string-equal (file-remote-p "/host:" 'method) "default-method"))
171 (should (string-equal (file-remote-p "/host:" 'user) "default-user"))
172 (should (string-equal (file-remote-p "/host:" 'host) "host"))
173 (should (string-equal (file-remote-p "/host:" 'localname) ""))
174
175 ;; Expand `tramp-default-method' and `tramp-default-host'.
176 (should (string-equal
177 (file-remote-p "/user@:")
178 (format "/%s:%s@%s:" "default-method""user" "default-host")))
179 (should (string-equal (file-remote-p "/user@:" 'method) "default-method"))
180 (should (string-equal (file-remote-p "/user@:" 'user) "user"))
181 (should (string-equal (file-remote-p "/user@:" 'host) "default-host"))
182 (should (string-equal (file-remote-p "/user@:" 'localname) ""))
183
184 ;; Expand `tramp-default-method'.
185 (should (string-equal
186 (file-remote-p "/user@host:")
187 (format "/%s:%s@%s:" "default-method" "user" "host")))
188 (should (string-equal
189 (file-remote-p "/user@host:" 'method) "default-method"))
190 (should (string-equal (file-remote-p "/user@host:" 'user) "user"))
191 (should (string-equal (file-remote-p "/user@host:" 'host) "host"))
192 (should (string-equal (file-remote-p "/user@host:" 'localname) ""))
193
194 ;; Expand `tramp-default-user'.
195 (should (string-equal
196 (file-remote-p "/method:host:")
197 (format "/%s:%s@%s:" "method" "default-user" "host")))
198 (should (string-equal (file-remote-p "/method:host:" 'method) "method"))
199 (should (string-equal (file-remote-p "/method:host:" 'user) "default-user"))
200 (should (string-equal (file-remote-p "/method:host:" 'host) "host"))
201 (should (string-equal (file-remote-p "/method:host:" 'localname) ""))
202
203 ;; Expand `tramp-default-host'.
204 (should (string-equal
205 (file-remote-p "/method:user@:")
206 (format "/%s:%s@%s:" "method" "user" "default-host")))
207 (should (string-equal (file-remote-p "/method:user@:" 'method) "method"))
208 (should (string-equal (file-remote-p "/method:user@:" 'user) "user"))
209 (should (string-equal (file-remote-p "/method:user@:" 'host)
210 "default-host"))
211 (should (string-equal (file-remote-p "/method:user@:" 'localname) ""))
212
213 ;; No expansion.
214 (should (string-equal
215 (file-remote-p "/method:user@host:")
216 (format "/%s:%s@%s:" "method" "user" "host")))
217 (should (string-equal
218 (file-remote-p "/method:user@host:" 'method) "method"))
219 (should (string-equal (file-remote-p "/method:user@host:" 'user) "user"))
220 (should (string-equal (file-remote-p "/method:user@host:" 'host) "host"))
221 (should (string-equal (file-remote-p "/method:user@host:" 'localname) ""))
222
223 ;; No expansion.
224 (should (string-equal
225 (file-remote-p "/method:user@email@host:")
226 (format "/%s:%s@%s:" "method" "user@email" "host")))
227 (should (string-equal
228 (file-remote-p "/method:user@email@host:" 'method) "method"))
229 (should (string-equal
230 (file-remote-p "/method:user@email@host:" 'user) "user@email"))
231 (should (string-equal
232 (file-remote-p "/method:user@email@host:" 'host) "host"))
233 (should (string-equal
234 (file-remote-p "/method:user@email@host:" 'localname) ""))
235
236 ;; Expand `tramp-default-method' and `tramp-default-user'.
237 (should (string-equal
238 (file-remote-p "/host#1234:")
239 (format "/%s:%s@%s:" "default-method" "default-user" "host#1234")))
240 (should (string-equal
241 (file-remote-p "/host#1234:" 'method) "default-method"))
242 (should (string-equal (file-remote-p "/host#1234:" 'user) "default-user"))
243 (should (string-equal (file-remote-p "/host#1234:" 'host) "host#1234"))
244 (should (string-equal (file-remote-p "/host#1234:" 'localname) ""))
245
246 ;; Expand `tramp-default-method'.
247 (should (string-equal
248 (file-remote-p "/user@host#1234:")
249 (format "/%s:%s@%s:" "default-method" "user" "host#1234")))
250 (should (string-equal
251 (file-remote-p "/user@host#1234:" 'method) "default-method"))
252 (should (string-equal (file-remote-p "/user@host#1234:" 'user) "user"))
253 (should (string-equal (file-remote-p "/user@host#1234:" 'host) "host#1234"))
254 (should (string-equal (file-remote-p "/user@host#1234:" 'localname) ""))
255
256 ;; Expand `tramp-default-user'.
257 (should (string-equal
258 (file-remote-p "/method:host#1234:")
259 (format "/%s:%s@%s:" "method" "default-user" "host#1234")))
260 (should (string-equal
261 (file-remote-p "/method:host#1234:" 'method) "method"))
262 (should (string-equal
263 (file-remote-p "/method:host#1234:" 'user) "default-user"))
264 (should (string-equal
265 (file-remote-p "/method:host#1234:" 'host) "host#1234"))
266 (should (string-equal (file-remote-p "/method:host#1234:" 'localname) ""))
267
268 ;; No expansion.
269 (should (string-equal
270 (file-remote-p "/method:user@host#1234:")
271 (format "/%s:%s@%s:" "method" "user" "host#1234")))
272 (should (string-equal
273 (file-remote-p "/method:user@host#1234:" 'method) "method"))
274 (should (string-equal
275 (file-remote-p "/method:user@host#1234:" 'user) "user"))
276 (should (string-equal
277 (file-remote-p "/method:user@host#1234:" 'host) "host#1234"))
278 (should (string-equal
279 (file-remote-p "/method:user@host#1234:" 'localname) ""))
280
281 ;; Expand `tramp-default-method' and `tramp-default-user'.
282 (should (string-equal
283 (file-remote-p "/1.2.3.4:")
284 (format "/%s:%s@%s:" "default-method" "default-user" "1.2.3.4")))
285 (should (string-equal (file-remote-p "/1.2.3.4:" 'method) "default-method"))
286 (should (string-equal (file-remote-p "/1.2.3.4:" 'user) "default-user"))
287 (should (string-equal (file-remote-p "/1.2.3.4:" 'host) "1.2.3.4"))
288 (should (string-equal (file-remote-p "/1.2.3.4:" 'localname) ""))
289
290 ;; Expand `tramp-default-method'.
291 (should (string-equal
292 (file-remote-p "/user@1.2.3.4:")
293 (format "/%s:%s@%s:" "default-method" "user" "1.2.3.4")))
294 (should (string-equal
295 (file-remote-p "/user@1.2.3.4:" 'method) "default-method"))
296 (should (string-equal (file-remote-p "/user@1.2.3.4:" 'user) "user"))
297 (should (string-equal (file-remote-p "/user@1.2.3.4:" 'host) "1.2.3.4"))
298 (should (string-equal (file-remote-p "/user@1.2.3.4:" 'localname) ""))
299
300 ;; Expand `tramp-default-user'.
301 (should (string-equal
302 (file-remote-p "/method:1.2.3.4:")
303 (format "/%s:%s@%s:" "method" "default-user" "1.2.3.4")))
304 (should (string-equal (file-remote-p "/method:1.2.3.4:" 'method) "method"))
305 (should (string-equal
306 (file-remote-p "/method:1.2.3.4:" 'user) "default-user"))
307 (should (string-equal (file-remote-p "/method:1.2.3.4:" 'host) "1.2.3.4"))
308 (should (string-equal (file-remote-p "/method:1.2.3.4:" 'localname) ""))
309
310 ;; No expansion.
311 (should (string-equal
312 (file-remote-p "/method:user@1.2.3.4:")
313 (format "/%s:%s@%s:" "method" "user" "1.2.3.4")))
314 (should (string-equal
315 (file-remote-p "/method:user@1.2.3.4:" 'method) "method"))
316 (should (string-equal (file-remote-p "/method:user@1.2.3.4:" 'user) "user"))
317 (should (string-equal
318 (file-remote-p "/method:user@1.2.3.4:" 'host) "1.2.3.4"))
319 (should (string-equal
320 (file-remote-p "/method:user@1.2.3.4:" 'localname) ""))
321
927fbd6b
MA
322 ;; Expand `tramp-default-method', `tramp-default-user' and
323 ;; `tramp-default-host'.
324 (should (string-equal
325 (file-remote-p "/[]:")
326 (format
327 "/%s:%s@%s:" "default-method" "default-user" "default-host")))
328 (should (string-equal (file-remote-p "/[]:" 'method) "default-method"))
329 (should (string-equal (file-remote-p "/[]:" 'user) "default-user"))
330 (should (string-equal (file-remote-p "/[]:" 'host) "default-host"))
331 (should (string-equal (file-remote-p "/[]:" 'localname) ""))
332
333 ;; Expand `tramp-default-method' and `tramp-default-user'.
334 (let ((tramp-default-host "::1"))
335 (should (string-equal
336 (file-remote-p "/[]:")
337 (format "/%s:%s@%s:" "default-method" "default-user" "[::1]")))
338 (should (string-equal (file-remote-p "/[]:" 'method) "default-method"))
339 (should (string-equal (file-remote-p "/[]:" 'user) "default-user"))
340 (should (string-equal (file-remote-p "/[]:" 'host) "::1"))
341 (should (string-equal (file-remote-p "/[]:" 'localname) "")))
a213a541
MA
342
343 ;; Expand `tramp-default-method' and `tramp-default-user'.
344 (should (string-equal
345 (file-remote-p "/[::1]:")
346 (format "/%s:%s@%s:" "default-method" "default-user" "[::1]")))
347 (should (string-equal (file-remote-p "/[::1]:" 'method) "default-method"))
348 (should (string-equal (file-remote-p "/[::1]:" 'user) "default-user"))
349 (should (string-equal (file-remote-p "/[::1]:" 'host) "::1"))
350 (should (string-equal (file-remote-p "/[::1]:" 'localname) ""))
351
352 ;; Expand `tramp-default-method'.
353 (should (string-equal
354 (file-remote-p "/user@[::1]:")
355 (format "/%s:%s@%s:" "default-method" "user" "[::1]")))
356 (should (string-equal
357 (file-remote-p "/user@[::1]:" 'method) "default-method"))
358 (should (string-equal (file-remote-p "/user@[::1]:" 'user) "user"))
359 (should (string-equal (file-remote-p "/user@[::1]:" 'host) "::1"))
360 (should (string-equal (file-remote-p "/user@[::1]:" 'localname) ""))
361
362 ;; Expand `tramp-default-user'.
363 (should (string-equal
364 (file-remote-p "/method:[::1]:")
365 (format "/%s:%s@%s:" "method" "default-user" "[::1]")))
366 (should (string-equal (file-remote-p "/method:[::1]:" 'method) "method"))
367 (should (string-equal
368 (file-remote-p "/method:[::1]:" 'user) "default-user"))
369 (should (string-equal (file-remote-p "/method:[::1]:" 'host) "::1"))
370 (should (string-equal (file-remote-p "/method:[::1]:" 'localname) ""))
371
372 ;; No expansion.
373 (should (string-equal
374 (file-remote-p "/method:user@[::1]:")
375 (format "/%s:%s@%s:" "method" "user" "[::1]")))
376 (should (string-equal
377 (file-remote-p "/method:user@[::1]:" 'method) "method"))
378 (should (string-equal (file-remote-p "/method:user@[::1]:" 'user) "user"))
379 (should (string-equal (file-remote-p "/method:user@[::1]:" 'host) "::1"))
380 (should (string-equal
381 (file-remote-p "/method:user@[::1]:" 'localname) ""))
382
383 ;; Local file name part.
384 (should (string-equal (file-remote-p "/host:/:" 'localname) "/:"))
385 (should (string-equal (file-remote-p "/method:::" 'localname) ":"))
386 (should (string-equal (file-remote-p "/method:: " 'localname) " "))
387 (should (string-equal (file-remote-p "/method::file" 'localname) "file"))
388 (should (string-equal
389 (file-remote-p "/method::/path/to/file" 'localname)
390 "/path/to/file"))
391
392 ;; Multihop.
393 (should
394 (string-equal
395 (file-remote-p "/method1:user1@host1|method2:user2@host2:/path/to/file")
396 (format "/%s:%s@%s:" "method2" "user2" "host2")))
397 (should
398 (string-equal
399 (file-remote-p
400 "/method1:user1@host1|method2:user2@host2:/path/to/file" 'method)
401 "method2"))
402 (should
403 (string-equal
404 (file-remote-p
405 "/method1:user1@host1|method2:user2@host2:/path/to/file" 'user)
406 "user2"))
407 (should
408 (string-equal
409 (file-remote-p
410 "/method1:user1@host1|method2:user2@host2:/path/to/file" 'host)
411 "host2"))
412 (should
413 (string-equal
414 (file-remote-p
415 "/method1:user1@host1|method2:user2@host2:/path/to/file" 'localname)
416 "/path/to/file"))
417
418 (should
419 (string-equal
420 (file-remote-p
421 "/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file")
422 (format "/%s:%s@%s:" "method3" "user3" "host3")))
423 (should
424 (string-equal
425 (file-remote-p
426 "/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file"
427 'method)
428 "method3"))
429 (should
430 (string-equal
431 (file-remote-p
432 "/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file"
433 'user)
434 "user3"))
435 (should
436 (string-equal
437 (file-remote-p
438 "/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file"
439 'host)
440 "host3"))
441 (should
442 (string-equal
443 (file-remote-p
444 "/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file"
445 'localname)
446 "/path/to/file"))))
447
448(ert-deftest tramp-test03-file-name-defaults ()
449 "Check default values for some methods."
450 ;; Default values in tramp-adb.el.
451 (should (string-equal (file-remote-p "/adb::" 'host) ""))
452 ;; Default values in tramp-ftp.el.
453 (should (string-equal (file-remote-p "/ftp.host:" 'method) "ftp"))
454 (dolist (u '("ftp" "anonymous"))
455 (should (string-equal (file-remote-p (format "/%s@:" u) 'method) "ftp")))
456 ;; Default values in tramp-gvfs.el.
927fbd6b
MA
457 (when (and (load "tramp-gvfs" 'noerror 'nomessage)
458 (symbol-value 'tramp-gvfs-enabled))
459 (should (string-equal (file-remote-p "/synce::" 'user) nil)))
a213a541
MA
460 ;; Default values in tramp-gw.el.
461 (dolist (m '("tunnel" "socks"))
927fbd6b
MA
462 (should
463 (string-equal (file-remote-p (format "/%s::" m) 'user) (user-login-name))))
a213a541
MA
464 ;; Default values in tramp-sh.el.
465 (dolist (h `("127.0.0.1" "[::1]" "localhost" "localhost6" ,(system-name)))
466 (should (string-equal (file-remote-p (format "/root@%s:" h) 'method) "su")))
467 (dolist (m '("su" "sudo" "ksu"))
468 (should (string-equal (file-remote-p (format "/%s::" m) 'user) "root")))
469 (dolist (m '("rcp" "remcp" "rsh" "telnet" "krlogin" "fcp"))
927fbd6b
MA
470 (should
471 (string-equal (file-remote-p (format "/%s::" m) 'user) (user-login-name))))
a213a541
MA
472 ;; Default values in tramp-smb.el.
473 (should (string-equal (file-remote-p "/user%domain@host:" 'method) "smb"))
474 (should (string-equal (file-remote-p "/smb::" 'user) nil)))
475
476(ert-deftest tramp-test04-substitute-in-file-name ()
477 "Check `substitute-in-file-name'."
478 (should (string-equal (substitute-in-file-name "/method:host://foo") "/foo"))
927fbd6b
MA
479 (should
480 (string-equal
481 (substitute-in-file-name "/method:host:/path//foo") "/method:host:/foo"))
482 (should
483 (string-equal (substitute-in-file-name "/method:host:/path///foo") "/foo"))
484 (should
485 (string-equal
486 (substitute-in-file-name "/method:host:/path/~/foo") "/method:host:~/foo"))
487 (should
488 (string-equal (substitute-in-file-name "/method:host:/path//~/foo") "~/foo"))
a213a541
MA
489 (let (process-environment)
490 (should
927fbd6b
MA
491 (string-equal
492 (substitute-in-file-name "/method:host:/path/$FOO")
493 "/method:host:/path/$FOO"))
a213a541 494 (setenv "FOO" "bla")
927fbd6b
MA
495 (should
496 (string-equal
497 (substitute-in-file-name "/method:host:/path/$FOO")
498 "/method:host:/path/bla"))
499 (should
500 (string-equal
501 (substitute-in-file-name "/method:host:/path/$$FOO")
502 "/method:host:/path/$FOO"))))
a213a541
MA
503
504(ert-deftest tramp-test05-expand-file-name ()
505 "Check `expand-file-name'."
927fbd6b
MA
506 (should
507 (string-equal
508 (expand-file-name "/method:host:/path/./file") "/method:host:/path/file"))
509 (should
510 (string-equal
511 (expand-file-name "/method:host:/path/../file") "/method:host:/file")))
a213a541
MA
512
513(ert-deftest tramp-test06-directory-file-name ()
514 "Check `directory-file-name'.
515This checks also `file-name-as-directory', `file-name-directory'
516and `file-name-nondirectory'."
927fbd6b
MA
517 (should
518 (string-equal
519 (directory-file-name "/method:host:/path/to/file")
520 "/method:host:/path/to/file"))
521 (should
522 (string-equal
523 (directory-file-name "/method:host:/path/to/file/")
524 "/method:host:/path/to/file"))
525 (should
526 (string-equal
527 (file-name-as-directory "/method:host:/path/to/file")
528 "/method:host:/path/to/file/"))
529 (should
530 (string-equal
531 (file-name-as-directory "/method:host:/path/to/file/")
532 "/method:host:/path/to/file/"))
533 (should
534 (string-equal
535 (file-name-directory "/method:host:/path/to/file")
536 "/method:host:/path/to/"))
537 (should
538 (string-equal
539 (file-name-directory "/method:host:/path/to/file/")
540 "/method:host:/path/to/file/"))
541 (should
542 (string-equal (file-name-nondirectory "/method:host:/path/to/file") "file"))
543 (should
544 (string-equal (file-name-nondirectory "/method:host:/path/to/file/") ""))
545 (should-not
546 (file-remote-p
547 (unhandled-file-name-directory "/method:host:/path/to/file"))))
a213a541
MA
548
549(ert-deftest tramp-test07-file-exists-p ()
6865f4d5 550 "Check `file-exist-p', `write-region' and `delete-file'."
1c49d6c2
MA
551 (skip-unless (tramp--test-enabled))
552 (let ((tmp-name (tramp--test-make-temp-name)))
553 (should-not (file-exists-p tmp-name))
554 (write-region "foo" nil tmp-name)
555 (should (file-exists-p tmp-name))
556 (delete-file tmp-name)
557 (should-not (file-exists-p tmp-name))))
a213a541
MA
558
559(ert-deftest tramp-test08-file-local-copy ()
560 "Check `file-local-copy'."
561 (skip-unless (tramp--test-enabled))
562 (let ((tmp-name1 (tramp--test-make-temp-name))
563 tmp-name2)
564 (unwind-protect
565 (progn
566 (write-region "foo" nil tmp-name1)
567 (should (setq tmp-name2 (file-local-copy tmp-name1)))
568 (with-temp-buffer
569 (insert-file-contents tmp-name2)
570 (should (string-equal (buffer-string) "foo"))))
571 (ignore-errors
572 (delete-file tmp-name1)
573 (delete-file tmp-name2)))))
574
575(ert-deftest tramp-test09-insert-file-contents ()
576 "Check `insert-file-contents'."
577 (skip-unless (tramp--test-enabled))
578 (let ((tmp-name (tramp--test-make-temp-name)))
579 (unwind-protect
580 (progn
581 (write-region "foo" nil tmp-name)
582 (with-temp-buffer
583 (insert-file-contents tmp-name)
8ee0219f
MA
584 (should (string-equal (buffer-string) "foo"))
585 (insert-file-contents tmp-name)
586 (should (string-equal (buffer-string) "foofoo"))
587 ;; Insert partly.
588 (insert-file-contents tmp-name nil 1 3)
589 (should (string-equal (buffer-string) "oofoofoo"))
590 ;; Replace.
591 (insert-file-contents tmp-name nil nil nil 'replace)
a213a541
MA
592 (should (string-equal (buffer-string) "foo"))))
593 (ignore-errors (delete-file tmp-name)))))
594
595(ert-deftest tramp-test10-write-region ()
596 "Check `write-region'."
597 (skip-unless (tramp--test-enabled))
598 (let ((tmp-name (tramp--test-make-temp-name)))
599 (unwind-protect
600 (progn
601 (with-temp-buffer
602 (insert "foo")
603 (write-region nil nil tmp-name))
604 (with-temp-buffer
605 (insert-file-contents tmp-name)
8ee0219f
MA
606 (should (string-equal (buffer-string) "foo")))
607 ;; Append.
608 (with-temp-buffer
609 (insert "bla")
610 (write-region nil nil tmp-name 'append))
611 (with-temp-buffer
612 (insert-file-contents tmp-name)
613 (should (string-equal (buffer-string) "foobla")))
614 ;; Write string.
615 (write-region "foo" nil tmp-name)
616 (with-temp-buffer
617 (insert-file-contents tmp-name)
618 (should (string-equal (buffer-string) "foo")))
619 ;; Write partly.
620 (with-temp-buffer
621 (insert "123456789")
622 (write-region 3 5 tmp-name))
623 (with-temp-buffer
624 (insert-file-contents tmp-name)
625 (should (string-equal (buffer-string) "34"))))
626 (ignore-errors (delete-file tmp-name)))))
a213a541
MA
627
628(ert-deftest tramp-test11-copy-file ()
629 "Check `copy-file'."
630 (skip-unless (tramp--test-enabled))
631 (let ((tmp-name1 (tramp--test-make-temp-name))
632 (tmp-name2 (tramp--test-make-temp-name)))
a213a541
MA
633 (unwind-protect
634 (progn
635 (write-region "foo" nil tmp-name1)
636 (copy-file tmp-name1 tmp-name2)
637 (should (file-exists-p tmp-name2))
638 (with-temp-buffer
639 (insert-file-contents tmp-name2)
640 (should (string-equal (buffer-string) "foo"))))
641 (ignore-errors
642 (delete-file tmp-name1)
643 (delete-file tmp-name2)))))
644
645(ert-deftest tramp-test12-rename-file ()
646 "Check `rename-file'."
647 (skip-unless (tramp--test-enabled))
648 (let ((tmp-name1 (tramp--test-make-temp-name))
649 (tmp-name2 (tramp--test-make-temp-name)))
650 (unwind-protect
651 (progn
652 (write-region "foo" nil tmp-name1)
653 (rename-file tmp-name1 tmp-name2)
654 (should-not (file-exists-p tmp-name1))
655 (should (file-exists-p tmp-name2))
656 (with-temp-buffer
657 (insert-file-contents tmp-name2)
658 (should (string-equal (buffer-string) "foo"))))
659 (ignore-errors (delete-file tmp-name2)))))
660
661(ert-deftest tramp-test13-make-directory ()
662 "Check `make-directory'.
663This tests also `file-directory-p' and `file-accessible-directory-p'."
664 (skip-unless (tramp--test-enabled))
665 (let ((tmp-name (tramp--test-make-temp-name)))
666 (unwind-protect
667 (progn
668 (make-directory tmp-name)
669 (should (file-directory-p tmp-name))
670 (should (file-accessible-directory-p tmp-name)))
671 (ignore-errors (delete-directory tmp-name)))))
672
673(ert-deftest tramp-test14-delete-directory ()
674 "Check `delete-directory'."
675 (skip-unless (tramp--test-enabled))
676 (let ((tmp-name (tramp--test-make-temp-name)))
677 ;; Delete empty directory.
678 (make-directory tmp-name)
679 (should (file-directory-p tmp-name))
680 (delete-directory tmp-name)
681 (should-not (file-directory-p tmp-name))
682 ;; Delete non-empty directory.
683 (make-directory tmp-name)
684 (write-region "foo" nil (expand-file-name "bla" tmp-name))
685 (should-error (delete-directory tmp-name))
686 (delete-directory tmp-name 'recursive)
687 (should-not (file-directory-p tmp-name))))
688
689(ert-deftest tramp-test15-copy-directory ()
690 "Check `copy-directory'."
691 (skip-unless (tramp--test-enabled))
692 (let* ((tmp-name1 (tramp--test-make-temp-name))
693 (tmp-name2 (tramp--test-make-temp-name))
694 (tmp-name3 (expand-file-name
695 (file-name-nondirectory tmp-name1) tmp-name2))
696 (tmp-name4 (expand-file-name "foo" tmp-name1))
697 (tmp-name5 (expand-file-name "foo" tmp-name2))
698 (tmp-name6 (expand-file-name "foo" tmp-name3)))
699 (unwind-protect
700 (progn
701 ;; Copy empty directory.
702 (make-directory tmp-name1)
703 (write-region "foo" nil tmp-name4)
704 (should (file-directory-p tmp-name1))
705 (should (file-exists-p tmp-name4))
706 (copy-directory tmp-name1 tmp-name2)
707 (should (file-directory-p tmp-name2))
708 (should (file-exists-p tmp-name5))
709 ;; Target directory does exist already.
710 (copy-directory tmp-name1 tmp-name2)
711 (should (file-directory-p tmp-name3))
712 (should (file-exists-p tmp-name6)))
713 (delete-directory tmp-name1 'recursive)
714 (delete-directory tmp-name2 'recursive))))
715
716(ert-deftest tramp-test16-directory-files ()
717 "Check `directory-files'."
718 (skip-unless (tramp--test-enabled))
719 (let* ((tmp-name1 (tramp--test-make-temp-name))
720 (tmp-name2 (expand-file-name "bla" tmp-name1))
721 (tmp-name3 (expand-file-name "foo" tmp-name1)))
722 (unwind-protect
723 (progn
724 (make-directory tmp-name1)
725 (write-region "foo" nil tmp-name2)
726 (write-region "bla" nil tmp-name3)
727 (should (file-directory-p tmp-name1))
728 (should (file-exists-p tmp-name2))
729 (should (file-exists-p tmp-name3))
730 (should (equal (directory-files tmp-name1) '("." ".." "bla" "foo")))
731 (should (equal (directory-files tmp-name1 'full)
732 `(,(concat tmp-name1 "/.")
733 ,(concat tmp-name1 "/..")
734 ,tmp-name2 ,tmp-name3)))
735 (should (equal (directory-files
736 tmp-name1 nil directory-files-no-dot-files-regexp)
737 '("bla" "foo")))
738 (should (equal (directory-files
739 tmp-name1 'full directory-files-no-dot-files-regexp)
740 `(,tmp-name2 ,tmp-name3))))
741 (delete-directory tmp-name1 'recursive))))
742
743(ert-deftest tramp-test17-insert-directory ()
744 "Check `insert-directory'."
745 (skip-unless (tramp--test-enabled))
746 (let* ((tmp-name1 (tramp--test-make-temp-name))
747 (tmp-name2 (expand-file-name "foo" tmp-name1)))
748 (unwind-protect
749 (progn
750 (make-directory tmp-name1)
751 (write-region "foo" nil tmp-name2)
752 (should (file-directory-p tmp-name1))
753 (should (file-exists-p tmp-name2))
754 (with-temp-buffer
755 (insert-directory tmp-name1 nil)
756 (goto-char (point-min))
757 (should (looking-at-p (regexp-quote tmp-name1))))
758 (with-temp-buffer
759 (insert-directory tmp-name1 "-al")
760 (goto-char (point-min))
761 (should (looking-at-p (format "^.+ %s$" (regexp-quote tmp-name1)))))
762 (with-temp-buffer
763 (insert-directory (file-name-as-directory tmp-name1) "-al")
764 (goto-char (point-min))
765 (should
766 (looking-at-p (format "^.+ %s/$" (regexp-quote tmp-name1)))))
767 (with-temp-buffer
768 (insert-directory
769 (file-name-as-directory tmp-name1) "-al" nil 'full-directory-p)
770 (goto-char (point-min))
771 (should
772 (looking-at-p "total +[[:digit:]]+\n.+ \\.\n.+ \\.\\.\n.+ foo$"))))
773 (delete-directory tmp-name1 'recursive))))
774
775(ert-deftest tramp-test18-file-attributes ()
776 "Check `file-attributes'.
777This tests also `file-readable-p' and `file-regular-p'."
778 (skip-unless (tramp--test-enabled))
779 (let ((tmp-name (tramp--test-make-temp-name))
780 attr)
781 (unwind-protect
782 (progn
783 (write-region "foo" nil tmp-name)
784 (should (file-exists-p tmp-name))
785 (setq attr (file-attributes tmp-name))
786 (should (consp attr))
787 (should (file-exists-p tmp-name))
788 (should (file-readable-p tmp-name))
789 (should (file-regular-p tmp-name))
790 ;; We do not test inodes and device numbers.
791 (should (null (car attr)))
792 (should (numberp (nth 1 attr))) ;; Link.
793 (should (numberp (nth 2 attr))) ;; Uid.
794 (should (numberp (nth 3 attr))) ;; Gid.
795 ;; Last access time.
796 (should (stringp (current-time-string (nth 4 attr))))
797 ;; Last modification time.
798 (should (stringp (current-time-string (nth 5 attr))))
799 ;; Last status change time.
800 (should (stringp (current-time-string (nth 6 attr))))
801 (should (numberp (nth 7 attr))) ;; Size.
802 (should (stringp (nth 8 attr))) ;; Modes.
803
804 (setq attr (file-attributes tmp-name 'string))
805 (should (stringp (nth 2 attr))) ;; Uid.
806 (should (stringp (nth 3 attr))) ;; Gid.
807 (delete-file tmp-name)
808
809 (make-directory tmp-name)
810 (should (file-exists-p tmp-name))
811 (should (file-readable-p tmp-name))
812 (should-not (file-regular-p tmp-name))
813 (setq attr (file-attributes tmp-name))
814 (should (eq (car attr) t)))
815 (delete-directory tmp-name))))
816
817(ert-deftest tramp-test19-directory-files-and-attributes ()
818 "Check `directory-files-and-attributes'."
819 (skip-unless (tramp--test-enabled))
820 (let ((tmp-name (tramp--test-make-temp-name))
821 attr)
822 (unwind-protect
823 (progn
824 (make-directory tmp-name)
825 (should (file-directory-p tmp-name))
826 (write-region "foo" nil (expand-file-name "foo" tmp-name))
827 (write-region "bar" nil (expand-file-name "bar" tmp-name))
828 (write-region "boz" nil (expand-file-name "boz" tmp-name))
829 (setq attr (directory-files-and-attributes tmp-name))
830 (should (consp attr))
831 (dolist (elt attr)
832 (should
833 (equal (file-attributes (expand-file-name (car elt) tmp-name))
834 (cdr elt))))
835 (setq attr (directory-files-and-attributes tmp-name 'full))
836 (dolist (elt attr)
837 (should
838 (equal (file-attributes (car elt)) (cdr elt))))
839 (setq attr (directory-files-and-attributes tmp-name nil "^b"))
840 (should (equal (mapcar 'car attr) '("bar" "boz"))))
841 (delete-directory tmp-name 'recursive))))
842
843(ert-deftest tramp-test20-file-modes ()
844 "Check `file-modes'.
845This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
846 (skip-unless (tramp--test-enabled))
8ee0219f 847 (let ((tmp-name (tramp--test-make-temp-name)))
a213a541
MA
848 (unwind-protect
849 (progn
8ee0219f
MA
850 (write-region "foo" nil tmp-name)
851 (should (file-exists-p tmp-name))
852 (set-file-modes tmp-name #o777)
853 (should (= (file-modes tmp-name) #o777))
854 (should (file-executable-p tmp-name))
855 (should (file-writable-p tmp-name))
856 (set-file-modes tmp-name #o444)
857 (should (= (file-modes tmp-name) #o444))
858 (should-not (file-executable-p tmp-name))
859 ;; A file is always writable for user "root".
860 (unless (string-equal (file-remote-p tmp-name 'user) "root")
861 (should-not (file-writable-p tmp-name))))
862 (delete-file tmp-name))))
a213a541
MA
863
864(ert-deftest tramp-test21-file-links ()
865 "Check `file-symlink-p'.
866This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
867 (skip-unless (tramp--test-enabled))
868 (let ((tmp-name1 (tramp--test-make-temp-name))
869 (tmp-name2 (tramp--test-make-temp-name))
870 (tmp-name3 (make-temp-name "tramp-")))
871 (unwind-protect
872 (progn
873 (write-region "foo" nil tmp-name1)
874 (should (file-exists-p tmp-name1))
875 (make-symbolic-link tmp-name1 tmp-name2)
876 (should (file-symlink-p tmp-name2))
877 (should-error (make-symbolic-link tmp-name1 tmp-name2))
878 (make-symbolic-link tmp-name1 tmp-name2 'ok-if-already-exists)
879 (should (file-symlink-p tmp-name2))
880 ;; `tmp-name3' is a local file name.
881 (should-error (make-symbolic-link tmp-name1 tmp-name3)))
882 (delete-file tmp-name1)
883 (delete-file tmp-name2))
884
885 (unwind-protect
886 (progn
887 (write-region "foo" nil tmp-name1)
888 (should (file-exists-p tmp-name1))
889 (add-name-to-file tmp-name1 tmp-name2)
890 (should-not (file-symlink-p tmp-name2))
891 (should-error (add-name-to-file tmp-name1 tmp-name2))
892 (add-name-to-file tmp-name1 tmp-name2 'ok-if-already-exists)
893 (should-not (file-symlink-p tmp-name2))
894 ;; `tmp-name3' is a local file name.
895 (should-error (add-name-to-file tmp-name1 tmp-name3)))
896 (delete-file tmp-name1)
897 (delete-file tmp-name2))
898
899 (unwind-protect
900 (progn
901 (write-region "foo" nil tmp-name1)
902 (should (file-exists-p tmp-name1))
903 (make-symbolic-link tmp-name1 tmp-name2)
904 (should (file-symlink-p tmp-name2))
927fbd6b
MA
905 (should-not (string-equal tmp-name2 (file-truename tmp-name2)))
906 (should
907 (string-equal (file-truename tmp-name1) (file-truename tmp-name2))))
a213a541
MA
908 (delete-file tmp-name1)
909 (delete-file tmp-name2))))
910
911(ert-deftest tramp-test22-file-times ()
912 "Check `set-file-times' and `file-newer-than-file-p'."
913 (skip-unless (tramp--test-enabled))
914 (let ((tmp-name1 (tramp--test-make-temp-name))
915 (tmp-name2 (tramp--test-make-temp-name))
916 (tmp-name3 (tramp--test-make-temp-name)))
917 (unwind-protect
918 (progn
919 (write-region "foo" nil tmp-name1)
920 (should (file-exists-p tmp-name1))
921 (should (consp (nth 5 (file-attributes tmp-name1))))
922 ;; '(0 0) means don't know, and will be replaced by `current-time'.
923 (set-file-times tmp-name1 '(0 1))
924 (should (equal (nth 5 (file-attributes tmp-name1)) '(0 1)))
925 (write-region "bla" nil tmp-name2)
926 (should (file-exists-p tmp-name2))
927 (should (file-newer-than-file-p tmp-name2 tmp-name1))
928 ;; `tmp-name3' does not exist.
929 (should (file-newer-than-file-p tmp-name2 tmp-name3))
930 (should-not (file-newer-than-file-p tmp-name3 tmp-name1)))
931 (delete-file tmp-name1)
932 (delete-file tmp-name2))))
933
934(ert-deftest tramp-test23-visited-file-modtime ()
935 "Check `set-visited-file-modtime' and `verify-visited-file-modtime'."
936 (skip-unless (tramp--test-enabled))
937 (let ((tmp-name (tramp--test-make-temp-name)))
938 (unwind-protect
939 (progn
940 (write-region "foo" nil tmp-name)
941 (should (file-exists-p tmp-name))
942 (with-temp-buffer
943 (insert-file-contents tmp-name)
944 (should (verify-visited-file-modtime))
945 (set-visited-file-modtime '(0 1))
946 (should (verify-visited-file-modtime))
947 (should (equal (visited-file-modtime) '(0 1 0 0)))))
948 (delete-file tmp-name))))
949
950(ert-deftest tramp-test24-file-name-completion ()
951 "Check `file-name-completion' and `file-name-all-completions'."
952 (skip-unless (tramp--test-enabled))
953 (let ((tmp-name (tramp--test-make-temp-name)))
954 (unwind-protect
955 (progn
956 (make-directory tmp-name)
957 (should (file-directory-p tmp-name))
958 (write-region "foo" nil (expand-file-name "foo" tmp-name))
959 (write-region "bar" nil (expand-file-name "bold" tmp-name))
960 (make-directory (expand-file-name "boz" tmp-name))
961 (should (equal (file-name-completion "fo" tmp-name) "foo"))
962 (should (equal (file-name-completion "b" tmp-name) "bo"))
963 (should
964 (equal (file-name-completion "b" tmp-name 'file-directory-p) "boz/"))
965 (should (equal (file-name-all-completions "fo" tmp-name) '("foo")))
966 (should
967 (equal (sort (file-name-all-completions "b" tmp-name) 'string-lessp)
968 '("bold" "boz/"))))
969 (delete-directory tmp-name 'recursive))))
970
971(ert-deftest tramp-test25-load ()
972 "Check `load'."
973 (skip-unless (tramp--test-enabled))
974 (let ((tmp-name (tramp--test-make-temp-name)))
975 (unwind-protect
976 (progn
977 (load tmp-name 'noerror 'nomessage)
978 (should-not (featurep 'tramp-test-load))
979 (write-region "(provide 'tramp-test-load)" nil tmp-name)
980 ;; `load' in lread.c does not pass `must-suffix'. Why?
981 ;(should-error (load tmp-name nil 'nomessage 'nosuffix 'must-suffix))
982 (load tmp-name nil 'nomessage 'nosuffix)
983 (should (featurep 'tramp-test-load)))
984 (and (featurep 'tramp-test-load) (unload-feature 'tramp-test-load))
985 (delete-file tmp-name))))
986
987(ert-deftest tramp-test26-process-file ()
988 "Check `process-file'."
989 (skip-unless (tramp--test-enabled))
927fbd6b
MA
990 (let ((tmp-name (tramp--test-make-temp-name))
991 (default-directory tramp-test-temporary-file-directory))
992 (unwind-protect
993 (progn
994 ;; We cannot use "/bin/true" and "/bin/false"; those paths
995 ;; do not exist on hydra.
996 (should (zerop (process-file "true")))
997 (should-not (zerop (process-file "false")))
998 (should-not (zerop (process-file "binary-does-not-exist")))
999 (with-temp-buffer
1000 (write-region "foo" nil tmp-name)
1001 (should (zerop (process-file "ls" nil t)))
1002 (should (> (point-max) (point-min)))))
1003 (delete-file tmp-name))))
a213a541
MA
1004
1005(ert-deftest tramp-test27-start-file-process ()
1006 "Check `start-file-process'."
1007 (skip-unless (tramp--test-enabled))
1008 (let ((default-directory tramp-test-temporary-file-directory)
1009 (tmp-name (tramp--test-make-temp-name))
1010 kill-buffer-query-functions proc)
1011 (unwind-protect
1012 (with-temp-buffer
1013 (setq proc (start-file-process "test1" (current-buffer) "cat"))
1014 (should (processp proc))
1015 (should (equal (process-status proc) 'run))
1016 (process-send-string proc "foo")
1017 (process-send-eof proc)
1018 (accept-process-output proc 1)
1019 (should (string-equal (buffer-string) "foo")))
1020 (delete-process proc))
1021
1022 (unwind-protect
1023 (with-temp-buffer
1024 (write-region "foo" nil tmp-name)
1025 (should (file-exists-p tmp-name))
1026 (setq proc
1027 (start-file-process
1028 "test2" (current-buffer)
1029 "cat" (file-name-nondirectory tmp-name)))
1030 (should (processp proc))
1031 (accept-process-output proc 1)
1032 (should (string-equal (buffer-string) "foo")))
1033 (delete-process proc)
1034 (delete-file tmp-name))
1035
1036 (unwind-protect
1037 (progn
1038 (setq proc (start-file-process "test3" nil "cat"))
1039 (should (processp proc))
1040 (should (equal (process-status proc) 'run))
1041 (set-process-filter
1042 proc (lambda (p s) (should (string-equal s "foo"))))
1043 (process-send-string proc "foo")
1044 (process-send-eof proc)
1045 (accept-process-output proc 1))
1046 (delete-process proc))))
1047
1048(ert-deftest tramp-test28-shell-command ()
1049 "Check `shell-command'."
1050 (skip-unless (tramp--test-enabled))
927fbd6b
MA
1051 (let ((tmp-name (tramp--test-make-temp-name))
1052 (default-directory tramp-test-temporary-file-directory))
1053 (unwind-protect
1054 (with-temp-buffer
1055 (write-region "foo" nil tmp-name)
1056 (shell-command "ls" (current-buffer))
1057 (should (> (point-max) (point-min))))
1058 (delete-file tmp-name))))
a213a541
MA
1059
1060;; TODO:
1061
1062;; * dired-compress-file
1063;; * dired-uncache
1064;; * file-acl
1065;; * file-ownership-preserved-p
1066;; * file-selinux-context
1067;; * find-backup-file-name
1068;; * make-auto-save-file-name
1069;; * set-file-acl
1070;; * set-file-selinux-context
1071;; * vc-registered
1072
1073(defun tramp-test-all (&optional interactive)
1074 "Run all tests for \\[tramp]."
1075 (interactive "p")
1076 (funcall
1077 (if interactive 'ert-run-tests-interactively 'ert-run-tests-batch) "^tramp"))
1078
1079(provide 'tramp-tests)
1080;;; tramp-tests.el ends here