Skip to content

Commit

Permalink
Record flags for test component
Browse files Browse the repository at this point in the history
At least one build system
[Haskell.nix](https://github.com/input-output-hk/haskell.nix) builds Haskell
projects a component at a time.  This breaks cabal-doctest's expected usage of
getting configuration from the Cabal components for libraries and executables
under test.

By recording flags for the test component, we introduce another possible usage
where all information we need comes from the test component alone.

See issue ulidtko#57 for more discussion and details.
  • Loading branch information
shajra committed Dec 30, 2019
1 parent b494b38 commit 073a571
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Empty file added cabal.project.local
Empty file.
14 changes: 7 additions & 7 deletions src/Distribution/Extra/Doctest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,7 @@ generateBuildModule testSuiteName flags pkg lbi = do

additionalDirs <- mapM (fmap ("-i" ++) . makeAbsolute) additionalDirs'

-- Next, for each component (library or executable), we get to Build_doctests
-- the sets of flags needed to run doctest on that component.
let getBuildDoctests withCompLBI mbCompName compExposedModules compMainIs compBuildInfo =
withCompLBI pkg lbi $ \comp compCfg -> do
let recordComponent mbCompName compExposedModules compMainIs compBuildInfo comp compCfg = do
let compBI = compBuildInfo comp

-- modules
Expand Down Expand Up @@ -369,9 +366,12 @@ generateBuildModule testSuiteName flags pkg lbi = do
-- modify IORef, append component
modifyIORef componentsRef (\cs -> cs ++ [component])

-- For now, we only check for doctests in libraries and executables.
getBuildDoctests withLibLBI mbLibraryName exposedModules (const Nothing) libBuildInfo
getBuildDoctests withExeLBI (NameExe . executableName) (const []) (Just . modulePath) buildInfo
-- record Build_doctests flags for test component
recordComponent (const $ NameExe testSuiteName) (const []) (const Nothing) testBuildInfo suite suitecfg
-- record Build_doctests flags for library component
withLibLBI pkg lbi $ recordComponent mbLibraryName exposedModules (const Nothing) libBuildInfo
-- record Build_doctests flags for executable component
withExeLBI pkg lbi $ recordComponent (NameExe . executableName) (const []) (Just . modulePath) buildInfo

components <- readIORef componentsRef
F.for_ components $ \(Component cmpName cmpPkgs cmpFlags cmpSources) -> do
Expand Down

0 comments on commit 073a571

Please sign in to comment.