summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSebastian Wiesner <lunaryorn@gmail.com>2014-03-10 11:26:30 +0100
committerSebastian Wiesner <lunaryorn@gmail.com>2014-03-10 11:27:58 +0100
commitd0fac34e167b0e8559d4654c7e584eba0ca7323e (patch)
tree183f8abaa9b3d52aadcc8d6c906ab107a39efaab /test
parente474a49ceffc2e55385dc447a3004e3c8531a5a8 (diff)
Simplify test suite setup
Diffstat (limited to 'test')
-rw-r--r--test/test-helper.el69
1 files changed, 12 insertions, 57 deletions
diff --git a/test/test-helper.el b/test/test-helper.el
index ac4673f..56dd754 100644
--- a/test/test-helper.el
+++ b/test/test-helper.el
@@ -24,71 +24,26 @@
;;; Code:
-(require 'cl-lib)
-(require 'find-func)
-(require 'f)
-
(unless noninteractive
- (error "The test suite cannot be used interactively."))
+ (error "The test suite cannot be used interactively"))
(message "Running tests on Emacs %s" emacs-version)
-
-;;;; Directories
-
-(eval-and-compile
- (defconst pkg-info-test-directory (f-parent (f-this-file))
- "Directory of unit tests.")
-
- (defconst pkg-info-source-directory (file-name-as-directory
- (f-parent pkg-info-test-directory))
- "Directory of unit tests."))
-
-
-;;;; Load pkg-info
-
-;; Load compatibility libraries for Emacs 23
-(load (f-join pkg-info-source-directory "compat" "load.el") nil 'no-message)
-
-(require 'pkg-info (f-join pkg-info-source-directory "pkg-info.elc"))
-
-;; Check that we are testing the right pkg-info library
-(cl-assert (f-same? (symbol-file #'pkg-info-package-version 'defun)
- (f-join pkg-info-source-directory "pkg-info.elc"))
- nil "ERROR: pkg-info not loaded from compiled source. Run make compile")
+(let* ((current-file (if load-in-progress load-file-name (buffer-file-name)))
+ (source-directory (locate-dominating-file current-file "Cask")))
-
-;;;; Provide dummy packages for unit tests
+ (load (expand-file-name "pkg-info" source-directory))
-(defconst pkg-info-test-package-directory
- (f-join pkg-info-test-directory "elpa")
- "Directory for temporary package installations.")
-
-(defun pkg-info-test-initialize-packages ()
- "Initialize packages for our unit tests."
- (epl-change-package-dir pkg-info-test-package-directory)
+ ;; Setup package.el for our tests
+ (setq package-user-dir (expand-file-name "test/elpa" source-directory))
+ (package-initialize)
+ ;; Install our dummy package
(unless (epl-package-installed-p 'pkg-info-dummy-package)
;; Only install the dummy package if needed
- (epl-add-archive "localhost" "http://127.0.0.1:9191/packages/")
- (epl-refresh)
- (let ((package (car (epl-find-available-packages 'pkg-info-dummy-package))))
- (unless package
- (error (error "Test dummy package missing. \
-Start servant with cask exec servant start")))
- (epl-package-install package))))
-
-(message "Running tests on Emacs %s" emacs-version)
-(pkg-info-test-initialize-packages)
-
-
-;;;; Utilities
-
-(defconst pkg-info-version
- (let ((default-directory pkg-info-source-directory))
- (version-to-list (car (process-lines "cask" "version"))))
- "The pkg-info version, to use in unit tests.")
-
-(provide 'test-helper)
+ (add-to-list 'package-archives
+ '("localhost" . "http://127.0.0.1:9191/packages/"))
+ (package-refresh-contents)
+ (package-install 'pkg-info-dummy-package)))
;; Local Variables:
;; indent-tabs-mode: nil