From 0363a70d9e7e853d7f4cd632c63b994fe2ef49a5 Mon Sep 17 00:00:00 2001 From: Nick Drozd Date: Sat, 11 Jul 2020 10:02:27 -0500 Subject: [PATCH] Clean up Tramp version check * aclocal.m4 (TRAMP_EMACS_VERSION_CHECK): Rewrite * trampver.el.in (tramp-minimum-emacs-version): New variable (tramp-check-version): New function (tramp-tests.el): New test --- aclocal.m4 | 9 +++++---- lisp/trampver.el.in | 11 ++++++++--- test/tramp-tests.el | 8 ++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index d4a82cf9..91376978 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -75,10 +75,11 @@ AC_DEFUN(AC_EMACS_INFO, [ AC_SUBST(TRAMP_EMACS_REQUIRED_VERSION) dnl Starting with Emacs 26.1, we could use `string-version-lessp'. TRAMP_EMACS_VERSION_CHECK="\ - (if (not (string-lessp emacs-version \"${TRAMP_EMACS_REQUIRED_VERSION}\")) - \"ok\" - (format \"${PACKAGE_STRING} is not fit for %s\" - (replace-regexp-in-string \"\\n\" \"\" (emacs-version))))" +(progn ; <-- don't touch this progn + (when (string-lessp emacs-version \"${TRAMP_EMACS_REQUIRED_VERSION}\") + (error \"${PACKAGE_STRING} is not fit for %s\" + (replace-regexp-in-string \"\n\" \"\" (emacs-version)))) + \"ok\")" AC_SUBST(TRAMP_EMACS_VERSION_CHECK) AC_MSG_CHECKING([for $EMACS version]) diff --git a/lisp/trampver.el.in b/lisp/trampver.el.in index f487b332..add870ab 100644 --- a/lisp/trampver.el.in +++ b/lisp/trampver.el.in @@ -69,9 +69,14 @@ (emacs-repository-get-version dir)))) "The repository revision of the Tramp sources.") -;; Check for Emacs version. -(let ((x @TRAMP_EMACS_VERSION_CHECK@)) - (unless (string-equal "ok" x) (error "%s" x))) +(defconst tramp-minimum-emacs-version "@TRAMP_EMACS_REQUIRED_VERSION@" + "The minimum Emacs version required by Tramp.") + +(defun tramp-check-version () + "Error if `emacs-version' is less than `tramp-minimum-emacs-version'." + @TRAMP_EMACS_VERSION_CHECK@) + +(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/tramp-tests.el b/test/tramp-tests.el index 97f228f6..25568e33 100644 --- a/test/tramp-tests.el +++ b/test/tramp-tests.el @@ -6666,6 +6666,14 @@ Since it unloads Tramp, it shall be the last test to run." (ignore-errors (all-completions "tramp" (symbol-value x))) (ert-fail (format "Hook `%s' still contains Tramp function" x)))))) +(ert-deftest tramp-test47-version () + "Check that the version check checks out." + (should (string-equal "ok" (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