diff options
| author | F. Jason Park | 2022-07-11 05:14:57 -0700 |
|---|---|---|
| committer | F. Jason Park | 2022-11-16 21:34:36 -0800 |
| commit | 46c765ed09422767306bd7acfc8422d5ad4cea4a (patch) | |
| tree | 9f24e1baa24092c576573aa355f96899a9199fb5 /test | |
| parent | 5699e43f27ef5ca760a38572928be8a53819a430 (diff) | |
| download | emacs-46c765ed09422767306bd7acfc8422d5ad4cea4a.tar.gz emacs-46c765ed09422767306bd7acfc8422d5ad4cea4a.zip | |
Refactor erc-select-read-args
* lisp/erc/erc-backend.el (erc--server-connect-dumb-ipv6-regexp): Add
liberal pattern for matching bracketed IPv6 addresses.
(erc-server-connect): Remove brackets from IPv6 hosts before
connecting.
* lisp/erc/erc.el (erc--ensure-url): Add compat adapter to massage
partial URLs given as input that may be missing the scheme:// portion.
(erc-select-read-args): Keep bracketed IPv6 hosts
intact. Make this function fully URL-aware (was only partially so).
Accept optional `input' argument.
* lisp/erc/erc-tests.el (erc-tests--ipv6-examples,
erc--server-connect-dumb-ipv6-regexp, erc-select-read-args): Add test
reading user input during interactive invocations of entry points.
(Bug#56514.)
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/erc/erc-tests.el | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index c88dd9888d8..f72db816af4 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el | |||
| @@ -953,4 +953,93 @@ | |||
| 953 | (kill-buffer "ExampleNet") | 953 | (kill-buffer "ExampleNet") |
| 954 | (kill-buffer "#chan"))) | 954 | (kill-buffer "#chan"))) |
| 955 | 955 | ||
| 956 | (defvar erc-tests--ipv6-examples | ||
| 957 | '("1:2:3:4:5:6:7:8" | ||
| 958 | "::ffff:10.0.0.1" "::ffff:1.2.3.4" "::ffff:0.0.0.0" | ||
| 959 | "1:2:3:4:5:6:77:88" "::ffff:255.255.255.255" | ||
| 960 | "fe08::7:8" "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" | ||
| 961 | "1:2:3:4:5:6:7:8" "1::" "1:2:3:4:5:6:7::" "1::8" | ||
| 962 | "1:2:3:4:5:6::8" "1:2:3:4:5:6::8" "1::7:8" "1:2:3:4:5::7:8" | ||
| 963 | "1:2:3:4:5::8" "1::6:7:8" "1:2:3:4::6:7:8" "1:2:3:4::8" | ||
| 964 | "1::5:6:7:8" "1:2:3::5:6:7:8" "1:2:3::8" "1::4:5:6:7:8" | ||
| 965 | "1:2::4:5:6:7:8" "1:2::8" "1::3:4:5:6:7:8" "1::3:4:5:6:7:8" | ||
| 966 | "1::8" "::2:3:4:5:6:7:8" "::2:3:4:5:6:7:8" "::8" | ||
| 967 | "::" "fe08::7:8%eth0" "fe08::7:8%1" "::255.255.255.255" | ||
| 968 | "::ffff:255.255.255.255" "::ffff:0:255.255.255.255" | ||
| 969 | "2001:db8:3:4::192.0.2.33" "64:ff9b::192.0.2.33")) | ||
| 970 | |||
| 971 | (ert-deftest erc--server-connect-dumb-ipv6-regexp () | ||
| 972 | (dolist (a erc-tests--ipv6-examples) | ||
| 973 | (should-not (string-match erc--server-connect-dumb-ipv6-regexp a)) | ||
| 974 | (should (string-match erc--server-connect-dumb-ipv6-regexp | ||
| 975 | (concat "[" a "]"))))) | ||
| 976 | |||
| 977 | (ert-deftest erc-select-read-args () | ||
| 978 | |||
| 979 | (ert-info ("Defaults to TLS") | ||
| 980 | (should (equal (ert-simulate-keys "\r\r\r\r" | ||
| 981 | (erc-select-read-args)) | ||
| 982 | (list :server "irc.libera.chat" | ||
| 983 | :port 6697 | ||
| 984 | :nick (user-login-name) | ||
| 985 | :password nil)))) | ||
| 986 | |||
| 987 | (ert-info ("Override default TLS") | ||
| 988 | (should (equal (ert-simulate-keys "irc://irc.libera.chat\r\r\r\r" | ||
| 989 | (erc-select-read-args)) | ||
| 990 | (list :server "irc.libera.chat" | ||
| 991 | :port 6667 | ||
| 992 | :nick (user-login-name) | ||
| 993 | :password nil)))) | ||
| 994 | |||
| 995 | (ert-info ("Address includes port") | ||
| 996 | (should (equal (ert-simulate-keys | ||
| 997 | "localhost:6667\rnick\r\r" | ||
| 998 | (erc-select-read-args)) | ||
| 999 | (list :server "localhost" | ||
| 1000 | :port 6667 | ||
| 1001 | :nick "nick" | ||
| 1002 | :password nil)))) | ||
| 1003 | |||
| 1004 | (ert-info ("Address includes nick, password skipped via option") | ||
| 1005 | (should (equal (ert-simulate-keys "nick@localhost:6667\r" | ||
| 1006 | (let (erc-prompt-for-password) | ||
| 1007 | (erc-select-read-args))) | ||
| 1008 | (list :server "localhost" | ||
| 1009 | :port 6667 | ||
| 1010 | :nick "nick" | ||
| 1011 | :password nil)))) | ||
| 1012 | |||
| 1013 | (ert-info ("Addresss includes nick and password") | ||
| 1014 | (should (equal (ert-simulate-keys "nick:sesame@localhost:6667\r" | ||
| 1015 | (erc-select-read-args)) | ||
| 1016 | (list :server "localhost" | ||
| 1017 | :port 6667 | ||
| 1018 | :nick "nick" | ||
| 1019 | :password "sesame")))) | ||
| 1020 | |||
| 1021 | (ert-info ("IPv6 address plain") | ||
| 1022 | (should (equal (ert-simulate-keys "::1\r\r\r\r" | ||
| 1023 | (erc-select-read-args)) | ||
| 1024 | (list :server "[::1]" | ||
| 1025 | :port 6667 | ||
| 1026 | :nick (user-login-name) | ||
| 1027 | :password nil)))) | ||
| 1028 | |||
| 1029 | (ert-info ("IPv6 address with port") | ||
| 1030 | (should (equal (ert-simulate-keys "[::1]:6667\r\r\r" | ||
| 1031 | (erc-select-read-args)) | ||
| 1032 | (list :server "[::1]" | ||
| 1033 | :port 6667 | ||
| 1034 | :nick (user-login-name) | ||
| 1035 | :password nil)))) | ||
| 1036 | |||
| 1037 | (ert-info ("IPv6 address includes nick") | ||
| 1038 | (should (equal (ert-simulate-keys "nick@[::1]:6667\r\r" | ||
| 1039 | (erc-select-read-args)) | ||
| 1040 | (list :server "[::1]" | ||
| 1041 | :port 6667 | ||
| 1042 | :nick "nick" | ||
| 1043 | :password nil))))) | ||
| 1044 | |||
| 956 | ;;; erc-tests.el ends here | 1045 | ;;; erc-tests.el ends here |