12

Waiting for a large test suite to run is painful, so I collect the duration of each test from cargo test and use a simple heuristic to find failures fast (I order by probability of failure/last run duration and run tests in that order).

This is great, but it doesn't have a way of knowing about new tests. If I could list all tests, I could detect new tests and add them to the high risk group that gets run first.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Max Murphy
  • 1,701
  • 1
  • 19
  • 29

1 Answers1

22

You can run cargo test -- --list to list all tests and benchmarks. The output format is:

glonk: benchmark
hurz: test

1 test, 1 benchmark

You can suppress the summary line by passing the --format=terse flag.

Note that --list is a command line flag that is passed to the test binary itself, and not a Cargo flag. You can get a full list of flags accepted by the test binary using cargo test -- --help.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Sven Marnach
  • 574,206
  • 118
  • 941
  • 841
  • Thank you. I also looked at the `--format json` option; that is unstable and doesn't work. Hopefully it will, but that is not a big problem. The text format is easy to parse and has all the data I need. :-) – Max Murphy Nov 20 '20 at 00:53
  • Here is the updated script: https://gist.github.com/bitdivine/b785e6062d6fbf1becc69b78b8f6351f – Max Murphy Nov 20 '20 at 01:35