Skip to content

Commit 6765c03

Browse files
committed
Use Cask to trigger tests (and solve dependencies)
Follow up from the discussion #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 ec7ff37 commit 6765c03

File tree

2 files changed

+108
-1
lines changed

2 files changed

+108
-1
lines changed

.gitignore

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

tests/haskell-process-tests.el

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

0 commit comments

Comments
 (0)