Skip to content

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

Closed

Description

@cocreature

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.

Activity

  1. self-assigned this
    on Jul 29, 2017
  2. added
    cabal-install: v2-build system
    on Jul 29, 2017
  3. fgaz commented on Jul 29, 2017

    @fgaz
    Member

    This probably also affects new-bench

  4. 23Skidoo commented on Jul 29, 2017

    @23Skidoo
    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.

  5. fgaz commented on Jul 29, 2017

    @fgaz
    Member

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

  6. lspitzner commented on Aug 3, 2017

    @lspitzner
    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..

  7. hvr commented on Aug 3, 2017

    @hvr
    Member

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

  8. fgaz commented on Aug 10, 2017

    @fgaz
    Member

    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?

  9. ezyang commented on Aug 13, 2017

    @ezyang
    Contributor

    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.

  10. hvr commented on Aug 13, 2017

    @hvr
    Member

    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?

  11. phadej commented on Aug 13, 2017

    @phadej
    Collaborator

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

  12. fgaz commented on Jan 17, 2018

    @fgaz
    Member

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

    new-test still cannot pass arguments.

  13. sjakobi commented on Jul 19, 2018

    @sjakobi
    Member

    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.

  14. l29ah commented on Sep 30, 2022

    @l29ah

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

  15. ulysses4ever commented on Sep 30, 2022

    @ulysses4ever
    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

Metadata

Metadata

Assignees

Labels

cabal-install: v2-build systemtype: enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions