I'm writing unit tests using rackunit
and running them using raco
through the command raco test .
, which recursively finds all racket files and executes them, including files that do not contain unit tests at all. It just runs everything.
According to what I investigated, the idiomatic way to write unit tests in racket is to write a test module inside the implementation file, and not have a separate file for them. The problem is that I have multiple different implementations of the same specification that share the same unit tests, so I need to import all the implementations in a separate file and run the unit tests there.
So I end up with just a few unit test files, and a lot of racket files that do not contain unit tests, but raco test
ends up scanning everything anyway.
I'm looking for a way to use raco test
to only run files that have a specific pattern in the name. Like *.test.rkt
, *.spec.rkt
, test-*.rkt
, or similar (like in jest
for js or pytest
for python).
Is this possible?
I looked into test-include-paths
in info.rkt
files, but it seems to be for files that are not racket files, and not for whitelisting which files to run.
CodePudding user response:
If you're using bash
, zsh
, or ksh93
as your shell, you can use a recursive glob to find all the matching files:
raco test **/*.test.rkt
(bash
might need a shopt -s globstar
first)
or any Unix-y system:
find . -name "*.test.rkt" -exec raco test \{\}