Skip to content

Commit

Permalink
Misc: vendor patched/working ppx_expect.v0.14.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Sep 20, 2021
1 parent ab869a1 commit d205521
Show file tree
Hide file tree
Showing 68 changed files with 4,647 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vendor/ppx_expect/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_build
*.install
*.merlin
_opam

142 changes: 142 additions & 0 deletions vendor/ppx_expect/CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
## git version


- Make sure the code we generate can be typed without warning when `-principal`
is passed to the compiler.

## v0.14.1

- Update to be compatible with ppxlib 0.18.0

## v0.11

- Change `ppx_expect` so that when `-diff-cmd -` is passed, they write the
.corrected file but don't diff it or exit with a non-zero exit code.

This is to make expect tests work with jbuilder. Jbuilder uses a separate
build tree, so the current behavior of `ppx_expect` doesn't work well with
jbuilder, especially the in-place behavior.

What is done instead in jbuilder is that after running the test runner, it
checks whether a .corrected file was created. If yes, jbuilder does the
diffing itself, and by default also replaces the source file by the
correction.'

- Regexp and glob matching in the output is now deprecated. This gets in the
way of the "promote" workflow.
People are instead encouraged to prefilter the output before displaying it.

- Tell the build system via output metadata whether a file contains
tests or not

- Depend on ppxlib instead of (now deprecated) ppx\_core, ppx\_driver,
ppx\_metaquot, ppx\_traverse and ppx\_type\_conv.

## v0.10

- In `[%expect]` expressions, disallowed backtraces, which can vary across
compilation configurations (X_LIBRARY_INLINING, flambda, etc.)

- Improved `ppx_expect` to support simultaneous runs of `inline_tests_runner` on
the same file.

- Added expect-test support for reaching a single `[%expect]` multiple times,
where the test only fails if the output was distinct

- For expect tests, relaxed the rule for `%expects` that are reached multiple
times. Instead of requiring all outputs to be identical, require only that
each output individually match the `%expect`.

- In synchronous expect tests, `[%expect]` now captures stderr in addition to
stdout. Previously, there was code that did this for Async expect tests. Now,
stderr is captured in all expect tests.

- Improved expect tests to get the current file when the test runs, rather than
when it is registered.

## v0.9

## 113.43.00

- Always flush Pervasives.stdout in the ppx_expect runtime.

We already do this, but it was missing in one place.

- Made the test framework resilient to user changing the current working directory during the test.

- Print newlines in `"`-strings as real newlines, not `\n`

- The expect test runtime breaks any executable that wants to work even if
cwd doesn't exist, like fe does. Fix that.

It also brings expect tests in line with what ppx\_inline\_test does, and removes the diff
due to absolute paths I was seeing in the output of `./inline_tests_runner -log` in some
other features. Concretely, here is what changes:

- Use the new context-free API

- Change the check in ppx\_expect to be a dynamic check. Instead of
checking that expect tests appears only at toplevel, we test that
they are run in the library they appear.

This has several consquence:

- ppx\_expect can use `Context_free` as well and doesn't require two extra passes
- expect tests can appear inside let%test_module

## 113.33.01

- Add dependency on `re.emacs`

## 113.33.00

- Don't remove trailing semicolons when producing a correction.

- Corrected `%expect`s with double quoted strings don't have the single space padding.

- In the ppx\_expect runtime, flush stdout before redirecting it
This is to avoid capturing leftover of the stdout buffer.

- Make sure the expect-test runtime doesn't generate
`%collector_never_triggered`, which is not accepted by ppx\_expect.
Instead generate:

`%expect {| DID NOT REACH THIS PROGRAM POINT |}`

- Make expect tests pass the user description to the inline test runtime

- Fix a race condition in the ppx\_expect runtime


- Change ppx\_expect be more permissive when matching whitespace in actual output.
See `ppx/ppx_expect/README.org` for details.

Changes to the implementation of ppx\_expect (including some refactoring):
- factorized the common bits between the runtime and ppx rewriter
into one library expect_test_common
- factorized different structures representing the same thing using polymorphism
- communicate data structures between the ppx rewriter and runtime
using a generated lifter instead of hand-written lifters
- splitted the matching and correction writing code: the .corrected is
now only created when needed instead of all the time
- added a concrete syntax tree to represent both the actual output and
expectation in non-exact mode.
This allow to keep the user formatting as much as possible
- made various bits more re-usable

- Change the default style of multi-line expectation to:

`%expect {|
abc
def |}`

More generally, try to preserve the formatting a bit more when
correcting from empty or single to multi-line.

- Arrange things so that when `open Async.Std` is opened, `%expect ...`
expressions are of type `unit Deferred.t` and flush stdout before
capturing the output.

## 113.24.00

Initial release.
67 changes: 67 additions & 0 deletions vendor/ppx_expect/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
This repository contains open source software that is developed and
maintained by [Jane Street][js].

Contributions to this project are welcome and should be submitted via
GitHub pull requests.

Signing contributions
---------------------

We require that you sign your contributions. Your signature certifies
that you wrote the patch or otherwise have the right to pass it on as
an open-source patch. The rules are pretty simple: if you can certify
the below (from [developercertificate.org][dco]):

```
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
```

Then you just add a line to every git commit message:

```
Signed-off-by: Joe Smith <[email protected]>
```

Use your real name (sorry, no pseudonyms or anonymous contributions.)

If you set your `user.name` and `user.email` git configs, you can sign
your commit automatically with git commit -s.

[dco]: http://developercertificate.org/
[js]: https://opensource.janestreet.com/
21 changes: 21 additions & 0 deletions vendor/ppx_expect/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2015--2020 Jane Street Group, LLC <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
17 changes: 17 additions & 0 deletions vendor/ppx_expect/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
INSTALL_ARGS := $(if $(PREFIX),--prefix $(PREFIX),)

default:
dune build

install:
dune install $(INSTALL_ARGS)

uninstall:
dune uninstall $(INSTALL_ARGS)

reinstall: uninstall install

clean:
dune clean

.PHONY: default install uninstall reinstall clean
Loading

3 comments on commit d205521

@Lupus
Copy link

@Lupus Lupus commented on d205521 Sep 23, 2021

Choose a reason for hiding this comment

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

Are there any plans to support these changes in upstream ppx_expect? Would be awesome to rely on ppx_expect for codebases targeting both native and js_of_ocaml compilations. Might be related to janestreet/ppx_expect#15.

@hhugo
Copy link
Member Author

@hhugo hhugo commented on d205521 Sep 23, 2021

Choose a reason for hiding this comment

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

ppx_expect already work on both native and js. The changes here are only related to support on windows janestreet/ppx_expect#34

@Lupus
Copy link

@Lupus Lupus commented on d205521 Sep 23, 2021

Choose a reason for hiding this comment

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

Ah, perfect! Thanks!

Please sign in to comment.