Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the processing of test filter ranges to match the documentation #312

Merged
merged 3 commits into from
Jun 1, 2021

Conversation

craigfe
Copy link
Member

@craigfe craigfe commented May 20, 2021

The documentation of the test subcommand gives an example of an integer range using the - delimiter, when the implementation actually uses ... This regression was introduced by cb9cf43, which switched from - to .. internally.

This PR takes the most liberal approach of supporting both syntaxes (and documents them appropriately).

CC @samoht.

@craigfe
Copy link
Member Author

craigfe commented May 20, 2021

For some context, the switch from - to .. was initially proposed here in order to leave room for - to mean "negation".

I think this was a good rationale, but in the time since then we haven't ended up implementing that feature. Personally, I find - less surprising and so suggest we support that until there's a specific reason not to, but ultimately I mostly care that the docs match the implementation.

The documentation of the `test` subcommand gives an example of an
integer range using the `-` delimiter, when the implementation actually
uses `..`. This regression was introduced by
cb9cf43, which switched from `-` to
`..` internally.

This commit takes the most liberal approach of supporting both syntaxes
(and documents them appropriately).
Copy link

@Ngoguey42 Ngoguey42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +49 to +55
let rec aux f acc = function
| [] -> rev acc
| x :: l ->
let xs = f x in
(aux [@tailcall]) f (rev_append xs acc) l
in
aux f [] l

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you are passing f to aux?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just me over-optimising out of habit. ocamlopt w/o flambda doesn't do lambda lifting, so if you don't string f through the calls to aux then you need to allocate a closure to store it (which is slower).

https://godbolt.org/z/4zxvszW7c

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)

@craigfe craigfe merged commit afb9d70 into mirage:master Jun 1, 2021
craigfe added a commit to craigfe/opam-repository that referenced this pull request Oct 9, 2021
…and alcotest-lwt (1.5.0)

CHANGES:

- Make Alcotest compatible with `js_of_ocaml.3.11.0`. Users can depend on the
  new virtual `alcotest-js` Opam library to pick up the right `js_of_ocaml`
  version automatically. (mirage/alcotest#326 mirage/alcotest#328, @hhugo @smorimoto)

- Record exception backtraces during test suite runs by default. This behaviour
  can be disabled by passing `~record_backtrace:false` to `Alcotest.run`. (mirage/alcotest#317,
  @craigfe)

- Generate shorter unique identifiers for test runs (8-character alphanumeric,
  rather than a full 128-bit UUID). (mirage/alcotest#304, @craigfe)

- Change `Alcotest.{char,string}` pretty-printers to use OCaml syntax on
  assertion failures (i.e. wrap with quotes and escape control characters).
  (mirage/alcotest#318, @craigfe)

- Fix process for getting the width of attached terminals on MacOS.
  Previously, a terminal width of 80 columns was assumed. (mirage/alcotest#325, @craigfe)

- Fix parsing of test filter ranges to allow '-' separators (e.g. `test alpha
  1-4`), as advertised in the manpage. The previously-used '..' separator is
  also supported. (mirage/alcotest#312, @craigfe)

- Introduce an `Alcotest.V1` module that aliases the existing `Alcotest` API and
  provides a stability guarantee over major version changes. Similar versioned
  aliases also exist for the backends: `Alcotest_{async,lwt}.V1`. (mirage/alcotest#306,
  @craigfe)

- Change the `~filter` argument to `Alcotest.run` to be a predicate over tests.
  (mirage/alcotest#305, @craigfe)

- Renamed / removed some less frequently used modules used by the test backends:
  - `Alcotest.Unix` -> `Alcotest.Unix_platform`
  - `Alcotest_engine.{Cli,Core,Test}` -> `Alcotest_engine.V1.{Cli,Core,Test}`
  - `Alcotest.{Cli,Core}` are now gone. Use `Alcotest_engine.V1.{Cli,Core}.Make
    (Alcotest.Unix_platform)` instead.
  (mirage/alcotest#306 mirage/alcotest#309, @craigfe)

- Avoid exporting `list_tests` in the main test APIs (`Alcotest{,_lwt,_async}`).
  Use `Alcotest_engine` directly if you want this function. (mirage/alcotest#310, @craigfe)
craigfe added a commit to craigfe/opam-repository that referenced this pull request Oct 9, 2021
…and alcotest-lwt (1.5.0)

CHANGES:

- Make Alcotest compatible with `js_of_ocaml.3.11.0`. Users can depend on the
  new virtual `alcotest-js` Opam library to pick up the right `js_of_ocaml`
  version automatically. (mirage/alcotest#326 mirage/alcotest#328, @hhugo @smorimoto)

- Record exception backtraces during test suite runs by default. This behaviour
  can be disabled by passing `~record_backtrace:false` to `Alcotest.run`. (mirage/alcotest#317,
  @craigfe)

- Generate shorter unique identifiers for test runs (8-character alphanumeric,
  rather than a full 128-bit UUID). (mirage/alcotest#304, @craigfe)

- Change `Alcotest.{char,string}` pretty-printers to use OCaml syntax on
  assertion failures (i.e. wrap with quotes and escape control characters).
  (mirage/alcotest#318, @craigfe)

- Fix process for getting the width of attached terminals on MacOS.
  Previously, a terminal width of 80 columns was assumed. (mirage/alcotest#325, @craigfe)

- Fix parsing of test filter ranges to allow '-' separators (e.g. `test alpha
  1-4`), as advertised in the manpage. The previously-used '..' separator is
  also supported. (mirage/alcotest#312, @craigfe)

- Introduce an `Alcotest.V1` module that aliases the existing `Alcotest` API and
  provides a stability guarantee over major version changes. Similar versioned
  aliases also exist for the backends: `Alcotest_{async,lwt}.V1`. (mirage/alcotest#306,
  @craigfe)

- Change the `~filter` argument to `Alcotest.run` to be a predicate over tests.
  (mirage/alcotest#305, @craigfe)

- Renamed / removed some less frequently used modules used by the test backends:
  - `Alcotest.Unix` -> `Alcotest.Unix_platform`
  - `Alcotest_engine.{Cli,Core,Test}` -> `Alcotest_engine.V1.{Cli,Core,Test}`
  - `Alcotest.{Cli,Core}` are now gone. Use `Alcotest_engine.V1.{Cli,Core}.Make
    (Alcotest.Unix_platform)` instead.
  (mirage/alcotest#306 mirage/alcotest#309, @craigfe)

- Avoid exporting `list_tests` in the main test APIs (`Alcotest{,_lwt,_async}`).
  Use `Alcotest_engine` directly if you want this function. (mirage/alcotest#310, @craigfe)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants