Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run an individual test with Stack and Haskell Test.Framework?

I'm cloning the following repository and making one change to the stack.yaml by adding at the end:

docker:
    enable: true

To run all the tests for haskoin-core I'm using

stack test haskoin-core:test-haskoin-core

What I want to do is run just one test. If this were HSpec (which it is not) I'd be running something like:

stack test --test-arguments -m "Network.Haskoin.Network.Units"

Now what I could do is modify the file haskcoin-core/test/Main.hs and comment out all the tests I don't want to run. But ya know - there should be a simpler way to run it with just command line parameters. (Mutating the file system goes agains the whole functional grain of Haskell).

I'd also be open to running it with stack ghci somehow.

My question is: How to run an individual test with Stack and Haskell Test.Framework?

like image 240
hawkeye Avatar asked Dec 09 '17 11:12

hawkeye


1 Answers

As of mid 2019, I think stack has changed.

  1. See --help for options:

    stack test --test-arguments "--help"

  2. Do a --dry-run to see what tests will run:

    stack test --test-arguments "--dry-run"

  3. Select tests with --match. Note, this alleges glob patterns will work but they don't seem to for me:

    stack test --test-arguments "--match=foobar"

AFAICT, "foobar" is interpreted like a glob of *foobar*, but I can't be explicit about it.

like image 80
Josh.F Avatar answered Sep 24 '22 13:09

Josh.F