Skip to content

Subcomponent diffing - #247

Closed
craigfe wants to merge 24 commits into
mirage:mainfrom
craigfe:subcomponent-diffing
Closed

craigfe wants to merge 24 commits into
mirage:mainfrom
craigfe:subcomponent-diffing

Conversation

@craigfe

@craigfe craigfe commented May 25, 2020

Copy link
Copy Markdown
Member

Depends on #246.

WIP efforts towards a diffing output that highlights differing subcomponents:

image

For lists, arrays and strings, this works by computing the Levenshtein edit script between the expected and actual values and highlighting the affected indices in the output.

TODOs:

  • simplify highlighting logic (perhaps using some notion of Traversable types);
  • add an upper-bound for the edit distance used in highlighting the output;
  • test the behaviour of the edit distance computation in special cases (equal inputs, inputs with equal prefixes / suffixes);
  • add better test cases for highlighting choices;
  • implement for sum types;
  • provide combinators for algebraic types to benefit from the diffing mechanism; (?)
  • allow the user to supply a custom diffing strategy. (?) (would fix_ Custom diff support #194)

craigfe added 24 commits May 22, 2020 12:09
This changes the default value of the `--color` flag to `always` rather
than `auto` when the `INSIDE_DUNE` variable is set.

As discussed before (see mirage#207
and ocaml/dune#145), Alcotest output is not
coloured by default if run via `dune runtest`, since Dune's buffering
mechanism keeps the test process from having direct access to the
terminal.

We now have the `ALCOTEST_COLOR` variable for experienced users to
override this behaviour, but I suspect the better solution is to default
to _always_ showing colours, so that new users are not surprised by this
interaction. People who really don't want colours can still disable it
with the environment variable or the command-line option.

Travis CI appears to filter out any ANSII colour codes in its logs (see
https://travis-ci.org/github/mirage/irmin/jobs/686951739#L3684).
This drops support for OCaml 4.03 and 4.04.

See discussion in mirage#242 (comment).
The 'latest' symlink is less useful in projects with many different test
binaries (such as this one), since each suite runner overwrites the
symlink from the previous one.
This test causes plenty of trouble in CI, and seems to be not very
portable. The important test is that it's possible to _override_ the
default, which has been kept.
... by computing the Levenshtein edit script from the expected list to
the actual list and then using this to highlight the relevant indices.

Also implemented for arrays.
@craigfe

craigfe commented Mar 1, 2022

Copy link
Copy Markdown
Member Author

Closing as I'm not currently working on this. Hopefully it can return after #347 has been resolved.

@craigfe craigfe closed this Mar 1, 2022
tmattio added a commit to tmattio/opam-repository that referenced this pull request Feb 13, 2026
CHANGES:

Windtrap is an all-in-one OCaml testing framework that unifies unit tests, property-based tests, snapshot tests, and expect tests under a single API. Instead of juggling multiple testing libraries, Windtrap gives you one cohesive package with a PPX for inline expect tests (`windtrap.ppx`).

- Unit tests with combinators, tags, skip, brackets, and timeouts.
- Property-based testing with configurable seeds and shrinking.
- Snapshot testing with automatic file management and diffing.
- Inline expect tests via `windtrap.ppx` with automatic correction.
- CLI test runner with filtering, verbosity, and color support.
- Test coverage reporting with `bisect_ppx` integration.

### Acknowledgments

Windtrap builds on ideas and code from several OCaml projects:

- **[Alcotest](https://github.com/mirage/alcotest)** by Thomas Gazagnaire — test structure and runner design
- **Craig Ferguson's Alcotest PRs** ([invariant-hq/windtrap#294](mirage/alcotest#294), [invariant-hq/windtrap#247](mirage/alcotest#247)) — API design, subcomponent diffing, and Levenshtein distance (ISC)
- **[QCheck2](https://github.com/c-cube/qcheck)** by Simon Cruanes et al. — generator design and integrated shrinking (BSD 2-Clause)
- **[ppx_expect](https://github.com/janestreet/ppx_expect)** and **[ppx_inline_test](https://github.com/janestreet/ppx_inline_test)** by Jane Street — expect test paradigm and dune integration
- **[Bisect_ppx](https://github.com/aantron/bisect_ppx)** by Anton Bachin et al. — coverage instrumentation and runtime (MIT)
tmattio added a commit to tmattio/opam-repository that referenced this pull request Feb 15, 2026
CHANGES:

Windtrap is an all-in-one OCaml testing framework that unifies unit tests, property-based tests, snapshot tests, and expect tests under a single API. Instead of juggling multiple testing libraries, Windtrap gives you one cohesive package with a PPX for inline expect tests (`windtrap.ppx`).

- Unit tests with combinators, tags, skip, brackets, and timeouts.
- Property-based testing with configurable seeds and shrinking.
- Snapshot testing with automatic file management and diffing.
- Inline expect tests via `windtrap.ppx` with automatic correction.
- CLI test runner with filtering, verbosity, and color support.
- Test coverage reporting with `bisect_ppx` integration.

### Acknowledgments

Windtrap builds on ideas and code from several OCaml projects:

- **[Alcotest](https://github.com/mirage/alcotest)** by Thomas Gazagnaire — test structure and runner design
- **Craig Ferguson's Alcotest PRs** ([invariant-hq/windtrap#294](mirage/alcotest#294), [invariant-hq/windtrap#247](mirage/alcotest#247)) — API design, subcomponent diffing, and Levenshtein distance (ISC)
- **[QCheck2](https://github.com/c-cube/qcheck)** by Simon Cruanes et al. — generator design and integrated shrinking (BSD 2-Clause)
- **[ppx_expect](https://github.com/janestreet/ppx_expect)** and **[ppx_inline_test](https://github.com/janestreet/ppx_inline_test)** by Jane Street — expect test paradigm and dune integration
- **[Bisect_ppx](https://github.com/aantron/bisect_ppx)** by Anton Bachin et al. — coverage instrumentation and runtime (MIT)
tmattio added a commit to tmattio/opam-repository that referenced this pull request Feb 15, 2026
CHANGES:

Windtrap is an all-in-one OCaml testing framework that unifies unit tests, property-based tests, snapshot tests, and expect tests under a single API. Instead of juggling multiple testing libraries, Windtrap gives you one cohesive package with a PPX for inline expect tests (`windtrap.ppx`).

- Unit tests with combinators, tags, skip, brackets, and timeouts.
- Property-based testing with configurable seeds and shrinking.
- Snapshot testing with automatic file management and diffing.
- Inline expect tests via `windtrap.ppx` with automatic correction.
- CLI test runner with filtering, verbosity, and color support.
- Test coverage reporting with `bisect_ppx` integration.

### Acknowledgments

Windtrap builds on ideas and code from several OCaml projects:

- **[Alcotest](https://github.com/mirage/alcotest)** by Thomas Gazagnaire — test structure and runner design
- **Craig Ferguson's Alcotest PRs** ([invariant-hq/windtrap#294](mirage/alcotest#294), [invariant-hq/windtrap#247](mirage/alcotest#247)) — API design, subcomponent diffing, and Levenshtein distance (ISC)
- **[QCheck2](https://github.com/c-cube/qcheck)** by Simon Cruanes et al. — generator design and integrated shrinking (BSD 2-Clause)
- **[ppx_expect](https://github.com/janestreet/ppx_expect)** and **[ppx_inline_test](https://github.com/janestreet/ppx_inline_test)** by Jane Street — expect test paradigm and dune integration
- **[Bisect_ppx](https://github.com/aantron/bisect_ppx)** by Anton Bachin et al. — coverage instrumentation and runtime (MIT)
tmattio added a commit to tmattio/opam-repository that referenced this pull request Feb 16, 2026
CHANGES:

Windtrap is an all-in-one OCaml testing framework that unifies unit tests, property-based tests, snapshot tests, and expect tests under a single API. Instead of juggling multiple testing libraries, Windtrap gives you one cohesive package with a PPX for inline expect tests (`ppx_windtrap`).

- Unit tests with combinators, tags, skip, brackets, and timeouts.
- Property-based testing with configurable seeds and shrinking.
- Snapshot testing with automatic file management and diffing.
- Inline expect tests via `ppx_windtrap` with automatic correction.
- CLI test runner with filtering, verbosity, and color support.
- Test coverage reporting with `bisect_ppx` integration.

### Acknowledgments

Windtrap builds on ideas and code from several OCaml projects:

- **[Alcotest](https://github.com/mirage/alcotest)** by Thomas Gazagnaire — test structure and runner design
- **Craig Ferguson's Alcotest PRs** ([invariant-hq/windtrap#294](mirage/alcotest#294), [invariant-hq/windtrap#247](mirage/alcotest#247)) — API design, subcomponent diffing, and Levenshtein distance (ISC)
- **[QCheck2](https://github.com/c-cube/qcheck)** by Simon Cruanes et al. — generator design and integrated shrinking (BSD 2-Clause)
- **[ppx_expect](https://github.com/janestreet/ppx_expect)** and **[ppx_inline_test](https://github.com/janestreet/ppx_inline_test)** by Jane Street — expect test paradigm and dune integration
- **[Bisect_ppx](https://github.com/aantron/bisect_ppx)** by Anton Bachin et al. — coverage instrumentation and runtime (MIT)
tmattio added a commit to tmattio/opam-repository that referenced this pull request Feb 16, 2026
CHANGES:

Windtrap is an all-in-one OCaml testing framework that unifies unit tests, property-based tests, snapshot tests, and expect tests under a single API. Instead of juggling multiple testing libraries, Windtrap gives you one cohesive package with a PPX for inline expect tests (`ppx_windtrap`).

- Unit tests with combinators, tags, skip, brackets, and timeouts.
- Property-based testing with configurable seeds and shrinking.
- Snapshot testing with automatic file management and diffing.
- Inline expect tests via `ppx_windtrap` with automatic correction.
- CLI test runner with filtering, verbosity, and color support.
- Test coverage reporting with `bisect_ppx` integration.

### Acknowledgments

Windtrap builds on ideas and code from several OCaml projects:

- **[Alcotest](https://github.com/mirage/alcotest)** by Thomas Gazagnaire — test structure and runner design
- **Craig Ferguson's Alcotest PRs** ([invariant-hq/windtrap#294](mirage/alcotest#294), [invariant-hq/windtrap#247](mirage/alcotest#247)) — API design, subcomponent diffing, and Levenshtein distance (ISC)
- **[QCheck2](https://github.com/c-cube/qcheck)** by Simon Cruanes et al. — generator design and integrated shrinking (BSD 2-Clause)
- **[ppx_expect](https://github.com/janestreet/ppx_expect)** and **[ppx_inline_test](https://github.com/janestreet/ppx_inline_test)** by Jane Street — expect test paradigm and dune integration
- **[Bisect_ppx](https://github.com/aantron/bisect_ppx)** by Anton Bachin et al. — coverage instrumentation and runtime (MIT)
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.

1 participant