summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2018-02-09 18:27:23 -0700
committerSean Whitton <spwhitton@spwhitton.name>2018-02-09 18:27:23 -0700
commit9ead0907f23d63bde989f5b9170edbc733ffbaf9 (patch)
tree10afce8d302468aa1eab5bcdaf6ea5d92c03c8ae
parenta58687bed98c69353fc4cdb9dd229e01f83972d1 (diff)
parentfd906d3f92d58ecf24169055744409886ceb06ce (diff)
Merge tag '0.9'
epl 0.9
-rw-r--r--.travis.yml24
-rw-r--r--epl.el34
-rw-r--r--test/epl-test.el36
-rw-r--r--test/resources/.nosearch0
-rw-r--r--test/resources/versioned-package-new.el32
-rw-r--r--test/resources/versioned-package.el32
6 files changed, 136 insertions, 22 deletions
diff --git a/.travis.yml b/.travis.yml
index 20ff50b..7fb28f4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,16 +1,14 @@
-language: emacs-lisp
-env:
- - EMACS=emacs24
- - EMACS=emacs-snapshot
+language: generic
before_install:
- - sudo add-apt-repository -y ppa:cassou/emacs # Emacs 24.3
- - sudo add-apt-repository -y ppa:ubuntu-elisp/ppa # Emacs snapshot
- - sudo apt-get update
- - sudo apt-get install -y "${EMACS}"-nox
- # Install and bootstrap cask
- - curl -fsSkL https://raw.github.com/cask/cask/master/go | python
- - export PATH="${HOME}/.cask/bin:$PATH"
-install:
- - cask install
+ - curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh
+ - evm install $EVM_EMACS --use --skip
+ - cask
+env:
+ - EVM_EMACS=emacs-24.1-travis
+ - EVM_EMACS=emacs-24.2-travis
+ - EVM_EMACS=emacs-24.3-travis
+ - EVM_EMACS=emacs-24.4-travis
+ - EVM_EMACS=emacs-24.5-travis
script:
+ - emacs --version
- make test
diff --git a/epl.el b/epl.el
index cc6f8ad..049ff8c 100644
--- a/epl.el
+++ b/epl.el
@@ -6,7 +6,7 @@
;; Author: Sebastian Wiesner <swiesner@lunaryorn.com>
;; Maintainer: Johan Andersson <johan.rejeep@gmail.com>
;; Sebastian Wiesner <swiesner@lunaryorn.com>
-;; Version: 0.8
+;; Version: 0.9
;; Package-Requires: ((cl-lib "0.3"))
;; Keywords: convenience
;; URL: http://github.com/cask/epl
@@ -438,16 +438,17 @@ typically ends with -pkg.el."
;;; Package database access
-(defun epl-package-installed-p (package)
- "Determine whether a PACKAGE is installed.
+(defun epl-package-installed-p (package &optional min-version)
+ "Determine whether a PACKAGE, of MIN-VERSION or newer, is installed.
-PACKAGE is either a package name as symbol, or a package object."
+PACKAGE is either a package name as symbol, or a package object.
+When a explicit MIN-VERSION is provided it overwrites the version of the PACKAGE object."
(let ((name (if (epl-package-p package)
(epl-package-name package)
package))
- (version (when (epl-package-p package)
- (epl-package-version package))))
- (package-installed-p name version)))
+ (min-version (or min-version (and (epl-package-p package)
+ (epl-package-version package)))))
+ (package-installed-p name min-version)))
(defun epl--parse-built-in-entry (entry)
"Parse an ENTRY from the list of built-in packages.
@@ -629,7 +630,21 @@ packages."
;;; Package operations
-(defalias 'epl-install-file 'package-install-file)
+(defun epl-install-file (file)
+ "Install a package from FILE, like `package-install-file'."
+ (interactive (advice-eval-interactive-spec
+ (cadr (interactive-form #'package-install-file))))
+ (apply #'package-install-file (list file))
+ (let ((package (epl-package-from-file file)))
+ (unless (epl-package--package-desc-p package)
+ (epl--kill-autoload-buffer package))))
+
+(defun epl--kill-autoload-buffer (package)
+ "Kill the buffer associated with autoloads for PACKAGE."
+ (let* ((auto-name (format "%s-autoloads.el" (epl-package-name package)))
+ (generated-autoload-file (expand-file-name auto-name (epl-package-directory package)))
+ (buf (find-buffer-visiting generated-autoload-file)))
+ (when buf (kill-buffer buf))))
(defun epl-package-install (package &optional force)
"Install a PACKAGE.
@@ -641,7 +656,8 @@ non-nil, install PACKAGE, even if it is already installed."
(package-install (epl-package-description package))
;; The legacy API installs by name. We have no control over versioning,
;; etc.
- (package-install (epl-package-name package)))))
+ (package-install (epl-package-name package))
+ (epl--kill-autoload-buffer package))))
(defun epl-package-delete (package)
"Delete a PACKAGE.
diff --git a/test/epl-test.el b/test/epl-test.el
index 7d68494..31a88ac 100644
--- a/test/epl-test.el
+++ b/test/epl-test.el
@@ -200,6 +200,42 @@ package.el tends to have such unfortunate side effects."
(epl-package-delete package)
(should-not (epl-package-installed-p package))))))
+(ert-deftest epl-package-installed-p/min-version ()
+ (epl-test/with-sandbox
+ (let ((package-file (epl-test-resource-file-name "versioned-package.el"))
+ (new-package-file (epl-test-resource-file-name "versioned-package-new.el")))
+ (epl-install-file package-file)
+ (let ((package (car (epl-find-installed-packages 'versioned-package))))
+ (should (epl-package-installed-p package))
+ (should (epl-package-installed-p package (version-to-list "8.2.10")))
+ (should (epl-package-installed-p package (version-to-list "8.2.9")))
+ (should (epl-package-installed-p package (version-to-list "8.2")))
+ (should (epl-package-installed-p package (version-to-list "8")))
+ (should-not (epl-package-installed-p package (version-to-list "8.2.11")))
+ (should-not (epl-package-installed-p package (version-to-list "8.3.10")))
+ (should-not (epl-package-installed-p package (version-to-list "9.1.6")))
+ (should-not (epl-package-installed-p package (version-to-list "999999")))))))
+
+(ert-deftest epl-package-installed-p/min-version-upgrade ()
+ (epl-test/with-sandbox
+ (let ((package-file (epl-test-resource-file-name "versioned-package.el"))
+ (new-package-file (epl-test-resource-file-name "versioned-package-new.el")))
+ (epl-install-file package-file)
+ (let ((package (car (epl-find-installed-packages 'versioned-package))))
+ (should (epl-package-installed-p package))
+ (should-not (epl-package-installed-p package (version-to-list "9.1.6")))
+ (epl-install-file new-package-file)
+ (let ((package (car (epl-find-installed-packages 'versioned-package))))
+ (should (epl-package-installed-p package))
+ (should (epl-package-installed-p package (version-to-list "8.2.10")))
+ (should (epl-package-installed-p package (version-to-list "8.2.9")))
+ (should (epl-package-installed-p package (version-to-list "8.2")))
+ (should (epl-package-installed-p package (version-to-list "8")))
+ (should (epl-package-installed-p package (version-to-list "8.2.11")))
+ (should (epl-package-installed-p package (version-to-list "8.3.10")))
+ (should (epl-package-installed-p package (version-to-list "9.1.6")))
+ (should-not (epl-package-installed-p package (version-to-list "999999"))))))))
+
(provide 'epl-test)
;;; epl-test.el ends here
diff --git a/test/resources/.nosearch b/test/resources/.nosearch
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/resources/.nosearch
diff --git a/test/resources/versioned-package-new.el b/test/resources/versioned-package-new.el
new file mode 100644
index 0000000..7dd2b43
--- /dev/null
+++ b/test/resources/versioned-package-new.el
@@ -0,0 +1,32 @@
+;;; versioned-package.el --- EPL: Dummy package for unit tests -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2018 Sam Brightman
+
+;; Author: Sam Brightman <sam.brightman@gmail.com>
+;; Version: 9.1.6
+
+;; This file is NOT part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; A dummy package to test EPL
+
+;;; Code:
+
+
+(provide 'versioned-package)
+
+;;; versioned-package.el ends here
diff --git a/test/resources/versioned-package.el b/test/resources/versioned-package.el
new file mode 100644
index 0000000..4e39d0d
--- /dev/null
+++ b/test/resources/versioned-package.el
@@ -0,0 +1,32 @@
+;;; versioned-package.el --- EPL: Dummy package for unit tests -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2018 Sam Brightman
+
+;; Author: Sam Brightman <sam.brightman@gmail.com>
+;; Version: 8.2.10
+
+;; This file is NOT part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; A dummy package to test EPL
+
+;;; Code:
+
+
+(provide 'versioned-package)
+
+;;; versioned-package.el ends here