haskell / cabal

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

Bad escaping of --test-options #6248

Open sjakobi opened 4 years ago

sjakobi commented 4 years ago

dhall has a tasty test-suite which I would like to execute with the arguments -p /type-inference\/failure/.

The arguments that cabal ends up passing to the tasty executable are -p ''\''/type-inference\/failure/'\''':

$ cabal test dhall:tasty --test-options "-p '/type-inference\/failure/'" -v
...
Test suite tasty: RUNNING...
/home/simon/src/dhall-haskell/dist-newstyle/build/x86_64-linux/ghc-8.6.5/dhall-1.26.0/t/tasty/noopt/build/tasty/tasty -p ''\''/type-inference\/failure/'\'''
option -p: Could not parse pattern
UnkindPartition commented 4 years ago

Normally '' would be interpreted and stripped by the shell. It looks like cabal is not doing that (i.e. it tries to pass the single quotes verbatim to the test suite). That's not necessarily a bug, though it would be nice if the precise semantics of --test-options was documented somewhere (is it?).

In this particular case I think you can simply drop the single quotes, as the outer double quotes would prevent the shell from interpreting the \/, but if the agument contained a white space, I wouldn't know how to pass it.

sjakobi commented 4 years ago

In this particular case I think you can simply drop the single quotes, as the outer double quotes would prevent the shell from interpreting the \/

Yes! --test-options "-p /type-inference\/failure/" works. How had I not tried this before?!

ulysses4ever commented 2 years ago

I wonder if #8093 improved/resolves this.

Mikolaj commented 2 years ago

Or breaks. Let's add the example above as a test for https://github.com/haskell/cabal/pull/8093.