-
Notifications
You must be signed in to change notification settings - Fork 347
Proposal - Add haskell-process-wrapper-function #370
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
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
;;; haskell-process-tests.el | ||
|
||
;;; Code: | ||
|
||
(require 'ert) | ||
(require 'haskell-process) | ||
|
||
;; HACK how to install deps in haskell-mode | ||
(progn (require 'package) | ||
(package-initialize) | ||
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/")) | ||
(package-refresh-contents) | ||
(package-install 'el-mock)) | ||
|
||
(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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware this HACK here to install the el-mock dependencies...
How can we do better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably Cask would be the way to handle this robustly across the entire repo, because it has the concept of development dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, indeed.
I did not want to take it upon me to propose it (I already use it for org-trello).
So, shall I try and propose using Cask in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we go #372 (in another PR to avoid cluttering this functionality).