[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master b8fdef7aa6 2/2: Convert ffap comments to tests
From: |
Stefan Kangas |
Subject: |
master b8fdef7aa6 2/2: Convert ffap comments to tests |
Date: |
Thu, 28 Jul 2022 09:08:24 -0400 (EDT) |
branch: master
commit b8fdef7aa65f5b1d2eeb726ff1627d9e169c2b3a
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>
Convert ffap comments to tests
* test/lisp/ffap-tests.el (ffap-file-remote-p, ffap-machine-p):
New tests.
---
lisp/ffap.el | 12 +-----------
test/lisp/ffap-tests.el | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/lisp/ffap.el b/lisp/ffap.el
index dc286db130..ffed9f9759 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -427,13 +427,6 @@ Returned values:
t means that HOST answered.
`accept' means the relevant variable told us to accept.
\"mesg\" means HOST exists, but does not respond for some reason."
- ;; Try some (Emory local):
- ;; (ffap-machine-p "ftp" nil nil 'ping)
- ;; (ffap-machine-p "nonesuch" nil nil 'ping)
- ;; (ffap-machine-p "ftp.mathcs.emory.edu" nil nil 'ping)
- ;; (ffap-machine-p "mathcs" 5678 nil 'ping)
- ;; (ffap-machine-p "foo.bonk" nil nil 'ping)
- ;; (ffap-machine-p "foo.bonk.com" nil nil 'ping)
(if (or (string-match "[^-[:alnum:].]" host) ; Invalid chars (?)
(not (string-match "[^0-9]" host))) ; 1: a number? 2: quick reject
nil
@@ -530,9 +523,6 @@ The optional NOMODIFY argument suppresses the extra search."
(defun ffap-file-remote-p (filename)
"If FILENAME looks remote, return it (maybe slightly improved)."
- ;; (ffap-file-remote-p "/user@foo.bar.com:/pub")
- ;; (ffap-file-remote-p "/cssun.mathcs.emory.edu://dir")
- ;; (ffap-file-remote-p "/ffap.el:80")
(or (and ffap-ftp-regexp
(string-match ffap-ftp-regexp filename)
;; Convert "/host.com://dir" to "/host:/dir", to handle a dying
@@ -573,7 +563,7 @@ Looks at `ffap-ftp-default-user', returns \"\" for
\"localhost\"."
;; www.ncsa.uiuc.edu
((and (string-match "\\`w\\(ww\\|eb\\)[-.]" mach))
(concat "http://" mach "/"))
- ;; More cases? Maybe "telnet:" for archie?
+ ;; More cases?
(ffap-ftp-regexp (ffap-host-to-filename mach))
))
diff --git a/test/lisp/ffap-tests.el b/test/lisp/ffap-tests.el
index a11af9507e..076d825642 100644
--- a/test/lisp/ffap-tests.el
+++ b/test/lisp/ffap-tests.el
@@ -33,6 +33,25 @@
(ffap-replace-file-component "/ftp:who@foo.com:/whatever" "/new")
"/ftp:who@foo.com:/new")))
+(ert-deftest ffap-file-remote-p ()
+ (dolist (test '(("/user@foo.bar.com:/pub" .
+ "/user@foo.bar.com:/pub")
+ ("/cssun.mathcs.emory.edu://dir" .
+ "/cssun.mathcs.emory.edu:/dir")
+ ("/ffap.el:80" .
+ "/ffap.el:80")))
+ (let ((A (car test))
+ (B (cdr test)))
+ (should (equal (ffap-file-remote-p A) B)))))
+
+(ert-deftest ffap-machine-p ()
+ (should-not (ffap-machine-p "ftp"))
+ (should-not (ffap-machine-p "nonesuch"))
+ (should (eq (ffap-machine-p "ftp.mathcs.emory.edu") 'accept))
+ (should-not (ffap-machine-p "mathcs" 5678))
+ (should-not (ffap-machine-p "foo.bonk"))
+ (should (eq (ffap-machine-p "foo.bonk.com") 'accept)))
+
(ert-deftest ffap-tests-25243 ()
"Test for https://debbugs.gnu.org/25243 ."
(ert-with-temp-file file