-
Notifications
You must be signed in to change notification settings - Fork 39
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
Testament diff rework - unstructured, structured #206
Conversation
43f7b54
to
431c4ea
Compare
bors try |
tryBuild failed: |
558e0ee
to
b42b2c4
Compare
cb4dbec
to
2296000
Compare
I tried to review, little too tired to digest this tonight, will try again tomorrow. |
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.
Reviewed code, will do docs tomorrow 🤞
|
||
proc sexp*[E: enum](e: E): SexpNode = newSSymbol($e) | ||
|
||
proc sexpItems*[T](s: T): SexpNode = |
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.
Can we move this below the other s-exp procs, it flows better and if the T is one of the ones below it'll not be confusing if some declares a new one but this doesn't take it into account up here.
Also, seriously this probably shouldn't compile.
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.
Also, seriously this process shouldn't compile.
what 'process' are you talking about and why it shouldn't compile?
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.
Typo, yeah it's strange that it's allowed by the compiler.
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.
it's strange that it's allowed by the compiler.
again, why?
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.
Because a type T
is not guaranteed to have an items
, yes?
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.
It won't compile when I instantiate the proc like every other generic, so I guess this is not allowed? I just don't get why this remark is attached to a definition. sexp two lines above can have $ defined as {.error.} and it would've been an instantiation error as well
compiler/front/sexp_reporter.nim
Outdated
sexp(writeConf.toMsgFilename(id)) | ||
|
||
|
||
iterator sexpFields[T](obj: T, ignore: seq[string] = @[]): SexpNode = |
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.
So weird that this works without constraints, feels like a bug.
I think T should have an a type constraint of object | tuple
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.
Why does it feel like a bug? Generic iterator, accepts generic type T
, works as intended
I think T should have an a type constraint of object | tuple
Can be clarified later, but the fact it works without it doesn't really make it a bug IMO
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.
It absolutely is a bug because there is no guarantee you can iterate over T?
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.
What do you mean "can't iterator over T"? The iterator
is defined for T
therefore I can iterate over it, I don't see any bugs here
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.
T
is not guaranteed to have fields for fieldPairs
to work, it might be out of scope for this PR, but it's silly that between the stdlib and the compiler that this is allowed.
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.
You are talking about need for 'HasFields' concept or something like that here, otherwise it is a perfectly fine generic that would generate a perfectly fine compilation error on instantiation saying that there are no fields in here. I don't understand where the "bug" part comes from here. Just like the sexpItems above - it is instantiation error, just like every other generic proc. I can put object|tuple there, but that would just make code clearer, it won't make it more correct (as in - reject malformed program that would've compiled previously) in any way. If there is no field pairs the code does not compile, pointing to "instantiation of X...". If there are field pairs the code compiles.
I will update the PR for review comments after you review the docs. Also, please do read the tests as well - I added some explanations about how diff is intended to function, and it's behavior there. |
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.
Reviewed. There is plenty about the differencing I don't understand. So that'll be fun to dig into later.
Mostly typos and doc adjustments.
2296000
to
c4a2005
Compare
what and why printing category |
I don't understand the question. The check for |
What I mean is the empty quotes in |
c4a2005
to
7252cbd
Compare
Fixed empty quotes, now it prints only test name for empty categories |
- rework implementation of the message diff in testament. Now plaintext diff is implemented using built-in diff written in nim instead of calling into separate `git diff` command that produced noisy, colorless output and was completely unconfigurable. - Add implementation of the structured message diff, structured compiler reports for the compiler. These changes had to be made togehter, otherwise it would've been a series incomplete PRs that depended on each other even for the purposes of testing/documentation. - Add s-expression formatter to the compiler output. Selected using `--msgFormat=sexp` (for now we have a `text` and `sexp`, in the future `json` must be added as well, since that's what people actually expect from their tooling - not some obscure data format). - Fix 'invalid value' error for cli switch - that bug was discovered when adding `msgFormat` option. - Add structural S-expression diff algorithm with formatting logic for mismatches. - Add `nimoutFormat: sexp` field for the testament, to allow it understand what kind of data will be generated by the compiler itself. - Clean up testament message diff handling a little and add checks for structural diffs where appropriate. - Minor related changes - Split `strutils.addf` and reuse the interpolation string for colored text - otherwise all futher formatting logic looked a lot uglier than necessary (using `strformat.&` would require factoring out macro implementation parts) - Clean up testament documentation for different spec parts, add description of the structural messages. - More documentation all over testament implementation - Move `sexp` file into `experimental/` directory - it is no longer related directly to nimsuggest, @saem has already suggested moving it in nim-works#164 - Testament no longer has a hard assertion on the path of the tested file `testament tfile.nim` can also work, and does not force user to create needlessly nested directories for purposes of simple file testing.
7252cbd
to
8015d49
Compare
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.
Bors r+
Merge me up, Scotty!
Build succeeded: |
wip, todo:
addResult
, so I split it up at least a little, and there were a couple of other entries that I had to reformat because I could not meaningfully work with them any other way, because they were SO badly implemented.--msgFormat
documentationnimc.rst
toHtml
for colored text is not needed#[tt.
inline annotations testament-+-+
is less readable compared to--++
. Make this configurable, sometimes-+-+
with inline change annotations is more useful than--++
that was joined.Changes for regular diff:
Convert this:
to this
and also make testament support structured reports that would allow you to get this
Out of this
Note how structured diff properly handles both inline and
nimout
error messages whereas with unstructured diff testament can only report half of the problems.