haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.63k stars 696 forks source link

`cabal bench` suggests to add `tests: True` instead of `benchmarks: True` to cabal.project.local file #8537

Open Lev135 opened 2 years ago

Lev135 commented 2 years ago

Describe the bug Running cabal bench for project without benchmarks: True provides the following hint:

cabal-3.6.2.0.exe: Cannot benchmark the package space-consumers-0.1.0.0
because none of the components are available to build: the benchmark
'bench-foo' is not available because the solver did not find a plan that
included the benchmarks. Force the solver to enable this for all packages by
adding the line 'tests: True' to the 'cabal.project.local' file.

however, only adding benchmarks: True, but not tests: True solves this problem

To Reproduce Steps to reproduce the behavior:

Expected behavior Hint should contain correct suggestion (to add benchmarks: True)

System information

jneira commented 2 years ago

oof, good catch, thanks pr fixing it totally welcomed, it should not be too difficult but wuld be good to include a regression test for it

cbclemmer commented 2 years ago

@Lev135 I'm having trouble reproducing this because it's a solver issue and not a configuration issue. I assume the project you are working on is called space-consumers based on the output and it looks like it is having trouble finding a benchmark. Can you share your .cabal file so that I can replicate it for the regression test?

ulysses4ever commented 2 years ago

@cbclemmer very good call, thanks! I guess even without a reproducer, it should still be possible to grep through the source for this message, and see how it's used. It should be more or less clear where it's misused.

cbclemmer commented 2 years ago

@ulysses4ever It's used in this error handler. Whenever you explicitly set benchmarks: False in the config file or --disable-benchmarks as a command line arg it uses this case and that's why I can't reproduce it. I think the solver has to run into some kind of problem before it gives that message. I'm just not sure what problem it is exactly.

ulysses4ever commented 2 years ago

@cbclemmer makes sense, thank you for checking. Over to @Lev135 for a reproducer.

Lev135 commented 2 years ago

Unfortunatly, I haven't preserved the repository at that stage. Now, I also fail to reproduce a bug. I'm sure I didn't use --disable-benchmarks or benchmarks: False in the config, but cabal failed to build my benchmark with that strange error. I tried to clean up project, but this didn't lead to any result. That's all I can say about it

cbclemmer commented 2 years ago

@Lev135 No worries, the error came from some kind of configuration error in your .cabal file. Let us know if it happens again.