How to put '"alcotest" {with-test}' in an opam file generated from a dune-project file?

Handcrafted opam files may contain this:

depends: [
  "alcotest" {with-test}
  ...
]

It tells opam that the package in question (alcotest) is only a dependency if we want to run the tests (opam install --with-test ...). How can we specify the same when using a dune-project file as the source for the opam file?

$ cat dune-project
...
(generate_opam_files true)
...
(package
 ...
 (depends
   alcotest  ; <-- how to specify '{with-test}'?
   ...
 )
)

Solution:

$ cat dune-project
...
(generate_opam_files true)
...
(package
 ...
 (depends
   (alcotest :with-test)
   ...
 )
)
2 Likes