diff options
author | Filipp Gunbin <fgunbin@fastmail.fm> | 2018-05-15 03:02:49 +0300 |
---|---|---|
committer | Noam Postavsky <npostavs@gmail.com> | 2018-08-10 08:36:24 -0400 |
commit | 5e42c349a0533602c23bf651d6b28eca25e95a46 (patch) | |
tree | 3b73ef3bcd510e0201e65980343d9f92bd7dd64c /test/lisp/auth-source-tests.el | |
parent | 71c92d89137b7fdde6c2bd4bed9b8dfda5fa53dd (diff) | |
download | emacs-5e42c349a0533602c23bf651d6b28eca25e95a46.tar.gz |
Fix bugs in `auth-source-netrc-parse-one'.
* lisp/auth-source.el (auth-source-netrc-parse-one): Ensure that match
data is not overwritten in `auth-source-netrc-parse-next-interesting'.
Ensure that blanks are skipped before and after going over comments
and eols.
* test/lisp/auth-source-tests.el (auth-source-test-netrc-parse-one): New test.
(cherry picked from commit 60ff8101449eea3a5ca4961299501efd83d011bd)
Diffstat (limited to 'test/lisp/auth-source-tests.el')
-rw-r--r-- | test/lisp/auth-source-tests.el | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/lisp/auth-source-tests.el b/test/lisp/auth-source-tests.el index c1ee9093744..90caac8e4a2 100644 --- a/test/lisp/auth-source-tests.el +++ b/test/lisp/auth-source-tests.el @@ -210,6 +210,25 @@ ("login" . "user1") ("machine" . "mymachine1")))))) +(ert-deftest auth-source-test-netrc-parse-one () + (should (equal (auth-source--test-netrc-parse-one--all + "machine host1\n# comment\n") + '("machine" "host1"))) + (should (equal (auth-source--test-netrc-parse-one--all + "machine host1\n \n \nmachine host2\n") + '("machine" "host1" "machine" "host2")))) + +(defun auth-source--test-netrc-parse-one--all (text) + "Parse TEXT with `auth-source-netrc-parse-one' until end,return list." + (with-temp-buffer + (insert text) + (goto-char (point-min)) + (let ((one (auth-source-netrc-parse-one)) all) + (while one + (push one all) + (setq one (auth-source-netrc-parse-one))) + (nreverse all)))) + (ert-deftest auth-source-test-format-prompt () (should (equal (auth-source-format-prompt "test %u %h %p" '((?u "user") (?h "host"))) "test user host %p"))) |