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

ortac-dune plugin #190

Merged
merged 5 commits into from
Feb 9, 2024
Merged

ortac-dune plugin #190

merged 5 commits into from
Feb 9, 2024

Conversation

n-osborne
Copy link
Collaborator

Plugin to generate dune rules for other plugins.

@n-osborne
Copy link
Collaborator Author

Still in draft as the plugin does not load...

@n-osborne n-osborne force-pushed the ortac-dune branch 2 times, most recently from ae8ba40 to cdd2a7c Compare December 18, 2023 09:10
@n-osborne n-osborne marked this pull request as ready for review December 18, 2023 09:14
@n-osborne n-osborne requested a review from shym December 18, 2023 09:14
@n-osborne
Copy link
Collaborator Author

n-osborne commented Dec 18, 2023

I've put a no-changelog-needed label as this is a new not-yet-released-plugin.

Copy link
Contributor

@shym shym left a comment

Choose a reason for hiding this comment

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

Thank you for that!
A few remarks:

  • I think I would find it nicer for ortac dune qcheck-stm to expect the same command-line arguments as ortac qcheck-stm plus the necessary addition for the generation of rules; in particular, that would mean expect --include=... instead of a positional argument. Would it be possible to share the code creating those arguments, maybe?
  • I’d prefer not to see commented rules in plugins/dune-rules/src/dune.
  • The plugin generates a rule calling ortac_dune: I imagine it should be ortac dune?

@n-osborne
Copy link
Collaborator Author

Thanks for these remarks.
1 and 2 are just relics from the past, I'll remove them.
I also agree with 3. I was wondering about a better user interface (there are a lot of arguments to give).
The --include=... is easy to share and use in this plugin, and it makes a lot of sense.
I am wondering about the output files, because we have two of them: the output_file option to give ortac qcheck-stm and the one to write the dune rules in.
On the one hand, it doesn't make a lot of sense (I think) to have dune rules without an output file for the generated OCaml code: we want to be able to run the generated tests.
On the other hand, it is easy to have to optional argument for output files: the --output=... from ortac-core for the generated OCaml code and something like --dune-output=... for the generated rules.

@n-osborne
Copy link
Collaborator Author

n-osborne commented Dec 19, 2023

I'm also thinking about making the package argument optional.

@shym
Copy link
Contributor

shym commented Dec 19, 2023

Good point, I was thinking about ortac qcheck-stm optional arguments which should stay optional, but not about the ones that should be required 😅

@shym
Copy link
Contributor

shym commented Dec 19, 2023

Do you know whether it would be possible to make an interface such as:

ortac dune -o dune.inc qcheck-stm -o ...

with cmdliner?

@n-osborne
Copy link
Collaborator Author

I'm guessing it is not.
Here qcheck-stm is a subcommand of (the ortac's subcommand) dune. So it is build with Cmd.group which takes a Cmd.t list, but no argument terms.

@n-osborne n-osborne force-pushed the ortac-dune branch 2 times, most recently from 757fd83 to 026b294 Compare December 21, 2023 08:50
@n-osborne n-osborne force-pushed the ortac-dune branch 2 times, most recently from 784eeb0 to 7a0a1fb Compare January 3, 2024 15:07
@n-osborne
Copy link
Collaborator Author

I've renamed the --output option to --with-stdout-to to make it clearer and avoid confusion with the --output option of ortac qcheck-stm.

@n-osborne n-osborne requested a review from shym January 8, 2024 15:57
@n-osborne
Copy link
Collaborator Author

I should get rid of the ugly empty line generated where an optional argument is absent (see line 25 of the cram test).

n-osborne added a commit to n-osborne/ortac that referenced this pull request Jan 15, 2024
This feature will be usefull to test the dune plugin (ocaml-gospel#190) in CI.
n-osborne added a commit to n-osborne/ortac that referenced this pull request Jan 15, 2024
This feature will be usefull to test the dune plugin (ocaml-gospel#190) in CI.
n-osborne added a commit to n-osborne/ortac that referenced this pull request Jan 16, 2024
This feature will be usefull to test the dune plugin (ocaml-gospel#190) in CI.
@n-osborne n-osborne force-pushed the ortac-dune branch 5 times, most recently from f74c85a to 3d5ff2d Compare January 16, 2024 10:52
@n-osborne n-osborne force-pushed the ortac-dune branch 4 times, most recently from 676dfa8 to 892097a Compare January 16, 2024 14:22
Copy link
Contributor

@shym shym left a comment

Choose a reason for hiding this comment

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

The code that generates the dune rules is a pleasure to read, congratulations!

I have 2 main remarks:

  • The rule that will run ortac qcheck-stm on some .mli file must depend on that file (this dependency is currently missing in the generated rule). On the other hand, it doesn’t need to depend on the included file, I think: the generated test will only expect the module to be available, doesn’t it?
  • varray_circular_incl.ml and varray_incl.ml are so similar (I resorted to diff-ing them, to be honest) that I would have used a functor, even if they are so short.

and a couple of small ones attached to their positions.

The mechanism of including a module in the generated code will be common
to several plugins.
@n-osborne n-osborne force-pushed the ortac-dune branch 5 times, most recently from adac234 to 85a9f0e Compare February 2, 2024 09:06
@n-osborne
Copy link
Collaborator Author

Thanks for the review!

I think I've cover all of your remarks but one: the use of a functor.
I totally agree that having to file that just differ by a module that is opened in them is not ideal.
That being said, using a functor will bring some complexity to the dune rules:

  • declaring the functor as a library
  • the included file will depend on the new library containing the functor, this implies some change in the dependencies of the generated tests (trickier as these are generated and not all included files are a functor instantiation)

I'd propose to postpone this feature (easy support of included files for testing functor instantiation) in order to have a clean way of dealing with them.

Also, putting the body of the current included file in a functor, abstracting over the opened file does not work out of the box: I still have an error on the type extension that I don't manage to fix for now:

File "examples/make_varray_incl.ml", line 24, characters 2-39:
24 |   type _ ty += Elt : 'a ty -> 'a elt ty
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: In this definition, a type variable cannot be deduced
       from the type parameters.

@n-osborne n-osborne added this to the 0.2 milestone Feb 6, 2024
@n-osborne n-osborne requested a review from shym February 7, 2024 15:03
Copy link
Contributor

@shym shym left a comment

Choose a reason for hiding this comment

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

I’m sorry I sent you on a wild goose chase :-/
Anyway, it looks good to me now, thanks!

This commit only propose the `qcheck-stm` sub-command as this is the
only plugin release at the moment.
@shym shym merged commit 72628e5 into ocaml-gospel:main Feb 9, 2024
3 checks passed
@shym
Copy link
Contributor

shym commented Feb 9, 2024

Thank you for the fix. CI is happy so I merge it.

@n-osborne n-osborne deleted the ortac-dune branch February 14, 2024 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants