Open philderbeast opened 1 year ago
This is much needed: I had a question like this just this week.
Option 1 (cabal list-bin
):
❯ cabal list-bin all
Error: cabal: The list-bin command is for finding a single binary at once. The
target 'all' refers to all the packages in the project which includes the test
suite 'mypkg-test-2' and the test suite 'mypkg-test'.
You'd need to grep through this, perhaps. There's a feature request to make it more structured (https://github.com/haskell/cabal/issues/8189#issuecomment-1550140401).
Option 2 (cabal-plan
):
❯ cabal-plan list-bins
mypkg:test:mypkg-test /home/artem/tmp/mypkg/dist-newstyle/build/x86_64-linux/ghc-9.2.7/mypkg-0.1.0.0/t/mypkg-test/build/mypkg-test/mypkg-test
mypkg:test:mypkg-test-2 /home/artem/tmp/mypkg/dist-newstyle/build/x86_64-linux/ghc-9.2.7/mypkg-0.1.0.0/t/mypkg-test-2/build/mypkg-test-2/mypkg-test-2
Thanks @ulysses4ever, the cabal-plan
output shows the most promise for unmangling.
This is what I did to get the list of test targets cabal-plan list-bins > plan.txt
and then with vim editing that file; :%s/ \//.*$//
followed by :g/.*:exe:.*/d
followed by :g/.*:bench:.*/d
.
To run those test targets I used cabal test $(cat plan.txt)
.
:%s/ \//.*$//
I think it's supposed to be :%s/ \/.*$//
(extra forward slash in the middle). A bash one-liner that should mimick your vim commands:
> cat plan.txt | cut -d' ' -f1 | sed '/:exe:/d' | sed '/:bench:/d'
(provided you don't have anything funny in your paths that sed
would choke on.)
Thanks @ulysses4ever for the one-liner. Yes I made a transcription error with the :%s...
regex substitution.
This is much needed
agreed! we have to hack around the lack of a list-targets
command even in this repo. for example here's a cursed oneliner that could be removed:
I'd like to resurrect the cabal list-bin all
.
I think it's absolutely vital fire normal users to get it work as expected - i.e., listing all of the binaries generated for this project.
I admit I can't appreciate how difficult or easy it would be to get this capability working.
@mouse07410 sure. I'd take inspiration from above mentioned cabal-plan.
I'd like to resurrect the
cabal list-bin all
.
Would that give us something like cabal list-bin all:exes
and cabal list-bin all:tests
?
Is there a way to list project test suites?
I'd like to write all of a project's tests (in target form) to a file, discard the long-running ones, then have cabal run only the remaining tests.
I'm able to use
cabal test all --dry-run
but this noisy. Ideally I'd like a fully qualified target form likepackage:test:name
: