mirage / alcotest

A lightweight and colourful test framework
ISC License
454 stars 80 forks source link

how to run a single test? #377

Closed mimoo closed 1 year ago

mimoo commented 1 year ago

I have a test defined as such that I'm trying to call:

let circuit_tests =
  [ ( "boolean circuit"
    , `Quick
    , check_json ~input_typ:BooleanCircuit.input_typ
        ~return_typ:BooleanCircuit.return_typ ~circuit:BooleanCircuit.main
        "simple.json" )

I've been trying to pass the name as such:

ALCOTEST_COLOR=always dune test --no-buffer . -- 'boolean circuit'

but I get the following error:

Error: Don't know about directory "src/lib/crypto/snarky_tests/boolean
circuit" specified on the command line!
MisterDA commented 1 year ago

You cannot forward supplementary arguments from dune test -- args to the test executable, because there could be plenty of tests executables, and Dune wouldn't know which one you're actually trying to use (dune test runs all the tests executables). What you can do instead is write the argument in the dune file using an action stanza, or use dune exec with your test executable.

dune exec -- src/lib/crypto/snarky_tests/test.exe 'boolean circuit'

btw, using Dune 3.7.0 and Alcotest 1.7.0, you shouldn't have to specify ALCOTEST_COLOR.

mimoo commented 1 year ago

oh I see, I wish I didn't have to write the full path and .exe but this is what we have today I guess :D

MisterDA commented 1 year ago

I'm closing this, but please keep asking if you have questions. I'll probably add more documentation!

mimoo commented 1 year ago

now getting a new error

snarky_tests.exe: unknown command `updated'.
Usage: snarky_tests.exe COMMAND ...
Try `snarky_tests.exe --help' for more information.
mimoo commented 1 year ago

I'm getting "Invalid request (no tests to run, filter skipped everything)!" if I try with the additional test command:

dune exec -- src/lib/crypto/snarky_tests/test.exe test 'boolean circuit'

I'm looking at the --help but I don't see any examples of command there so perhaps I'm not using it correctly

mimoo commented 1 year ago

OK I think I understand how to use this. I have to run this command first:

dune exec -- src/lib/crypto/snarky_tests/test.exe list

and I can only use the test command to execute a group of test that matches a name (I can't seem to match a test inside a group of test)

MisterDA commented 1 year ago

I can't seem to match a test inside a group of test

Indeed, that's not possible with the current interface.