Skip to content

Fix logic for running cabal directly. #1306

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

Merged
merged 2 commits into from
May 3, 2016
Merged
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
8 changes: 5 additions & 3 deletions haskell-load.el
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,12 @@ list of modules where missed IDENT was found."

(defun haskell-process-do-cabal (command)
"Run a Cabal command."
(let ((process (haskell-interactive-process)))
(let ((process (ignore-errors
(haskell-interactive-process))))
(cond
((let ((child (haskell-process-process process)))
(not (equal 'run (process-status child))))
((or (eq process nil)
(let ((child (haskell-process-process process)))
(not (equal 'run (process-status child)))))
(message "Process is not running, so running directly.")
(shell-command (concat "cabal " command)
(get-buffer-create "*haskell-process-log*")
Expand Down
12 changes: 12 additions & 0 deletions tests/haskell-load-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

;;; Code:

(require 'cl)
(require 'ert)
(require 'haskell-test-utils)

Expand Down Expand Up @@ -83,3 +84,14 @@
(search-forward "import Data.String")
(haskell-goto-prev-error)
(should (looking-at-p "Data.Mayb"))))

(ert-deftest do-cabal-no-process ()
"Ensure that haskell-process-do-cabal can call cabal directly.

Redefine `shell-command' to just capture the command it's asked
to execute, and make sure it matches what we expected."
(let (shell-call)
(flet ((shell-command (command &optional input-buffer output-buffer)
(setq shell-call command)))
(haskell-process-do-cabal "help")
(should (equal shell-call "cabal help")))))