Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding my executable in a Cabal test suite

I'm trying to write a test suite for a cabal project which builds an executable. I'd like the tests in the suite to run that particular executable, but I don't know where to find it (because my tests might be getting run from a sandbox in some unknown location).

Cabal ought to know where my project's executable is when it calls my test suite. Is there some way for my test module/program to gather this and other similar information from Cabal, perhaps with the new detailed-1.0 testing framework?

like image 834
kini Avatar asked Oct 21 '22 06:10

kini


1 Answers

There's a "magic" module you can include in your cabal file to query the paths related to the project.

name: myproject

library

  other-modules:       
    Paths_myproject

Exported by this module (import Paths_myproject) are several FilePath values which can be used to query the various paths Cabal uses when installing the project.

Paths_myproject.getBinDir        
Paths_myproject.getDataDir       
Paths_myproject.getDataFileName  
Paths_myproject.getLibDir        
Paths_myproject.getLibexecDir    
Paths_myproject.getSysconfDir    
Paths_myproject.version
like image 51
Stephen Diehl Avatar answered Oct 22 '22 22:10

Stephen Diehl