A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/haskell/haskell-mode/wiki/Writing-tests below:

Writing tests · haskell/haskell-mode Wiki · GitHub

Tests for haskell-mode reside in tests directory and are divided roughly according to functionality. To run the test suite use the command:

or

make check EMACS=/path/to/your/emacs

As test framework we use Emacs Lisp Regression Testing. A test roughly looks like this:

(ert-deftest haskell-test ()
  (should (equal .. ..))
  (should (not (equal .. ..))
  ...)

To document that a functionality has a known issue waiting for a bugfix use tests that are expected to fail:

(ert-deftest haskell-test ()
  :expected-result :failed
  (should (equal .. ..))
  (should (not (equal .. ..))
  ...)

Notes about tests cases:

Mocking and non-pure functionality

To test functionality that touches filesystem we use el-mock.el to mock all the necessary details.

Example:

(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))))))

Note the usage of mocklet in the above snippet.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4