patch: --enable-tests and --only-dependencies

Thomas Tuegel ttuegel at gmail.com
Fri Feb 3 04:36:24 CET 2012


On Thu, Feb 2, 2012 at 6:50 PM, Antoine Latter <aslatter at gmail.com> wrote:
> On Thu, Feb 2, 2012 at 5:39 PM, Johan Tibell <johan.tibell at gmail.com> wrote:
>>
>> If I do
>>
>>     cabal install --enable-tests --only-dependencies
>>
>> with your patch I wil install test-suite dependencies of the current package
>> (as in the current directory) only right? That seems like the intended
>> effect. cabal configure --enable-tests is not affected, right?
>>
>
> Yes, that still happens.
>
> My change should be down-stream of the dependency solver, so it still
> does whatever it did.
>
> The difference is that now when we call 'configure' on each candidate
> package, we never pass '--enable-tests' during the 'install' command.
>
> This leads to 'cabal install $pkg --enable-tests' installing test
> dependencies but then not building the test suite for the target
> package - this is weird, but I'm not sure what we would do with the
> test suite after we built it.

It seems weird, but I think it's sensible behavior (at least
until/unless we implement an auto-run-tests feature). You patch looks
good to me.

> If we had a 'auto run test suites on install' feature, we would need
> some way to only tweak the config flags of the non-target packages.
> But I didn't do that.

Just thinking out loud about this a little:

Luckily, I think there is relatively little demand for such a feature.
Implementing it would involve unraveling the mess we get from passing
config flags around. cabal-install automatically propagates any config
flags down to all the targets (which your patch correctly disables for
--enable-tests), but that happens _after_ dependency resolution, so we
have to manually add --enable-tests to target packages before
resolution. This is why we don't respect --enable-tests for named
packages right now: there's no way to specify the flag during the
dependency stage unless we have access to the package description. The
way to handle tests for named packages would be to add a
PackageConstraint for tests the way is already done for flags, but
this is a lot more work because it would require getting deep into the
dependency solver. However, it would make it easy to set the config
flags during build for explicit targets so we could implement a test
auto-run feature.

Anyway, the patch looks good. Thanks for taking care of that!

-- 
Thomas Tuegel



More information about the cabal-devel mailing list