Asserting outputs of vernacular commands and tactics#107
Asserting outputs of vernacular commands and tactics#107radrow wants to merge 5 commits intorocq-prover:masterfrom
Conversation
|
This will act similarly to ppx expect for OCaml I suppose? https://github.com/janestreet/ppx_expect |
Co-authored-by: Gaëtan Gilbert <gaetan.gilbert@skyskimmer.net>
Pretty much. That looks like a good source of further ideas. |
|
I like this proposal. I prefer Assert Output rather than With Output, or #[expected(output="...")]. |
|
I think the proposal can also be very useful to write tutorials. I have two improvements to suggest:
|
I'd also prefer the output to go after the command, but I can't come up with nice syntax for it (e.g. so that the desired output doesn't look like a parameter to the command and especially isn't confused with optional parameters). Maybe the command could be wrapped with some tokens, but that might look weird as afaik no existing commands use such syntax. You can throw ideas if you have any |
|
Maybe we could separate into 2 commands, looking like Capture Output Check foo.
Assert Output "foo : nat".The original issue had Check foo.
Output "foo : nat".ie implicit capture with the assert applying to the previous command, but this wouldn't work well with eg proof general inserting arbitrary commands for itself between the user's commands. With explicit capture we can insert non-captured commands without issue: Capture Output Check foo.
Check bar.
Assert Output "foo : nat".we can also combine outputs: Capture Output Check foo.
Capture Output Check bar.
Assert Output "
foo : nat
bar : bool
".To prevent forgetting outputs, if there is a Capture Output but no Assert Output before the end of the file compilation fails (like with leaving open proofs). We could also fail if there is no Assert Output before a End (not sure if desired).
I don't think we want to be able to call unix commands from Rocq code (security issues, not portable...). We could also have a way to call Rocq code on the output string (ie expose it as a primitive string) somehow. |
|
I like the |
|
That's a great idea, I really like the ability to combine two outputs. To that I would also add
Also a fun trick: if you want to assert output without flushing it, you can do This could be later extended to more advanced output caching with assignable buffers that can be managed more precisely (dumping to files, combining, whatever). |
|
Note that |
Render: https://github.com/radrow/rfcs/blob/vernact-output-assert/text/000-vernac-output-assert.md
Referenced issue: rocq-prover/rocq#20688