haskell / haskell/cabal

How can we enable-tests for single target component in runhaskell Setup.hs build

Open
#9,721 1 comment 0 reactions 0 assignees View on GitHub
type: user-question
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**What is your question?**

My question is about a difference in behavior between single target components and non targeted or multi-targeted Simple cabal builds. This comes from an experiment I ran for getting component based builds support in stack.
Assuming a package named foo with a cabal file with 2 components, one main library and one test suite called bar.
If you do this :
```
runhaskell Setup.hs build --enable-tests
```
You'll have a .conf file automatically created in you build dir at some directory called package.conf.inplace.
Now, switching to a single target component, you can't use the enable-tests flag.
And so, if you try to build the main library :
```
runhaskell Setup.hs build lib:foo
```
You will not have a .conf file created and you can't ask cabal to create this file.
I found the way to explicitly register the library into a file manually, but I found this behavior puzzling hence this issue.

I believe I've found the relevant code [here](https://github.com/haskell/cabal/blob/3d3622fc3207932eb21950baac434996165191aa/Cabal/src/Distribution/Simple/Build.hs#L438), with this awkward comment, giving me a reason for this behavior that I don't understand.

So, my question is simple : why this behavior ? How am I supposed to have this .conf file if I want to stay as close to the unqualified build as possible ?
I'd be happy to submit an MR to clarify the comment in the code and perhaps to document this behavior in the cabal documentation under the setup.hs build section.

I suppose the intuitive behavior for me would have been to give an explicit flag for this behavior on library builds...

**Additional context**

Note that I haven't found any rationale for this behavior either in https://github.com/ezyang/ghc-proposals/blob/master/proposals/0000-componentized-cabal.rst.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.