-
Notifications
You must be signed in to change notification settings - Fork 735
Capture Output command modified #22140
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
Draft
SkySkimmer
wants to merge
12
commits into
rocq-prover:master
Choose a base branch
from
SkySkimmer:capture-out
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
740e245
Delete unused Topfmt.deep_ft
SkySkimmer 201d836
Update Topfmt.with_output_to_file to use memprof masking API
SkySkimmer dd7067b
vernaccontrol merge after_last_phase with interp phase
SkySkimmer 5bc1e22
add minor XXX comment
SkySkimmer c0380f0
Capture Output syntax + vernaccontrol (missing state)
SkySkimmer 238b006
Capture Output state handling
SkySkimmer 3c45940
add Print Captured Output
SkySkimmer 0ff1585
Invert dependency between G_vernac and Proof_using
SkySkimmer b3da133
add Drop Captured Output
SkySkimmer 064bbaf
test Print Captured Output
SkySkimmer 62d6bed
doc
SkySkimmer 1634a3c
Assert Captured Output first attempt
SkySkimmer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| 0 | ||
| : nat | ||
| 1 | ||
| : nat | ||
| 2 | ||
| : nat | ||
| File "./output/captured_output.v", line 7, characters 21-24: | ||
| Warning: hello [warn-reference,user-warn,default] | ||
| bar | ||
| : nat | ||
| File "./output/captured_output.v", line 9, characters 26-29: | ||
| The command has indeed failed with message: | ||
| Illegal application (Non-functional construction): | ||
| The expression "0" of type "nat" cannot be applied to the term | ||
| "0" : "nat" | ||
| File "./output/captured_output.v", line 11, characters 26-29: | ||
| The command has indeed failed with message: | ||
| Illegal application (Non-functional construction): | ||
| The expression "1" of type "nat" cannot be applied to the term | ||
| "1" : "nat" | ||
| 4 | ||
| : nat | ||
| File "./output/captured_output.v", line 16, characters 36-39: | ||
| Warning: hello [warn-reference,user-warn,default] | ||
| bar | ||
| : nat | ||
| File "./output/captured_output.v", line 19, characters 0-52: | ||
| Warning: Postfix notations (i.e. starting with a nonterminal symbol and | ||
| ending with a terminal symbol) should usually be at level 1 (default). | ||
| [postfix-notation-not-level-1,parsing,default] | ||
| Captured output: | ||
| 0 | ||
| : nat | ||
| 2 | ||
| : nat | ||
| hello | ||
| [warn-reference,user-warn,default] | ||
| bar | ||
| : nat | ||
| The command has indeed failed with message: | ||
| Illegal application (Non-functional construction): | ||
| The expression "0" of type "nat" | ||
| cannot be applied to the term | ||
| "0" : "nat" | ||
| hello [warn-reference,user-warn,default] | ||
| bar | ||
| : nat | ||
| hello [warn-reference,user-warn,default] | ||
| bar | ||
| : nat | ||
| Postfix notations (i.e. starting with a nonterminal symbol and ending with a | ||
| terminal symbol) should usually be at level 1 (default). | ||
| [postfix-notation-not-level-1,parsing,default] | ||
| 5 | ||
| : nat | ||
| Captured output: | ||
| 5 | ||
| : nat | ||
| File "./output/captured_output.v", line 31, characters 49-58: | ||
| The command has indeed failed with message: | ||
| Not OK: expected | ||
| "5 | ||
| : nat" | ||
| Quickfix: | ||
| Replace File "./output/captured_output.v", line 31, characters 49-58 with "5 | ||
| : nat" | ||
| File "./output/captured_output.v", line 34, characters 0-14: | ||
| Output OK. | ||
| File "./output/captured_output.v", line 38, characters 0-14: | ||
| Output OK. | ||
| File "./output/captured_output.v", line 41, characters 44-46: | ||
| Output OK. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| Capture Output Check 0. | ||
| Check 1. | ||
| Capture Output Check 2. | ||
|
|
||
| #[warn(note="hello")] Definition bar := 3. | ||
|
|
||
| Capture Output Check bar. | ||
|
|
||
| Capture Output Fail Check 0 0. | ||
|
|
||
| Fail Capture Output Check 1 1. | ||
|
|
||
| Succeed Capture Output Check 4. | ||
|
|
||
| (* multiple captures add the output multiple times NOT interleaved *) | ||
| Capture Output Capture Output Check bar. | ||
|
|
||
| (* synterp message goes after the interp messages of previous commands *) | ||
| Capture Output Reserved Notation "x !" (at level 2). | ||
|
|
||
| Print Captured Output. | ||
|
|
||
| Drop Captured Output. | ||
|
|
||
| Capture Output Check 5. | ||
|
|
||
| Succeed Drop Captured Output. | ||
|
|
||
| Print Captured Output. | ||
|
|
||
| Fail Assert Captured Output (printing width 102) "5 : nat". | ||
|
|
||
| Assert Captured Output (printing width 102, no drop) | ||
| "5 | ||
| : nat". | ||
|
|
||
| Assert Captured Output (printing width 102) | ||
| "5 | ||
| : nat". | ||
|
|
||
| Assert Captured Output (printing width 102) "". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| (************************************************************************) | ||
| (* * The Rocq Prover / The Rocq Development Team *) | ||
| (* v * Copyright INRIA, CNRS and contributors *) | ||
| (* <O___,, * (see version control and CREDITS file for authors & dates) *) | ||
| (* \VV/ **************************************************************) | ||
| (* // * This file is distributed under the terms of the *) | ||
| (* * GNU Lesser General Public License Version 2.1 *) | ||
| (* * (see LICENSE file for the text of the license) *) | ||
| (************************************************************************) | ||
|
|
||
| (* NB we could also keep the loc but it's unstable between coqtop | ||
| (proof general) and files so hard to use.Q | ||
|
|
||
| Could also add phase info, not sure if useful. *) | ||
| type output = Message of Feedback.level * Pp.t | ||
|
|
||
| type t = output list | ||
|
|
||
| let from_rev_list l = List.rev l | ||
|
|
||
| let from_list l = l | ||
|
|
||
| type flags = { | ||
| width : int option; | ||
| } | ||
|
|
||
| let default_flags = { | ||
| width = None; | ||
| } | ||
|
|
||
| let parse_flag acc (flag : Vernacexpr.AssertCapturedOutputFlags.t CAst.t) = | ||
| match flag.v with | ||
| (* NoDrop handled outside this file *) | ||
| | NoDrop -> acc | ||
| | PrintingWidth w -> | ||
| if Option.has_some acc.width then | ||
| CErrors.user_err ?loc:flag.loc Pp.(str "Duplicate flag " ++ Ppvernac.pr_assert_captured_output_flag flag.v ++ str ".") | ||
| else { width = Some w } | ||
|
|
||
| let parse_flags flags = List.fold_left parse_flag default_flags flags | ||
|
|
||
| let buf = Buffer.create 117 | ||
|
|
||
| let pp_with_width w out = | ||
| let fmt = Format.formatter_of_buffer buf in | ||
| Topfmt.set_gp fmt { Topfmt.dflt_gp with margin = w }; | ||
| Pp.pp_with fmt out; | ||
| Format.pp_print_flush fmt (); | ||
| Buffer.contents buf | ||
|
|
||
| let pp_with_width w out = | ||
| Util.try_finally (fun () -> pp_with_width w out) () | ||
| (fun () -> Buffer.reset buf) () | ||
|
|
||
| let print_captured_with_width w out = | ||
| let print_one (Message (_, msg)) = pp_with_width w msg in | ||
| let out = List.map print_one out in | ||
| String.concat "\n" out | ||
|
|
||
| exception Mismatch of Loc.t option * string | ||
|
|
||
| let () = CErrors.register_handler @@ function | ||
| | Mismatch (_,s) -> Some Pp.(str "Not OK: expected" ++ spc() ++ qstring s) | ||
| | _ -> None | ||
|
|
||
| let () = Quickfix.register @@ function | ||
| | Mismatch (Some loc,s) -> [Quickfix.make ~loc (Pp.qstring s)] | ||
| | _ -> [] | ||
|
|
||
| let vernac_assert out flags {CAst.loc; v=s} = | ||
| let flags = parse_flags flags in | ||
| match flags.width with | ||
| | None -> CErrors.user_err Pp.(str "Explicit printing width required.") | ||
| | Some w -> | ||
| let out = | ||
| print_captured_with_width | ||
| (Option.default (Option.get @@ Topfmt.get_margin()) flags.width) | ||
| out | ||
| in | ||
| (* XXX trim? (remove whitespace at end of lines, remove empty line at begin/end) *) | ||
| if String.equal out s then Feedback.msg_info ?loc Pp.(str "Output OK.") | ||
| else | ||
| (* XXX make this an error by default warning so that it's easy | ||
| to see all output mismatch from a file? *) | ||
| (* TODO print in patch format? *) | ||
| Loc.raise ?loc (Mismatch (loc,out)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| (************************************************************************) | ||
| (* * The Rocq Prover / The Rocq Development Team *) | ||
| (* v * Copyright INRIA, CNRS and contributors *) | ||
| (* <O___,, * (see version control and CREDITS file for authors & dates) *) | ||
| (* \VV/ **************************************************************) | ||
| (* // * This file is distributed under the terms of the *) | ||
| (* * GNU Lesser General Public License Version 2.1 *) | ||
| (* * (see LICENSE file for the text of the license) *) | ||
| (************************************************************************) | ||
|
|
||
| type output = Message of Feedback.level * Pp.t | ||
|
|
||
| (** In chronological order *) | ||
| type t = private output list | ||
|
|
||
| (** Build a [t] from a list in reverse chronological order. *) | ||
| val from_rev_list : output list -> t | ||
|
|
||
| (** Build a [t] from a list in chronological order. *) | ||
| val from_list : output list -> t | ||
|
|
||
| (** [vernac_assert captured flags s] checks that [captured] matches [s] according to [flags] | ||
| ([NoDrop] is ignored and should be handled by the caller). *) | ||
| val vernac_assert : t -> Vernacexpr.AssertCapturedOutputFlags.t CAst.t list -> string CAst.t -> unit |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently I don't print locations in Print Captured Output
notably they would be inconsistent in proof general (which gets some "toplevel input" location)
TODO make this more explicit in the doc