Skip to content
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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ ELFILES = \
haskell-collapse.el \
haskell-modules.el \
haskell-sandbox.el \
haskell-cabal.el \
haskell-commands.el \
haskell-compat.el \
haskell-compile.el \
Expand Down
14 changes: 9 additions & 5 deletions haskell-cabal.el
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,18 @@ OTHER-WINDOW use `find-file-other-window'."
(with-temp-buffer
(insert-file-contents cabal-file)
(haskell-cabal-mode)
(let (matches)
(goto-char (point-min))
(goto-char (point-min))
(let ((matches)
(projectName (haskell-cabal-get-setting "name")))
(haskell-cabal-next-section)
(while (not (eobp))
(if (haskell-cabal-source-section-p (haskell-cabal-section))
(let ((val (haskell-cabal-section-value (haskell-cabal-section))))
(if (string= val "")
(push "library" matches)
(let ((val (car (split-string
(haskell-cabal-section-value (haskell-cabal-section))))))
(if (or (string= val "")
(string= val "{")
(not val))
(push projectName matches)
(push val matches))))
(haskell-cabal-next-section))
(reverse matches))))))
Expand Down
21 changes: 21 additions & 0 deletions tests/haskell-cabal-tests.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
;;; haskell-cabal-tests.el
;;; Code:

(require 'ert)
(require 'haskell-cabal)

(ert-deftest haskell-cabal-enum-targets-1 ()
"Test enumerating .cabal targets."
(with-temp-buffer
(haskell-cabal-mode)
(let ((scriptDir
(file-name-directory
(or (symbol-file 'haskell-cabal-enum-targets-1)
(buffer-file-name)))))
(setq default-directory (expand-file-name "test-data" scriptDir)))
(should (equal '("Test" "test-1" "bench-1" "bin-1")
(haskell-cabal-enum-targets)))))

(provide 'haskell-cabal-tests)

;;; haskell-cabal-tests.el ends here
74 changes: 74 additions & 0 deletions tests/test-data/Test.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Name: Test
Version: 2999.18.0.1
Stability: Beta
Synopsis: Testing haskell-mode
Description: {
This is test .cabal file
}

Build-Type: Simple
Tested-With: GHC == 7.10.2
Cabal-Version: >= 1.14
Extra-Source-Files: TODO.md
Changelog.md
README.md
FAQ.md
utils/AttributeGenerator.hs

Source-Repository head
Type: git
Location: git://github.com/haskell-mode

Flag some-flag
Description: This is a flag
Default: False

Library
Default-Language: Haskell2010

Build-Depends: base == 4.*,
containers,
process,
directory,
Exposed-Modules: Some.Module
Other-Modules: Some.Other.Module
Ghc-Options: -Wall


Test-Suite test-1 {
Default-Language: Haskell2010
Type: exitcode-stdio-1.0
Build-Depends: base,
containers,
fgl,
fgl-arbitrary == 0.2.*,
filepath,
text,
QuickCheck >= 2.3 && < 2.9
hs-Source-Dirs: tests
Main-Is: RunTests.hs
Other-Modules: Some.Module
Ghc-Options: -O -Wall
}

Benchmark bench-1 {
Default-Language: Haskell2010
Type: exitcode-stdio-1.0
Build-Depends: base,
deepseq,
text,
criterion >= 0.5 && < 1.2
hs-Source-Dirs: utils
Main-Is: Benchmark.hs
}

Executable bin-1
Default-Language: Haskell2010
hs-Source-Dirs: utils
Main-Is: TestParsing.hs
Build-Depends: base,
bytestring,
directory,
filepath,
text
Ghc-Options: -O -Wall