aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/ChangeLog23
-rw-r--r--test/automated/tramp-tests.el252
2 files changed, 243 insertions, 32 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 4488aab701f..a9c20f6fbfa 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,26 @@
12015-03-04 Michael Albinus <michael.albinus@gmx.de>
2
3 * automated/tramp-tests.el (top): Declare `tramp-get-remote-stat'
4 and `tramp-get-remote-perl'.
5 (tramp-test06-directory-file-name): Fix docstring and last test.
6 (tramp-test08-file-local-copy): Extend test.
7 (tramp-test13-make-directory): Test also PARENTS arg.
8 (tramp-test17-insert-directory): Do not expect any order in
9 directory listing.
10 (tramp--test-adb-p): New defun.
11 (tramp--test-check-files): Fix doxstring. Extend tests.
12 (tramp--test-special-characters): New defun. Use body from
13 `tramp-test30-special-characters'. Adapt check for tramp-adb.el.
14 (tramp-test30-special-characters): Use it.
15 (tramp--test-utf8): New defun. Use body from
16 `tramp-test31-utf8'. Add test string.
17 (tramp-test31-utf8): Use it.
18 (tramp-test30-special-characters-with-stat)
19 (tramp-test30-special-characters-with-perl)
20 (tramp-test30-special-characters-with-ls):
21 (tramp-test31-utf8-with-stat, tramp-test31-utf8-with-perl)
22 (tramp-test31-utf8-with-ls): New tests.
23
12015-03-03 Daniel Colascione <dancol@dancol.org> 242015-03-03 Daniel Colascione <dancol@dancol.org>
2 25
3 * automated/generator-tests.el (cps-testcase): Use 26 * automated/generator-tests.el (cps-testcase): Use
diff --git a/test/automated/tramp-tests.el b/test/automated/tramp-tests.el
index 3b72da8955a..020f31f4e6f 100644
--- a/test/automated/tramp-tests.el
+++ b/test/automated/tramp-tests.el
@@ -46,6 +46,8 @@
46 46
47(declare-function tramp-find-executable "tramp-sh") 47(declare-function tramp-find-executable "tramp-sh")
48(declare-function tramp-get-remote-path "tramp-sh") 48(declare-function tramp-get-remote-path "tramp-sh")
49(declare-function tramp-get-remote-stat "tramp-sh")
50(declare-function tramp-get-remote-perl "tramp-sh")
49(defvar tramp-copy-size-limit) 51(defvar tramp-copy-size-limit)
50(defvar tramp-remote-process-environment) 52(defvar tramp-remote-process-environment)
51 53
@@ -558,8 +560,8 @@ shall not contain a timeout."
558 560
559(ert-deftest tramp-test06-directory-file-name () 561(ert-deftest tramp-test06-directory-file-name ()
560 "Check `directory-file-name'. 562 "Check `directory-file-name'.
561This checks also `file-name-as-directory', `file-name-directory' 563This checks also `file-name-as-directory', `file-name-directory',
562and `file-name-nondirectory'." 564`file-name-nondirectory' and `unhandled-file-name-directory'."
563 (should 565 (should
564 (string-equal 566 (string-equal
565 (directory-file-name "/method:host:/path/to/file") 567 (directory-file-name "/method:host:/path/to/file")
@@ -589,8 +591,7 @@ and `file-name-nondirectory'."
589 (should 591 (should
590 (string-equal (file-name-nondirectory "/method:host:/path/to/file/") "")) 592 (string-equal (file-name-nondirectory "/method:host:/path/to/file/") ""))
591 (should-not 593 (should-not
592 (file-remote-p 594 (unhandled-file-name-directory "/method:host:/path/to/file")))
593 (unhandled-file-name-directory "/method:host:/path/to/file"))))
594 595
595(ert-deftest tramp-test07-file-exists-p () 596(ert-deftest tramp-test07-file-exists-p ()
596 "Check `file-exist-p', `write-region' and `delete-file'." 597 "Check `file-exist-p', `write-region' and `delete-file'."
@@ -615,7 +616,13 @@ and `file-name-nondirectory'."
615 (should (setq tmp-name2 (file-local-copy tmp-name1))) 616 (should (setq tmp-name2 (file-local-copy tmp-name1)))
616 (with-temp-buffer 617 (with-temp-buffer
617 (insert-file-contents tmp-name2) 618 (insert-file-contents tmp-name2)
618 (should (string-equal (buffer-string) "foo")))) 619 (should (string-equal (buffer-string) "foo")))
620 ;; Check also that a file transfer with compression works.
621 (let ((default-directory tramp-test-temporary-file-directory)
622 (tramp-copy-size-limit 4)
623 (tramp-inline-compress-start-size 2))
624 (delete-file tmp-name2)
625 (should (setq tmp-name2 (file-local-copy tmp-name1)))))
619 (ignore-errors 626 (ignore-errors
620 (delete-file tmp-name1) 627 (delete-file tmp-name1)
621 (delete-file tmp-name2))))) 628 (delete-file tmp-name2)))))
@@ -840,7 +847,14 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
840 (progn 847 (progn
841 (make-directory tmp-name) 848 (make-directory tmp-name)
842 (should (file-directory-p tmp-name)) 849 (should (file-directory-p tmp-name))
843 (should (file-accessible-directory-p tmp-name))) 850 (should (file-accessible-directory-p tmp-name))
851 (should-error
852 (make-directory (expand-file-name "foo/bar" tmp-name))
853 :type 'file-error)
854 (make-directory (expand-file-name "foo/bar" tmp-name) 'parents)
855 (should (file-directory-p (expand-file-name "foo/bar" tmp-name)))
856 (should
857 (file-accessible-directory-p (expand-file-name "foo/bar" tmp-name))))
844 (ignore-errors (delete-directory tmp-name))))) 858 (ignore-errors (delete-directory tmp-name)))))
845 859
846(ert-deftest tramp-test14-delete-directory () 860(ert-deftest tramp-test14-delete-directory ()
@@ -959,9 +973,8 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
959 (concat 973 (concat
960 ;; There might be a summary line. 974 ;; There might be a summary line.
961 "\\(total.+[[:digit:]]+\n\\)?" 975 "\\(total.+[[:digit:]]+\n\\)?"
962 ;; We don't know in which order "." and ".." appear. 976 ;; We don't know in which order ".", ".." and "foo" appear.
963 "\\(.+ \\.?\\.\n\\)\\{2\\}" 977 "\\(.+ \\(\\.?\\.\\|foo\\)\n\\)\\{3\\}")))))
964 ".+ foo$")))))
965 (ignore-errors (delete-directory tmp-name1 'recursive))))) 978 (ignore-errors (delete-directory tmp-name1 'recursive)))))
966 979
967(ert-deftest tramp-test18-file-attributes () 980(ert-deftest tramp-test18-file-attributes ()
@@ -1490,38 +1503,68 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
1490 1503
1491 (ignore-errors (delete-directory tmp-name1 'recursive))))) 1504 (ignore-errors (delete-directory tmp-name1 'recursive)))))
1492 1505
1506(defun tramp--test-adb-p ()
1507 "Check, whether the remote host runs Android.
1508This requires restrictions of file name syntax."
1509 (eq (tramp-find-foreign-file-name-handler
1510 tramp-test-temporary-file-directory)
1511 'tramp-adb-file-name-handler))
1512
1493(defun tramp--test-smb-or-windows-nt-p () 1513(defun tramp--test-smb-or-windows-nt-p ()
1494 "Check, whether the locale or remote host runs MS Windows. 1514 "Check, whether the locale or remote host runs MS Windows.
1495This requires restrictions of file name syntax." 1515This requires restrictions of file name syntax."
1496 (or (eq system-type 'windows-nt) 1516 (or (eq system-type 'windows-nt)
1497 (eq (tramp-find-foreign-file-name-handler 1517 (eq (tramp-find-foreign-file-name-handler
1498 tramp-test-temporary-file-directory) 1518 tramp-test-temporary-file-directory)
1499 'tramp-smb-file-name-handler))) 1519 'tramp-smb-file-name-handler)))
1500 1520
1501(defun tramp--test-check-files (&rest files) 1521(defun tramp--test-check-files (&rest files)
1502 "Runs a simple but comprehensive test over every file in FILES." 1522 "Run a simple but comprehensive test over every file in FILES."
1503 (let ((tmp-name1 (tramp--test-make-temp-name)) 1523 (let ((tmp-name1 (tramp--test-make-temp-name))
1504 (tmp-name2 (tramp--test-make-temp-name 'local))) 1524 (tmp-name2 (tramp--test-make-temp-name 'local))
1525 (files (delq nil files)))
1505 (unwind-protect 1526 (unwind-protect
1506 (progn 1527 (progn
1507 (make-directory tmp-name1) 1528 (make-directory tmp-name1)
1508 (make-directory tmp-name2) 1529 (make-directory tmp-name2)
1509 (dolist (elt (delq nil files)) 1530 (dolist (elt files)
1510 (let ((file1 (expand-file-name elt tmp-name1)) 1531 (let* ((file1 (expand-file-name elt tmp-name1))
1511 (file2 (expand-file-name elt tmp-name2))) 1532 (file2 (expand-file-name elt tmp-name2))
1533 (file3 (concat file1 "foo")))
1512 (write-region elt nil file1) 1534 (write-region elt nil file1)
1513 (should (file-exists-p file1)) 1535 (should (file-exists-p file1))
1536
1514 ;; Check file contents. 1537 ;; Check file contents.
1515 (with-temp-buffer 1538 (with-temp-buffer
1516 (insert-file-contents file1) 1539 (insert-file-contents file1)
1517 (should (string-equal (buffer-string) elt))) 1540 (should (string-equal (buffer-string) elt)))
1541
1518 ;; Copy file both directions. 1542 ;; Copy file both directions.
1519 (copy-file file1 tmp-name2) 1543 (copy-file file1 tmp-name2)
1520 (should (file-exists-p file2)) 1544 (should (file-exists-p file2))
1521 (delete-file file1) 1545 (delete-file file1)
1522 (should-not (file-exists-p file1)) 1546 (should-not (file-exists-p file1))
1523 (copy-file file2 tmp-name1) 1547 (copy-file file2 tmp-name1)
1524 (should (file-exists-p file1)))) 1548 (should (file-exists-p file1))
1549
1550 ;; Method "smb" supports `make-symbolic-link' only if the
1551 ;; remote host has CIFS capabilities. tramp-adb.el and
1552 ;; tramp-gvfs.el do not support symbolic links at all.
1553 (condition-case err
1554 (progn
1555 (make-symbolic-link file1 file3)
1556 (should (file-symlink-p file3))
1557 (should
1558 (string-equal
1559 (expand-file-name file1) (file-truename file3)))
1560 ;; Check file contents.
1561 (with-temp-buffer
1562 (insert-file-contents file3)
1563 (should (string-equal (buffer-string) elt)))
1564 (delete-file file3))
1565 (file-error
1566 (should (string-equal (error-message-string err)
1567 "make-symbolic-link not supported"))))))
1525 1568
1526 ;; Check file names. 1569 ;; Check file names.
1527 (should (equal (directory-files 1570 (should (equal (directory-files
@@ -1548,26 +1591,44 @@ This requires restrictions of file name syntax."
1548 (should (equal (directory-files 1591 (should (equal (directory-files
1549 tmp-name1 nil directory-files-no-dot-files-regexp) 1592 tmp-name1 nil directory-files-no-dot-files-regexp)
1550 (directory-files 1593 (directory-files
1551 tmp-name2 nil directory-files-no-dot-files-regexp)))) 1594 tmp-name2 nil directory-files-no-dot-files-regexp)))
1595
1596 ;; Check directory creation. We use a subdirectory "foo"
1597 ;; in order to avoid conflicts with previous file name tests.
1598 (dolist (elt files)
1599 (let* ((file1 (expand-file-name (concat "foo/" elt) tmp-name1))
1600 (file2 (expand-file-name elt file1)))
1601 (make-directory file1 'parents)
1602 (should (file-directory-p file1))
1603 (write-region elt nil file2)
1604 (should (file-exists-p file2))
1605 (should
1606 (equal
1607 (directory-files file1 nil directory-files-no-dot-files-regexp)
1608 `(,elt)))
1609 (should
1610 (equal
1611 (caar (directory-files-and-attributes
1612 file1 nil directory-files-no-dot-files-regexp))
1613 elt))
1614 (delete-file file2)
1615 (should-not (file-exists-p file2))
1616 (delete-directory file1)
1617 (should-not (file-exists-p file1)))))
1552 1618
1553 (ignore-errors (delete-directory tmp-name1 'recursive)) 1619 (ignore-errors (delete-directory tmp-name1 'recursive))
1554 (ignore-errors (delete-directory tmp-name2 'recursive))))) 1620 (ignore-errors (delete-directory tmp-name2 'recursive)))))
1555 1621
1556;; This test is inspired by Bug#17238. 1622(defun tramp--test-special-characters ()
1557(ert-deftest tramp-test30-special-characters () 1623 "Perform the test in `tramp-test30-special-characters*'."
1558 "Check special characters in file names."
1559 (skip-unless (tramp--test-enabled))
1560 (skip-unless
1561 (not
1562 (memq
1563 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
1564 '(tramp-adb-file-name-handler
1565 tramp-gvfs-file-name-handler))))
1566
1567 ;; Newlines, slashes and backslashes in file names are not supported. 1624 ;; Newlines, slashes and backslashes in file names are not supported.
1568 ;; So we don't test. 1625 ;; So we don't test.
1569 (tramp--test-check-files 1626 (tramp--test-check-files
1570 (if (tramp--test-smb-or-windows-nt-p) "foo bar baz" " foo\tbar baz\t") 1627 (if (tramp--test-smb-or-windows-nt-p)
1628 "foo bar baz"
1629 (if (tramp--test-adb-p)
1630 " foo bar baz "
1631 " foo\tbar baz\t"))
1571 "$foo$bar$$baz$" 1632 "$foo$bar$$baz$"
1572 "-foo-bar-baz-" 1633 "-foo-bar-baz-"
1573 "%foo%bar%baz%" 1634 "%foo%bar%baz%"
@@ -1583,18 +1644,145 @@ This requires restrictions of file name syntax."
1583 "[foo]bar[baz]" 1644 "[foo]bar[baz]"
1584 "{foo}bar{baz}")) 1645 "{foo}bar{baz}"))
1585 1646
1586(ert-deftest tramp-test31-utf8 () 1647;; These tests are inspired by Bug#17238.
1587 "Check UTF8 encoding in file names and file contents." 1648(ert-deftest tramp-test30-special-characters ()
1649 "Check special characters in file names."
1588 (skip-unless (tramp--test-enabled)) 1650 (skip-unless (tramp--test-enabled))
1589 1651
1652 (tramp--test-special-characters))
1653
1654(ert-deftest tramp-test30-special-characters-with-stat ()
1655 "Check special characters in file names.
1656Use the `stat' command."
1657 (skip-unless (tramp--test-enabled))
1658 (skip-unless
1659 (eq
1660 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
1661 'tramp-sh-file-name-handler))
1662 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
1663 (skip-unless (tramp-get-remote-stat v)))
1664
1665 (unwind-protect
1666 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
1667 (tramp-set-connection-property v "perl" nil)
1668 (tramp--test-special-characters))
1669 ;; Reset suppressed properties.
1670 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
1671 (tramp-set-connection-property v "perl" 'undef))))
1672
1673(ert-deftest tramp-test30-special-characters-with-perl ()
1674 "Check special characters in file names.
1675Use the `perl' command."
1676 (skip-unless (tramp--test-enabled))
1677 (skip-unless
1678 (eq
1679 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
1680 'tramp-sh-file-name-handler))
1681 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
1682 (skip-unless (tramp-get-remote-perl v)))
1683
1684 (unwind-protect
1685 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
1686 (tramp-set-connection-property v "stat" nil)
1687 (tramp--test-special-characters))
1688 ;; Reset suppressed properties.
1689 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
1690 (tramp-set-connection-property v "stat" 'undef))))
1691
1692(ert-deftest tramp-test30-special-characters-with-ls ()
1693 "Check special characters in file names.
1694Use the `ls' command."
1695 (skip-unless (tramp--test-enabled))
1696 (skip-unless
1697 (eq
1698 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
1699 'tramp-sh-file-name-handler))
1700
1701 (unwind-protect
1702 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
1703 (tramp-set-connection-property v "stat" nil)
1704 (tramp-set-connection-property v "perl" nil)
1705 (tramp--test-special-characters))
1706 ;; Reset suppressed properties.
1707 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
1708 (tramp-set-connection-property v "stat" 'undef)
1709 (tramp-set-connection-property v "perl" 'undef))))
1710
1711(defun tramp--test-utf8 ()
1712 "Perform the test in `tramp-test31-utf8*'."
1590 (let ((coding-system-for-read 'utf-8) 1713 (let ((coding-system-for-read 'utf-8)
1591 (coding-system-for-write 'utf-8) 1714 (coding-system-for-write 'utf-8)
1592 (file-name-coding-system 'utf-8)) 1715 (file-name-coding-system 'utf-8))
1593 (tramp--test-check-files 1716 (tramp--test-check-files
1717 "Γυρίστε το Γαλαξία με Ώτο Στοπ"
1594 "أصبح بوسعك الآن تنزيل نسخة كاملة من موسوعة ويكيبيديا العربية لتصفحها بلا اتصال بالإنترنت" 1718 "أصبح بوسعك الآن تنزيل نسخة كاملة من موسوعة ويكيبيديا العربية لتصفحها بلا اتصال بالإنترنت"
1595 "银河系漫游指南系列" 1719 "银河系漫游指南系列"
1596 "Автостопом по гала́ктике"))) 1720 "Автостопом по гала́ктике")))
1597 1721
1722(ert-deftest tramp-test31-utf8 ()
1723 "Check UTF8 encoding in file names and file contents."
1724 (skip-unless (tramp--test-enabled))
1725 (skip-unless (not (tramp--test-adb-p)))
1726
1727 (tramp--test-utf8))
1728
1729(ert-deftest tramp-test31-utf8-with-stat ()
1730 "Check UTF8 encoding in file names and file contents.
1731Use the `stat' command."
1732 (skip-unless (tramp--test-enabled))
1733 (skip-unless
1734 (eq
1735 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
1736 'tramp-sh-file-name-handler))
1737 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
1738 (skip-unless (tramp-get-remote-stat v)))
1739
1740 (unwind-protect
1741 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
1742 (tramp-set-connection-property v "perl" nil)
1743 (tramp--test-utf8))
1744 ;; Reset suppressed properties.
1745 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
1746 (tramp-set-connection-property v "perl" 'undef))))
1747
1748(ert-deftest tramp-test31-utf8-with-perl ()
1749 "Check UTF8 encoding in file names and file contents.
1750Use the `perl' command."
1751 (skip-unless (tramp--test-enabled))
1752 (skip-unless
1753 (eq
1754 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
1755 'tramp-sh-file-name-handler))
1756 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
1757 (skip-unless (tramp-get-remote-perl v)))
1758
1759 (unwind-protect
1760 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
1761 (tramp-set-connection-property v "stat" nil)
1762 (tramp--test-utf8))
1763 ;; Reset suppressed properties.
1764 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
1765 (tramp-set-connection-property v "stat" 'undef))))
1766
1767(ert-deftest tramp-test31-utf8-with-ls ()
1768 "Check UTF8 encoding in file names and file contents.
1769Use the `ls' command."
1770 (skip-unless (tramp--test-enabled))
1771 (skip-unless
1772 (eq
1773 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
1774 'tramp-sh-file-name-handler))
1775
1776 (unwind-protect
1777 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
1778 (tramp-set-connection-property v "stat" nil)
1779 (tramp-set-connection-property v "perl" nil)
1780 (tramp--test-utf8))
1781 ;; Reset suppressed properties.
1782 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
1783 (tramp-set-connection-property v "stat" 'undef)
1784 (tramp-set-connection-property v "perl" 'undef))))
1785
1598;; This test is inspired by Bug#16928. 1786;; This test is inspired by Bug#16928.
1599(ert-deftest tramp-test32-asynchronous-requests () 1787(ert-deftest tramp-test32-asynchronous-requests ()
1600 "Check parallel asynchronous requests. 1788 "Check parallel asynchronous requests.
@@ -1758,7 +1946,7 @@ Since it unloads Tramp, it shall be the last test to run."
1758;; doesn't work well when an interactive password must be provided. 1946;; doesn't work well when an interactive password must be provided.
1759;; * Fix `tramp-test27-start-file-process' for `nc' and on MS 1947;; * Fix `tramp-test27-start-file-process' for `nc' and on MS
1760;; Windows (`process-send-eof'?). 1948;; Windows (`process-send-eof'?).
1761;; * Fix `tramp-test30-special-characters' for `adb' and `nc'. 1949;; * Fix `tramp-test30-special-characters' for `nc'.
1762;; * Fix `tramp-test31-utf8' for `nc'/`telnet' (when target is a dumb 1950;; * Fix `tramp-test31-utf8' for `nc'/`telnet' (when target is a dumb
1763;; busybox). Seems to be in `directory-files'. 1951;; busybox). Seems to be in `directory-files'.
1764;; * Fix Bug#16928. Set expected error of `tramp-test32-asynchronous-requests'. 1952;; * Fix Bug#16928. Set expected error of `tramp-test32-asynchronous-requests'.