Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing arguments to test suites run via new-test is unsupported #4643

Closed
cocreature opened this issue Jul 29, 2017 · 13 comments
Closed

Passing arguments to test suites run via new-test is unsupported #4643

cocreature opened this issue Jul 29, 2017 · 13 comments

Comments

@cocreature
Copy link
Collaborator

Currently it is impossible to pass any arguments to a test suite that is run via new-test since they are interpreted as targets (regardless of how many -- you add in between).

There is the question of what should happen if multiple test suites are run. Personally, I would prefer if the arguments are just passed to all of them in that case but I’m also fine with an error or whatever else as long as I have the possibility to specify the test suite explicitly.

@fgaz
Copy link
Member

fgaz commented Jul 29, 2017

This probably also affects new-bench

@23Skidoo
Copy link
Member

Just bumped into this the other day. I think that none of the flags specific to old-test (TestFlags) are supported by new-test right now.

@fgaz
Copy link
Member

fgaz commented Jul 29, 2017

Apparently some are set to mempty.
See setupHsTestFlags and setupHsTestArgs in Distribution/Client/ProjectPlanning.hs

@lspitzner
Copy link
Collaborator

in the meantime..

cabal new-build TESTNAME && `find dist-newstyle/build -type f -name TESTNAME` --color --my --other --args

which probably is brittle and breaks if you build tests with and without optimizations at some point..

@hvr
Copy link
Member

hvr commented Aug 3, 2017

@lspitzner less brittle: use cabal-plan list-bin :-)

@fgaz
Copy link
Member

fgaz commented Aug 10, 2017

Continuing on #3638 (comment),

That's because @hvr's example uses (currently) incorrect syntax.

As with new-run, the full syntax seems to be:

cabal new-test --cabal-flags -- test-name other-test -- --test-flags and test args

The first -- separates cabal flags and targets, and the second one separates targets and targets' args.

This correctly parses as

["test-name","other-test","--","--test-flags","and","test","args"]

Edit: well, maybe the current syntax wasn't intended to be used like this?

@ezyang
Copy link
Contributor

ezyang commented Aug 13, 2017

Let me offer one more unsolicited suggestion: maybe cabal new-test should NOT support running multiple tests. If you want multiple tests, make a new command or something.

@hvr
Copy link
Member

hvr commented Aug 13, 2017

I somewhat sympathize with @ezyang's suggestion; it would probably make things simpler and less surprising. However, we still want the ability to say cabal new-test all or cabal new-test :pkg:cabal-install. Maybe just disallow running multiple tests and passing flags at the same time; or expressed dually: allow flags only when the target resolves to a single test program?

@phadej
Copy link
Collaborator

phadej commented Aug 13, 2017

Yes, there should be a way to run all tests (in project/package) without knowing the test-suite names.

@fgaz
Copy link
Member

fgaz commented Jan 17, 2018

Partially fixed with #4861 (new-run can now run tests/benchs and it can pass arguments).

new-test still cannot pass arguments.

@sjakobi
Copy link
Member

sjakobi commented Jul 19, 2018

I'd love to see a fix for this! I think the new-run workaround doesn't work for me because it doesn't support --allow-newer.

harpocrates added a commit that referenced this issue Nov 12, 2018
This means that old `test` flags can be passed in to `new-test`, `new-build`, `new-install`,
`new-configure`, etc. These new flags are:

    * `--test-log` (see old `--log`)
    * `--test-machine-log` (see `--machine-log`)
    * `--test-show-details` (see `--show-details`)
    * `--test-keep-tix-files` (see `--keep-tix-files`)
    * `--test-options`
    * `--test-option`

This fixes #4803, #4643, #4766, and #5416.
@l29ah
Copy link

l29ah commented Sep 30, 2022

new-test and new-bench still don't accept args via --, as seen with cabal-3.6.2.0

@ulysses4ever
Copy link
Collaborator

@l29ah unfortunately, this is correct. The corresponding issue is #6198. There's a draft PR attached to it (#7454) with a simple and straightforward design, but it's abandoned, as far as I can see. Do you want to try to pull it out? We're happy to advise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants