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

Allow running non-deterministic MDX stanzas using dune-gen #366

Merged
merged 6 commits into from
Jan 28, 2022
Merged

Allow running non-deterministic MDX stanzas using dune-gen #366

merged 6 commits into from
Jan 28, 2022

Conversation

Leonidas-from-XIV
Copy link
Collaborator

There is a number of ways this could be implemented, but for simplicity this just uses the same environment variable as the main executable, but to avoid dependencies it doesn't use the Cmdliner flag.

Closes #365.

CHANGES.md Outdated Show resolved Hide resolved
bin/dune_gen.ml Show resolved Hide resolved
test/bin/mdx-dune-gen/misc/non-deterministic/dune Outdated Show resolved Hide resolved
test/bin/mdx-dune-gen/misc/non-deterministic/dune Outdated Show resolved Hide resolved
test/bin/mdx-dune-gen/misc/non-deterministic/dune Outdated Show resolved Hide resolved
test/bin/mdx-dune-gen/misc/non-deterministic/dune Outdated Show resolved Hide resolved
test/bin/mdx-dune-gen/misc/non-deterministic/dune Outdated Show resolved Hide resolved
Thanks to @emillon for pointing out all the shortcut that dune allows to
avoid declaring things over and over.
This should be more portable since we don't depend on `diff` being
installed or have an exit code of 1 when the files differ.
emillon added a commit to ocaml/dune that referenced this pull request Jan 27, 2022
Since realworldocaml/mdx#366, the executable output by `ocaml-mdx
dune-gen` supports `MDX_RUN_NON_DETERMINISTIC` like `ocaml-mdx test`
itself. Dune needs to know about that to rerun the tests if the variable
has been set in the meantime.

Signed-off-by: Etienne Millon <[email protected]>
emillon added a commit to ocaml/dune that referenced this pull request Jan 27, 2022
Since realworldocaml/mdx#366, the executable output by `ocaml-mdx
dune-gen` supports `MDX_RUN_NON_DETERMINISTIC` like `ocaml-mdx test`
itself. Dune needs to know about that to rerun the tests if the variable
has been set in the meantime.

Signed-off-by: Etienne Millon <[email protected]>
Copy link
Contributor

@NathanReb NathanReb left a comment

Choose a reason for hiding this comment

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

Looks good to me!

This still needs a change on the dune side to declare the env var dependency right? At some point it would be nice to include dune stanza tests here as well so we're confident we don't break the compat with dune on those features!

@Leonidas-from-XIV
Copy link
Collaborator Author

That's a good point for the future.

Unfortunately that would require us to use a dune version that has either 0.1 support or 0.2 support (the latter is dune 3.0 which is not released yet) unless we want to do a fun thing and declare:

dune | dune {>= "3.0" & with-test}

@Leonidas-from-XIV Leonidas-from-XIV merged commit fc7132d into realworldocaml:main Jan 28, 2022
@Leonidas-from-XIV Leonidas-from-XIV deleted the dune-gen-non-deterministic branch January 28, 2022 11:10
Leonidas-from-XIV added a commit to Leonidas-from-XIV/opam-repository that referenced this pull request Jan 28, 2022
CHANGES:

#### Added

- Add support for adding language tags and metadata labels in `mli` files.
  (realworldocaml/mdx#339, realworldocaml/mdx#357, @Julow, @Leonidas-from-XIV)
- Add support for running non-deterministic tests in `dune` MDX 0.2 stanza by
  setting the `MDX_RUN_NON_DETERMINISTIC` environment variable. (realworldocaml/mdx#365,
  realworldocaml/mdx#366, @Leonidas-from-XIV)
@emillon
Copy link
Contributor

emillon commented Jan 28, 2022

Looks good to me!

This still needs a change on the dune side to declare the env var dependency right? At some point it would be nice to include dune stanza tests here as well so we're confident we don't break the compat with dune on those features!

That's done in ocaml/dune#5391. This only affects stanza 0.2 which is unreleased at the moment.

@NathanReb
Copy link
Contributor

That's a good point indeed.

On the other hand I think that it wouldn't be too bad for MDX to require the version of dune that integrates well with it. We don't really offer good support for running MDX on your own anyway.

We'd need to look into the implications more carefully but on principle, I think it could work.

@emillon
Copy link
Contributor

emillon commented Jan 28, 2022

We can also test this by doing what the stanza does by hand, ie something like that in a cram test:

$ mdx dune-gen > t.ml
$ cat > dune <<EOF
> (executable ...)
$ dune exec ...

It's an e2e test of dune-gen, not of the dune stanza, but this ensures that this contract works.

emillon added a commit to ocaml/dune that referenced this pull request Jan 31, 2022
Since realworldocaml/mdx#366, the executable output by `ocaml-mdx
dune-gen` supports `MDX_RUN_NON_DETERMINISTIC` like `ocaml-mdx test`
itself. Dune needs to know about that to rerun the tests if the variable
has been set in the meantime.

Signed-off-by: Etienne Millon <[email protected]>
emillon added a commit to ocaml/dune that referenced this pull request Feb 7, 2022
Since realworldocaml/mdx#366, the executable output by `ocaml-mdx
dune-gen` supports `MDX_RUN_NON_DETERMINISTIC` like `ocaml-mdx test`
itself. Dune needs to know about that to rerun the tests if the variable
has been set in the meantime.

Signed-off-by: Etienne Millon <[email protected]>
emillon added a commit to ocaml/dune that referenced this pull request Feb 7, 2022
Since realworldocaml/mdx#366, the executable output by `ocaml-mdx
dune-gen` supports `MDX_RUN_NON_DETERMINISTIC` like `ocaml-mdx test`
itself. Dune needs to know about that to rerun the tests if the variable
has been set in the meantime.

Signed-off-by: Etienne Millon <[email protected]>
emillon added a commit to ocaml/dune that referenced this pull request Feb 8, 2022
Since realworldocaml/mdx#366, the executable output by `ocaml-mdx
dune-gen` supports `MDX_RUN_NON_DETERMINISTIC` like `ocaml-mdx test`
itself. Dune needs to know about that to rerun the tests if the variable
has been set in the meantime.

Signed-off-by: Etienne Millon <[email protected]>
rgrinberg pushed a commit to ocaml/dune that referenced this pull request Feb 10, 2022
Since realworldocaml/mdx#366, the executable output by `ocaml-mdx
dune-gen` supports `MDX_RUN_NON_DETERMINISTIC` like `ocaml-mdx test`
itself. Dune needs to know about that to rerun the tests if the variable
has been set in the meantime.

Signed-off-by: Etienne Millon <[email protected]>
rgrinberg pushed a commit to ocaml/dune that referenced this pull request Feb 10, 2022
Since realworldocaml/mdx#366, the executable output by `ocaml-mdx
dune-gen` supports `MDX_RUN_NON_DETERMINISTIC` like `ocaml-mdx test`
itself. Dune needs to know about that to rerun the tests if the variable
has been set in the meantime.

Signed-off-by: Etienne Millon <[email protected]>
rgrinberg pushed a commit to ocaml/dune that referenced this pull request Feb 10, 2022
Since realworldocaml/mdx#366, the executable output by `ocaml-mdx
dune-gen` supports `MDX_RUN_NON_DETERMINISTIC` like `ocaml-mdx test`
itself. Dune needs to know about that to rerun the tests if the variable
has been set in the meantime.

Signed-off-by: Etienne Millon <[email protected]>
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.

dune-gen does not support non-deterministic mode
3 participants