cabal - "Could not find module ‘Test.HUnit’" Error when executing Haskell's unittest (HUnit) in CodeRunner -
i have simple unit test code haskell's hunit. use mac os x 10.10, , installed hunit cabal install hunit
.
module testsafeprelude import safeprelude( safehead ) import test.hunit testsafeheadforemptylist :: test testsafeheadforemptylist = testcase $ assertequal "should return nothing empty list" nothing (safehead ([]::[int])) testsafeheadfornonemptylist :: test testsafeheadfornonemptylist = testcase $ assertequal "should return (just head) non empty list" (just 1) (safehead ([1]::[int])) main :: io counts main = runtesttt $ testlist [testsafeheadforemptylist, testsafeheadfornonemptylist]
i can execute runhaskell testsafeprelude.hs
results:
cases: 2 tried: 2 errors: 0 failures: 0 counts {cases = 2, tried = 2, errors = 0, failures = 0}
however, when run in code runner, have error message can't find hunit module.
coderunner launches test on different shell environment, , seems issue. if so, environment variables need added? if not, might causing problem?
i find ghc-pkg list
coderunner not search directories in ~/.ghc
contains hunit.
/usr/local/cellar/ghc/7.8.3/lib/ghc-7.8.3/package.conf.d: cabal-1.18.1.4 array-0.5.0.0 ... xhtml-3000.2.1
this results when executed in shell:
/usr/local/cellar/ghc/7.8.3/lib/ghc-7.8.3/package.conf.d cabal-1.18.1.4 array-0.5.0.0 ... /users/smcho/.ghc/x86_64-darwin-7.8.3/package.conf.d ... hunit-1.2.5.2 ... zlib-0.5.4.2
i added both ~/.cabal
, ~/.ghc
in path, doesn't work.
the problem $home
setup change. used different $home coderunner, haskell searches $home/.cabal , $home/.ghc installed package.
after resetting $home correct location, works fine.
Comments
Post a Comment