Skip to content

Add [--not-match] and [--not-file]

Arvid Jakobsson requested to merge arvid@selection-arguments into master

Description / Motivation

  • Added --not-match to deselect tests with a title that matches a regular expression.

  • Added --not-file to deselect tests with a given filename.

  • Added a warning when the argument to --not-title does not correspond to any known files.

  • Fixed a bug where the list of selectors printed with an empty test selection would not contain --not-title.

I've ended up wanting these selectors. In addition, it makes the interface more symmetric.

If you'd like, I could make a more complicated implementation under the hood, with a mini-expression language:

type selector = File of string | Tag of string | Match of rex | Not of selector

then we could eventually add boolean operators and expose a syntax to the user.

How to Test the MR Manually

$ dune exec test/unix/main.exe -- --list
+----------+-------------+----------------+
|   FILE   |    TITLE    |      TAGS      |
+----------+-------------+----------------+
| tests.ml | demo        | math, addition |
| tests.ml | fixed seed  | seed, fixed    |
| tests.ml | random seed | seed, random   |
+----------+-------------+----------------+

$ dune exec test/unix/main.exe -- --list --not-file tests.ml
No test found for filters: --not-file tests.ml

$ dune exec test/unix/main.exe -- --list --file tests.ml
+----------+-------------+----------------+
|   FILE   |    TITLE    |      TAGS      |
+----------+-------------+----------------+
| tests.ml | demo        | math, addition |
| tests.ml | fixed seed  | seed, fixed    |
| tests.ml | random seed | seed, random   |
+----------+-------------+----------------+

$ dune exec test/unix/main.exe -- --list --match fixed
+----------+------------+-------------+
|   FILE   |   TITLE    |    TAGS     |
+----------+------------+-------------+
| tests.ml | fixed seed | seed, fixed |
+----------+------------+-------------+

$ dune exec test/unix/main.exe -- --list --not-match fixed
+----------+-------------+----------------+
|   FILE   |    TITLE    |      TAGS      |
+----------+-------------+----------------+
| tests.ml | demo        | math, addition |
| tests.ml | random seed | seed, random   |
+----------+-------------+----------------+

$ dune exec test/unix/main.exe -- --list --not-title "foobar"
[07:19:28.268] [warn] Unknown --not-title: foobar
+----------+-------------+----------------+
|   FILE   |    TITLE    |      TAGS      |
+----------+-------------+----------------+
| tests.ml | demo        | math, addition |
| tests.ml | fixed seed  | seed, fixed    |
| tests.ml | random seed | seed, random   |
+----------+-------------+----------------+

Checklist

  • Update CHANGES.md. No need to document changes to documentation and tests.
  • Make sure all new values, types etc. are documented in .mli files and that the generated documentation looks ok.
  • Add tests in test/, if relevant.

Merge request reports