Skip to content

Commit ec29dfb

Browse files
committed
Use Cask to trigger tests (and solve dependencies)
Follow up from the discussion haskell#370 (comment) Use: - Install Cask - http://cask.readthedocs.org/en/latest/guide/installation.html ```sh curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python ``` - Trigger tests: ``` make check ``` This will use cask only for the tests target. Conflicts: Makefile tests/haskell-process-tests.el
1 parent db3c604 commit ec29dfb

File tree

6 files changed

+122
-2
lines changed

6 files changed

+122
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
haskell-mode-autoloads.el
44
haskell-mode.info
55
haskell-mode.tmp.texi
6-
dir
6+
dir
7+
/.cask/

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ env:
55
- EMACS=emacs23
66
- EMACS=emacs24
77
- EMACS=emacs-snapshot
8+
global:
9+
- PATH=$HOME/.cask/bin:$PATH
810

911
matrix:
1012
allow_failures:
@@ -27,6 +29,9 @@ install:
2729
sudo apt-get install -qq emacs-snapshot &&
2830
sudo apt-get install -qq emacs-snapshot-el emacs-snapshot-gtk;
2931
fi
32+
- make deps
33+
- cask --version
34+
- cask
3035

3136
script:
3237
lsb_release -a && $EMACS --version && make EMACS=$EMACS check

Cask

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(source gnu)
2+
(source melpa)
3+
4+
(package-file "haskell-mode.el")
5+
6+
(files "*.el")
7+
8+
(development
9+
(depends-on "ert")
10+
(depends-on "ert-expectations")
11+
(depends-on "el-mock"))

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,17 @@ ELCHECKS=$(addprefix check-, $(ELFILES:.el=))
6969

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

72+
deps:
73+
curl -fsSkL https://raw.github.com/cask/cask/master/go | python
74+
7275
all: compile $(AUTOLOADS) info
7376

7477
compile: $(ELCFILES)
7578

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

haskell-mode.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
;; 2003 Dave Love <[email protected]>
1111
;; Keywords: faces files Haskell
1212
;; URL: https://github.com/haskell/haskell-mode
13+
;; Version: 13.07
1314

1415
;; This file is not part of GNU Emacs.
1516

