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

Update integration tests for Rust and error groups #1433

Merged
merged 3 commits into from
Mar 26, 2018

Conversation

fmdkdd
Copy link
Member

@fmdkdd fmdkdd commented Mar 14, 2018

See individual commit messages for an overview.

Implementation note: Currently the group property, as used by the rustc parser is populated with make-symbol values. This makes testing these values difficult using equal. I've worked around the issue by doing the comparison on copies of errors that have group set to nil, and added a second check using flycheck-related-errors.

The better solution would be to use group values that can be checked against in the integration tests. Or somehow redefine equal to optionally disregard the group slot. I'm open to suggestions.

Since the introduction of the `group` slot for `flycheck-error`, the
checkers in `flycheck-ert` hadn't been updated.  That meant that tests
for languages which used groups were failing (i.e., rust tests).

This commit takes the `group` slot into account when checking
`flycheck-error` objects against expected errors.
Since GH-1427, errors from other files are included in the current
buffer.  So they must be included in the integration tests.

In the case of Rust, macro errors emit diagnostics with a phony file, so
we now filter these errors to prevent them from appearing in the buffer.
@fmdkdd fmdkdd changed the title Test error groups Update integration tests for Rust and error groups Mar 14, 2018
@cpitclaudel
Copy link
Member

This looks very nice, thanks.

The better solution would be to use group values that can be checked against in the integration tests. Or somehow redefine equal to optionally disregard the group slot. I'm open to suggestions.

What about using consecutive numbers for groups? That is, use seq-map-indexed in -parse-rustc, and use the index as the group number in -parse-rustc-disagnostic.

@fmdkdd
Copy link
Member Author

fmdkdd commented Mar 14, 2018

What about using consecutive numbers for groups?

I think that would work. I went for symbols first because that was the easiest way to avoid collisions. If we use consecutive numbers, then we risk collisions since flycheck-related-errors will group errors based on that value alone.

I think it should be okay for Rust currently, since we can only have one Rust checker active at at time.

@cpitclaudel
Copy link
Member

If we use consecutive numbers, then we risk collisions since flycheck-related-errors will group errors based on that value alone.

Good point. What about using "rustc-%d"? Alternatively, should flycheck-related-errors group by group id and checker?

@fmdkdd
Copy link
Member Author

fmdkdd commented Mar 14, 2018

Alternatively, should flycheck-related-errors group by group id and checker?

It's probably best, yes!

Also what version of seq is seq-map-indexed in?

@cpitclaudel
Copy link
Member

Also what version of seq is seq-map-indexed in?

I see it in both seq-24 and seq on master

@fmdkdd
Copy link
Member Author

fmdkdd commented Mar 14, 2018

Yeah I see it on master but not in seq 2.3 that we currently have a dependency for flycheck. I tried to find a changelog but didn't find any. I ask because I recall an issue around here about using a seq version other than the one bundled with Emacs 24.3, I think.

@cpitclaudel
Copy link
Member

Indeed. I see it in seq-2.18.

@cpitclaudel
Copy link
Member

And also in 2.12

@fmdkdd
Copy link
Member Author

fmdkdd commented Mar 14, 2018

Ah, there is an unforeseen issue with using consecutive numbers. Cargo may call multiple compilation target in parallel, and the order of the diagnostics may not be the same at every run.

For instance, I'm seeing runs with groups 2, 2, 3, 3 and then runs with 4, 4, 5, 5. Now, in this particular case it looks like numbering the groups after error filtering would work, but... it's messy.

@cpitclaudel
Copy link
Member

Hmm, I don't understand too well. You mean that the output of cargo-check isn't deterministic? :/

@purcell
Copy link
Member

purcell commented Mar 15, 2018

Awesome, thanks for picking this up!

Also add a test for this function.
@fmdkdd
Copy link
Member Author

fmdkdd commented Mar 15, 2018

You mean that the output of cargo-check isn't deterministic? :/

For the same file, it will always return errors in the same order, but since cargo checks several files in parallel, the diagnostic sets of each file will interleave non-deterministically.

Since now we do not filter errors from other files, it seems predicting the group value set by the parser will be difficult.

@cpitclaudel
Copy link
Member

OK, understood. Your approach of stripping the group ids might be the best, then. The only other approach I can think of is to use one of the errors in a group as the group identifier (think union-find).

@fmdkdd
Copy link
Member Author

fmdkdd commented Mar 16, 2018

(think union-find).

That could be interesting, yes. I might try that.

@fmdkdd
Copy link
Member Author

fmdkdd commented Mar 23, 2018

That could be interesting, yes. I might try that.

I tried to use the first error of a group as the value for the group property of all related errors. The main issue I'm running into is that specifying the expected errors can be tricky due to the circularity.

It's possible to group the expected errors together, to avoid spelling out the group property:

'((1 1 info "msg" :checker rust)
  (1 1 info "msg" :checker rust))
'((2 2 info "msg" :checker rust))

In flycheck-ert, we can reconstruct that by assuming the first error of the list will be used for the group property of all errors in the same list. However, this assumption does not hold for all tests (as errors are re-ordered after parsing), so we have to decorrelate the error order from the groups.

We could use the circular notation instead:

   '(1 1 info "msg" :checker rust :group #1#)
'#1=(1 1 info "msg" :checker rust :group #1#)
'#2=(2 2 info "msg" :checker rust :group #2#)

But this does not work either, since #1# must appear after #1= is defined. Even if it did parse correctly, we would need some extra juggling since these are arguments to flycheck-error-new-at, and the group property should point to the flycheck-error created by the argument list.

This leaves us with coming up with a special marker to distinguish the reprensentative error (the one used as the group value for errors in the same group).

But at this point, I feel the original solution of stripping groups was more straightforward, especially as it does not involve changing the syntax of the tests.

@cpitclaudel
Copy link
Member

But at this point, I feel the original solution of stripping groups was more straightforward, especially as it does not involve changing the syntax of the tests.

Yes, I agree entirely.

@fmdkdd
Copy link
Member Author

fmdkdd commented Mar 26, 2018

Yes, I agree entirely.

Please do review and merge then :)

@cpitclaudel cpitclaudel merged commit 0a588ed into master Mar 26, 2018
@fmdkdd fmdkdd deleted the test-error-groups branch March 26, 2018 15:51
@fmdkdd
Copy link
Member Author

fmdkdd commented Mar 26, 2018

@cpitclaudel Thanks!

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.

3 participants