Skip to content
Browse files

Improving the setup for running tests on haskell projects

  • Loading branch information...
1 parent f319013 commit e363f144df8fa8a9651dd1bb42143ce472814c34 @roman committed Jul 11, 2011
Showing with 31 additions and 20 deletions.
  1. +1 −1 modules/quickfix/haskell.vim
  2. +1 −1 modules/quickrun.vim
  3. +27 −16 modules/quickrun/haskell.vim
  4. +2 −2 vimrc
View
2 modules/quickfix/haskell.vim
@@ -33,7 +33,7 @@ function! FindCabalDirectory()
endif
endfunction
-au BufEnter *.hs call FindCabalDirectory()
+au BufEnter *.hs,*.cabal call FindCabalDirectory()
" We have to call it the first time
call FindCabalDirectory()
View
2 modules/quickrun.vim
@@ -3,4 +3,4 @@ let g:quickrun_no_default_key_mappings = 1
nmap <LEADER>r <Plug>(quickrun)
-au FileType haskell source ~/.vim/modules/quickrun/haskell.vim
+au BufEnter *.hs,*.cabal source ~/.vim/modules/quickrun/haskell.vim
View
43 modules/quickrun/haskell.vim
@@ -1,18 +1,29 @@
-let g:quickrun_config['haskell/test'] = {
- \ 'exec': ['./runTestsAndCoverage.sh --plain']
- \ }
-
-" If the current directory is a test folder
-" and it holds the necessary files
-" we are going to remap <LEADER>r to
-" run the haskell/test type on QuickRun
-let s:currentDirectory = getcwd()
-let s:cabalFilePresent = filereadable(glob("*-testsuite.cabal"))
-let s:runExecPresent = filereadable("runTestsAndCoverage.sh")
-if s:currentDirectory =~# "/test$"
- \ && s:cabalFilePresent
- \ && s:runExecPresent
- " Run the haskell/test mode, and put the cursor into the buffer
- nmap <LEADER>m :QuickRun haskell/test -mode n -into 1<CR>
+" If the current directory has a testsuite cabal
+" then run the testsuite
+"
+" NOTE: This code depends on the cabalFilePresent variable
+" defined on the quickfix/haskell.vim module
+
+if exists('b:cabalFilePresent')
+
+ " If the current cabal path is with testsuite
+ " then configure the quickrun with cabal
+ if filereadable(glob(b:currentCabalPath . '/*-testsuite.cabal'))
+
+ let s:executablePath = './dist/build/testsuite/testsuite --plain -j 4'
+
+ let g:quickrun_config['haskell/test'] = {
+ \ 'exec': [s:executablePath]
+ \ }
+
+ nmap <LEADER>r :QuickRun haskell/test -mode n -into 1<CR>
+
+ " Otherwise we restore the previous behaviour
+ " for quickrun
+ else
+
+ nmap <LEADER>r <Plug>(quickrun)
+ endif
+
endif
View
4 vimrc
@@ -35,10 +35,10 @@ source ~/.vim/modules/rainbowparentheses.vim
source ~/.vim/modules/nerdtree.vim
" == Yankring module
source ~/.vim/modules/yankring.vim
-" == QuickRun module
-source ~/.vim/modules/quickrun.vim
" == QuickFix module
source ~/.vim/modules/quickfix.vim
+" == QuickRun module
+source ~/.vim/modules/quickrun.vim
" == Syntastic module
source ~/.vim/modules/syntastic.vim
" == TPP module

0 comments on commit e363f14

Please sign in to comment.
Something went wrong with that request. Please try again.