tests/haskell-process-tests.el

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
;;; haskell-process-tests.el
2+
3+
;;; Code:
4+
5+
(require 'ert)
6+
(require 'haskell-process)
7+
8+
(eval-when-compile (require 'cl)) ;; for tests with mock to pass...
9+
(require 'el-mock)
10+
11+
(ert-deftest haskell-process-wrapper-command-function-identity ()
12+
"No wrapper, return directly the command."
13+
(should (equal '("ghci")
14+
(progn
15+
(custom-set-variables '(haskell-process-wrapper-function #'identity))
16+
(apply haskell-process-wrapper-function (list '("ghci")))))))
17+
18+
(ert-deftest haskell-process-wrapper-function-non-identity ()
19+
"Wrapper as a string, return the wrapping command as a string."
20+
(should (equal '("nix-shell" "default.nix" "--command" "cabal\\ run")
21+
(progn
22+
(custom-set-variables '(haskell-process-wrapper-function (lambda (argv)
23+
(append '("nix-shell" "default.nix" "--command")
24+
(list (shell-quote-argument argv))))))
25+
(apply haskell-process-wrapper-function (list "cabal run"))))))
26+
27+
(ert-deftest test-haskell-process--compute-process-log-and-command-ghci ()
28+
(should (equal '("Starting inferior GHCi process ghci ..." "dumses1" nil "ghci" "-ferror-spans")
29+
(let ((haskell-process-path-ghci "ghci")
30+
(haskell-process-args-ghci '("-ferror-spans")))
31+
(custom-set-variables '(haskell-process-wrapper-function #'identity))
32+
(mocklet (((haskell-session-name "dummy-session") => "dumses1"))
33+
(haskell-process-compute-process-log-and-command "dummy-session" 'ghci))))))
34+
35+
(ert-deftest test-haskell-process--with-wrapper-compute-process-log-and-command-ghci ()
36+
(should (equal '("Starting inferior GHCi process ghci ..." "dumses1" nil "nix-shell" "default.nix" "--command" "ghci\\ -ferror-spans")
37+
(let ((haskell-process-path-ghci "ghci")
38+
(haskell-process-args-ghci '("-ferror-spans")))
39+
(custom-set-variables '(haskell-process-wrapper-function
40+
(lambda (argv) (append (list "nix-shell" "default.nix" "--command" )
41+
(list (shell-quote-argument (mapconcat 'identity argv " ")))))))
42+
(mocklet (((haskell-session-name "dummy-session") => "dumses1"))
43+
(haskell-process-compute-process-log-and-command "dummy-session" 'ghci))))))
44+
45+
(ert-deftest test-haskell-process--compute-process-log-and-command-cabal-repl ()
46+
(should (equal '("Starting inferior `cabal repl' process using cabal ..." "dumses2" nil "cabal" "repl" "--ghc-option=-ferror-spans" "dumdum-session")
47+
(let ((haskell-process-path-cabal "cabal")
48+
(haskell-process-args-cabal-repl '("--ghc-option=-ferror-spans")))
49+
(custom-set-variables '(haskell-process-wrapper-function #'identity))
50+
(mocklet (((haskell-session-name "dummy-session2") => "dumses2")
51+
((haskell-session-target "dummy-session2") => "dumdum-session"))
52+
(haskell-process-compute-process-log-and-command "dummy-session2" 'cabal-repl))))))
53+
54+
(ert-deftest test-haskell-process--with-wrapper-compute-process-log-and-command-cabal-repl ()
55+
(should (equal '("Starting inferior `cabal repl' process using cabal ..." "dumses2" nil "nix-shell" "default.nix" "--command" "cabal\\ repl\\ --ghc-option\\=-ferror-spans" "dumdum-session")
56+
(let ((haskell-process-path-cabal "cabal")
57+
(haskell-process-args-cabal-repl '("--ghc-option=-ferror-spans")))
58+
(custom-set-variables '(haskell-process-wrapper-function
59+
(lambda (argv) (append (list "nix-shell" "default.nix" "--command" )
60+
(list (shell-quote-argument (mapconcat 'identity argv " ")))))))
61+
(mocklet (((haskell-session-name "dummy-session2") => "dumses2")
62+
((haskell-session-target "dummy-session2") => "dumdum-session"))
63+
(haskell-process-compute-process-log-and-command "dummy-session2" 'cabal-repl))))))
64+
65+
(ert-deftest test-haskell-process--compute-process-log-and-command-cabal-ghci ()
66+
(should (equal '("Starting inferior cabal-ghci process using cabal-ghci ..." "dumses3" nil "cabal-ghci")
67+
(let ((haskell-process-path-ghci "ghci"))
68+
(custom-set-variables '(haskell-process-wrapper-function #'identity))
69+
(mocklet (((haskell-session-name "dummy-session3") => "dumses3"))
70+
(haskell-process-compute-process-log-and-command "dummy-session3" 'cabal-ghci))))))
71+
72+
(ert-deftest test-haskell-process--with-wrapper-compute-process-log-and-command-cabal-ghci ()
73+
(should (equal '("Starting inferior cabal-ghci process using cabal-ghci ..." "dumses3" nil "nix-shell" "default.nix" "--command" "cabal-ghci")
74+
(let ((haskell-process-path-ghci "ghci"))
75+
(custom-set-variables '(haskell-process-wrapper-function
76+
(lambda (argv) (append (list "nix-shell" "default.nix" "--command" )
77+
(list (shell-quote-argument (mapconcat 'identity argv " ")))))))
78+
(mocklet (((haskell-session-name "dummy-session3") => "dumses3"))
79+
(haskell-process-compute-process-log-and-command "dummy-session3" 'cabal-ghci))))))
80+
81+
(ert-deftest test-haskell-process--compute-process-log-and-command-cabal-dev ()
82+
(should (equal '("Starting inferior cabal-dev process cabal-dev -s directory/cabal-dev ..." "dumses4" nil "cabal-dev" "ghci" "-s" "directory/cabal-dev")
83+
(let ((haskell-process-path-cabal-dev "cabal-dev"))
84+
(custom-set-variables '(haskell-process-wrapper-function #'identity))
85+
(mocklet (((haskell-session-name "dummy-session4") => "dumses4")
86+
((haskell-session-cabal-dir "dummy-session4") => "directory"))
87+
(haskell-process-compute-process-log-and-command "dummy-session4" 'cabal-dev))))))
88+
89+
(ert-deftest test-haskell-process--with-wrapper-compute-process-log-and-command-cabal-dev ()
90+
(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")
91+
(let ((haskell-process-path-cabal-dev "cabal-dev"))
92+
(custom-set-variables '(haskell-process-wrapper-function
93+
(lambda (argv) (append (list "run-with-docker")
94+
(list (shell-quote-argument (mapconcat 'identity argv " ")))))))
95+
(mocklet (((haskell-session-name "dummy-session4") => "dumses4")
96+
((haskell-session-cabal-dir "dummy-session4") => "directory"))
97+
(haskell-process-compute-process-log-and-command "dummy-session4" 'cabal-dev))))))
98+
99+
;;; haskell-process-tests.el ends here

0 commit comments

Comments
 (0)