unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#42237: [PATCH] Clean up Tramp version check
@ 2020-07-06 22:19 Nicholas Drozd
  2020-07-07  7:19 ` Michael Albinus
  0 siblings, 1 reply; 11+ messages in thread
From: Nicholas Drozd @ 2020-07-06 22:19 UTC (permalink / raw)
  To: 42237

[-- Attachment #1: Type: text/plain, Size: 152 bytes --]

I actually saw the "not fit for" error message in the wild. The source
looked a little strange, so I cleaned it up. This shouldn't change any
behavior.

[-- Attachment #2: 0001-Clean-up-Tramp-version-check.patch --]
[-- Type: text/x-patch, Size: 2411 bytes --]

From 37169e549094ea426d6429f088515e5fc416785c Mon Sep 17 00:00:00 2001
From: Nick Drozd <nicholasdrozd@gmail.com>
Date: Sat, 4 Jul 2020 11:42:49 -0500
Subject: [PATCH] Clean up Tramp version check

* lisp/net/trampver.el
(tramp-minimum-emacs-version, tramp-check-version): New constant, new function
* test/lisp/net/tramp-tests.el
(tramp-test46-version): New test
---
 lisp/net/trampver.el         | 16 ++++++++++------
 test/lisp/net/tramp-tests.el |  8 ++++++++
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el
index 8d21133b3b..42d984dae3 100644
--- a/lisp/net/trampver.el
+++ b/lisp/net/trampver.el
@@ -69,12 +69,16 @@ tramp-repository-version
 	   (emacs-repository-get-version dir))))
   "The repository revision of the Tramp sources.")
 
-;; Check for Emacs version.
-(let ((x   (if (not (string-lessp emacs-version "25.1"))
-      "ok"
-    (format "Tramp 2.5.0-pre is not fit for %s"
-            (replace-regexp-in-string "\n" "" (emacs-version))))))
-  (unless (string-equal "ok" x) (error "%s" x)))
+(defconst tramp-minimum-emacs-version "25.1"
+  "The minimum Emacs version required by Tramp.")
+
+(defun tramp-check-version ()
+  "Error if `emacs-version' is less than `tramp-minimum-emacs-version'."
+  (when (string-lessp emacs-version tramp-minimum-emacs-version)
+    (error "Tramp 2.5.0-pre is not fit for %s"
+           (replace-regexp-in-string "\n" "" (emacs-version)))))
+
+(tramp-check-version)
 
 ;; Tramp versions integrated into Emacs.  If a user option declares a
 ;; `:package-version' which doesn't belong to an integrated Tramp
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 1f24ba2786..ff112e9c82 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -6557,6 +6557,14 @@ tramp-test45-unload
 	  (ignore-errors (all-completions "tramp" (symbol-value x)))
 	  (ert-fail (format "Hook `%s' still contains Tramp function" x))))))
 
+(ert-deftest tramp-test46-version ()
+  "Check that the version check checks out."
+  (tramp-check-version)
+  (let ((emacs-version "24.3"))
+    (should-error (tramp-check-version)))
+  (let ((tramp-minimum-emacs-version "30.1"))
+    (should-error (tramp-check-version))))
+
 (defun tramp-test-all (&optional interactive)
   "Run all tests for \\[tramp].
 If INTERACTIVE is non-nil, the tests are run interactively."
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-10-20  9:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CABAiW0oLzyf3hQVFLbML-vpy8B-k+iS4bEj6z__z65tRkVPYZg@mail.gmail.com>
2020-07-12 13:48 ` bug#42237: [PATCH] Clean up Tramp version check Michael Albinus
     [not found] ` <87tuyczvwn.fsf@gmx.de>
2020-07-12 19:54   ` Nicholas Drozd
     [not found]   ` <CABAiW0rCjbjQUXR6+PDn34R7Rs264xMeJS=wZ6stp=0iRs4mRA@mail.gmail.com>
2020-07-13 13:06     ` Michael Albinus
     [not found]     ` <87lfjnzhrk.fsf@gmx.de>
2020-07-13 13:55       ` Michael Albinus
     [not found]       ` <87ft9vzfhi.fsf@gmx.de>
2020-10-18 15:13         ` Michael Albinus
2020-10-19 17:07           ` Nicholas Drozd
     [not found]           ` <CABAiW0pOjeMSFicn2=qnmVz830UbvvDBXTb3r51b+DDf9WWfTA@mail.gmail.com>
2020-10-20  9:31             ` Michael Albinus
2020-08-14  9:17     ` Stefan Kangas
2020-08-15 13:40       ` Michael Albinus
2020-07-06 22:19 Nicholas Drozd
2020-07-07  7:19 ` Michael Albinus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).