From 37169e549094ea426d6429f088515e5fc416785c Mon Sep 17 00:00:00 2001 From: Nick Drozd 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