Skip to content

Proposal - Add Cask to deal with test dependencies #372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
haskell-mode-autoloads.el
haskell-mode.info
haskell-mode.tmp.texi
dir
dir
/.cask/
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ env:
- EMACS=emacs23
- EMACS=emacs24
- EMACS=emacs-snapshot
global:
- PATH=$HOME/.cask/bin:$PATH

matrix:
allow_failures:
Expand All @@ -27,6 +29,9 @@ install:
sudo apt-get install -qq emacs-snapshot &&
sudo apt-get install -qq emacs-snapshot-el emacs-snapshot-gtk;
fi
- make deps
- cask --version
- cask

script:
lsb_release -a && $EMACS --version && make EMACS=$EMACS check
Expand Down
11 changes: 11 additions & 0 deletions Cask
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(source gnu)
(source melpa)

(package-file "haskell-mode.el")

(files "*.el")

(development
(depends-on "ert")
(depends-on "ert-expectations")
(depends-on "el-mock"))
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,17 @@ ELCHECKS=$(addprefix check-, $(ELFILES:.el=))

.PHONY: all compile info clean check $(ELCHECKS) elpa package

deps:
curl -fsSkL https://raw.github.com/cask/cask/master/go | python

all: compile $(AUTOLOADS) info

compile: $(ELCFILES)

$(ELCHECKS): check-%: %.el %.elc
@$(BATCH) --eval '(when (check-declare-file "$*.el") (error "check-declare failed"))'
@if [ -f "$(<:%.el=tests/%-tests.el)" ]; then \
$(BATCH) -l "$(<:%.el=tests/%-tests.el)" -f ert-run-tests-batch-and-exit; \
cask exec $(BATCH) -l "$(<:%.el=tests/%-tests.el)" -f ert-run-tests-batch-and-exit; \
fi
@echo "--"

Expand Down
1 change: 1 addition & 0 deletions haskell-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
;; 2003 Dave Love <[email protected]>
;; Keywords: faces files Haskell
;; URL: https://github.com/haskell/haskell-mode
;; Version: 13.07
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need a version here otherwise cask is not happy.
What should be the right one here?


;; This file is not part of GNU Emacs.

Expand Down
99 changes: 99 additions & 0 deletions tests/haskell-process-tests.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
;;; haskell-process-tests.el

;;; Code:

