Skip to content

Commit

Permalink
Reformat test helper
Browse files Browse the repository at this point in the history
  • Loading branch information
galaunay committed Nov 14, 2019
1 parent 1fbbabf commit fb92d72
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions test/test-helper.el
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
;; -*- lexical-binding: t -*-


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Load Elpy
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'f)
(let ((elpy-dir (f-parent (f-dirname (f-this-file)))))
(add-to-list 'load-path elpy-dir)
(add-to-list 'process-environment (format "PYTHONPATH=%s:%s"
elpy-dir
(getenv "PYTHONPATH")))
(add-to-list 'process-environment "ELPY_TEST=1"))
(require 'elpy)
;; Avoid asking stuff during tests
(defun yes-or-no-p (&rest args) t)
(defun y-or-n-p (&rest args) t)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Travis
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Travis is using virtualenvs to test specific version of python
;; we need to use it as the system environment
(advice-add 'elpy-rpc-get-virtualenv-path
Expand All @@ -21,9 +34,18 @@
(getenv "TRAVIS_PYTHON_VERSION")))
(apply fun args))))

(require 'elpy)
;; Travis regularly has some lag for some reason.
(setq elpy-rpc-timeout 10)
;; Print elpy configuration
(when (getenv "TRAVIS")
(elpy-config)
(with-current-buffer "*Elpy Config*"
(message (buffer-substring-no-properties (point-min) (point-max)))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Virtual environments
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; If the environment variable `ELPY_TEST_DONT_USE_VIRTUALENV' is
;; defined, don't check for features involving virtualenvs.
;; This permits testing on platforms that do not allow virtualenvs
Expand All @@ -33,6 +55,10 @@
(message "ELPY_TEST_DONT_USE_VIRTUALENV is set, skipping tests using virtualenvs.")
(setq elpy-rpc-virtualenv-path 'system))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Test helper
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmacro mletf* (bindings &rest body)
"Liket `cl-letf*', just with a slightly more concise function syntax.
Expand All @@ -50,12 +76,6 @@
bindings)
,@body))

;; Print elpy configuration
(mletf* ((y-or-n-p (&rest rest) t))
(elpy-config)
(with-current-buffer "*Elpy Config*"
(message (buffer-substring-no-properties (point-min) (point-max)))))

(defmacro with-temp-dir (name &rest body)
"Create a temporary directory and bind the symbol NAME to the path.
Expand Down Expand Up @@ -203,8 +223,3 @@ for that file."

(setq yas-verbosity 0)
(setq yas-snippet-dirs ())


;; Avoid asking stuff during tests
(defun yes-or-no-p (&rest args) t)
(defun y-or-n-p (&rest args) t)

0 comments on commit fb92d72

Please sign in to comment.