(require 'ert)
(require 'haskell-process)

(eval-when-compile (require 'cl)) ;; for tests with mock to pass...
(require 'el-mock)

(ert-deftest haskell-process-wrapper-command-function-identity ()
"No wrapper, return directly the command."
(should (equal '("ghci")
(progn
(custom-set-variables '(haskell-process-wrapper-function #'identity))
(apply haskell-process-wrapper-function (list '("ghci")))))))

(ert-deftest haskell-process-wrapper-function-non-identity ()
"Wrapper as a string, return the wrapping command as a string."
(should (equal '("nix-shell" "default.nix" "--command" "cabal\\ run")
(progn
(custom-set-variables '(haskell-process-wrapper-function (lambda (argv)
(append '("nix-shell" "default.nix" "--command")
(list (shell-quote-argument argv))))))
(apply haskell-process-wrapper-function (list "cabal run"))))))

(ert-deftest test-haskell-process--compute-process-log-and-command-ghci ()
(should (equal '("Starting inferior GHCi process ghci ..." "dumses1" nil "ghci" "-ferror-spans")
(let ((haskell-process-path-ghci "ghci")
(haskell-process-args-ghci '("-ferror-spans")))
(custom-set-variables '(haskell-process-wrapper-function #'identity))
(mocklet (((haskell-session-name "dummy-session") => "dumses1"))
(haskell-process-compute-process-log-and-command "dummy-session" 'ghci))))))

(ert-deftest test-haskell-process--with-wrapper-compute-process-log-and-command-ghci ()
(should (equal '("Starting inferior GHCi process ghci ..." "dumses1" nil "nix-shell" "default.nix" "--command" "ghci\\ -ferror-spans")
(let ((haskell-process-path-ghci "ghci")
(haskell-process-args-ghci '("-ferror-spans")))
(custom-set-variables '(haskell-process-wrapper-function
(lambda (argv) (append (list "nix-shell" "default.nix" "--command" )
(list (shell-quote-argument (mapconcat 'identity argv " ")))))))
(mocklet (((haskell-session-name "dummy-session") => "dumses1"))
(haskell-process-compute-process-log-and-command "dummy-session" 'ghci))))))

(ert-deftest test-haskell-process--compute-process-log-and-command-cabal-repl ()
(should (equal '("Starting inferior `cabal repl' process using cabal ..." "dumses2" nil "cabal" "repl" "--ghc-option=-ferror-spans" "dumdum-session")
(let ((haskell-process-path-cabal "cabal")
(haskell-process-args-cabal-repl '("--ghc-option=-ferror-spans")))
(custom-set-variables '(haskell-process-wrapper-function #'identity))
(mocklet (((haskell-session-name "dummy-session2") => "dumses2")
((haskell-session-target "dummy-session2") => "dumdum-session"))
(haskell-process-compute-process-log-and-command "dummy-session2" 'cabal-repl))))))

(ert-deftest test-haskell-process--with-wrapper-compute-process-log-and-command-cabal-repl ()
(should (equal '("Starting inferior `cabal repl' process using cabal ..." "dumses2" nil "nix-shell" "default.nix" "--command" "cabal\\ repl\\ --ghc-option\\=-ferror-spans" "dumdum-session")
(let ((haskell-process-path-cabal "cabal")
(haskell-process-args-cabal-repl '("--ghc-option=-ferror-spans")))
(custom-set-variables '(haskell-process-wrapper-function
(lambda (argv) (append (list "nix-shell" "default.nix" "--command" )
(list (shell-quote-argument (mapconcat 'identity argv " ")))))))
(mocklet (((haskell-session-name "dummy-session2") => "dumses2")
((haskell-session-target "dummy-session2") => "dumdum-session"))
(haskell-process-compute-process-log-and-command "dummy-session2" 'cabal-repl))))))

(ert-deftest test-haskell-process--compute-process-log-and-command-cabal-ghci ()
(should (equal '("Starting inferior cabal-ghci process using cabal-ghci ..." "dumses3" nil "cabal-ghci")
(let ((haskell-process-path-ghci "ghci"))
(custom-set-variables '(haskell-process-wrapper-function #'identity))
(mocklet (((haskell-session-name "dummy-session3") => "dumses3"))
(haskell-process-compute-process-log-and-command "dummy-session3" 'cabal-ghci))))))

(ert-deftest test-haskell-process--with-wrapper-compute-process-log-and-command-cabal-ghci ()
(should (equal '("Starting inferior cabal-ghci process using cabal-ghci ..." "dumses3" nil "nix-shell" "default.nix" "--command" "cabal-ghci")
(let ((haskell-process-path-ghci "ghci"))
(custom-set-variables '(haskell-process-wrapper-function
(lambda (argv) (append (list "nix-shell" "default.nix" "--command" )
(list (shell-quote-argument (mapconcat 'identity argv " ")))))))
(mocklet (((haskell-session-name "dummy-session3") => "dumses3"))
(haskell-process-compute-process-log-and-command "dummy-session3" 'cabal-ghci))))))

(ert-deftest test-haskell-process--compute-process-log-and-command-cabal-dev ()
(should (equal '("Starting inferior cabal-dev process cabal-dev -s directory/cabal-dev ..." "dumses4" nil "cabal-dev" "ghci" "-s" "directory/cabal-dev")
(let ((haskell-process-path-cabal-dev "cabal-dev"))
(custom-set-variables '(haskell-process-wrapper-function #'identity))
(mocklet (((haskell-session-name "dummy-session4") => "dumses4")
((haskell-session-cabal-dir "dummy-session4") => "directory"))
(haskell-process-compute-process-log-and-command "dummy-session4" 'cabal-dev))))))

(ert-deftest test-haskell-process--with-wrapper-compute-process-log-and-command-cabal-dev ()
(should (equal '("Starting inferior cabal-dev process cabal-dev -s directory/cabal-dev ..." "dumses4" nil "run-with-docker" "cabal-dev\\ ghci\\ -s\\ directory/cabal-dev")
(let ((haskell-process-path-cabal-dev "cabal-dev"))
(custom-set-variables '(haskell-process-wrapper-function
(lambda (argv) (append (list "run-with-docker")
(list (shell-quote-argument (mapconcat 'identity argv " ")))))))
(mocklet (((haskell-session-name "dummy-session4") => "dumses4")
((haskell-session-cabal-dir "dummy-session4") => "directory"))
(haskell-process-compute-process-log-and-command "dummy-session4" 'cabal-dev))))))

;;; haskell-process-tests.el ends here