-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Coverage position misplacement in module #387
Comments
No, there shouldn't be a coverage point on any line here. Bisect only instruments the expression language (not the module language, and certainly not comments). I have two most likely initial candidate explanations:
|
Are you able to reduce the source file to smaller examples that still exhibit this behavior? Does it occur outside of your overall build? The content of the comment makes me suspect that this is a module that might be relatively easily taken out of your overall project. |
I can't have my hands on a computer this week-end but the file (and module) is relatively small yes. I did not manage to reproduce the issue on a minimal example (in a few minutes tbh), but will do very soon. Also an information I did not mention: the code is preprocessed by ppx_inline_test before bisect_ppx, could the generated code mess up positions ? |
Yes, that's very possible. I don't know what the case is here yet of course, but PPXs have often emitted bad locations in past experience. |
Here is a minimal example: https://github.com/vch9/bisect_ppx-issue-387 It is most certainly the generated code by let () = Ppx_inline_test_lib.Runtime.set_lib_and_partition "trie" ""
module Suffix = struct
...
end This is I believe the only difference of coverage's location when the preprocessing is enabled or not in this example. |
Could inspect the AST to get the exact location generated by I think the "correct" behavior for PPXs in most cases is to give generated code a "ghost" location, unless it corresponds to some user-written code in a very obvious way. Bisect_ppx knows not to instrument expressions that have ghost locations: bisect_ppx/src/ppx/instrument.ml Lines 185 to 192 in e65ee7f
If it's true that this generated code has a non-ghost location, it might not be deliberate, and this might be a mistake in ppx_inline_test. |
The generated code does not have a ghost location: structure_item (src/trie.ml[4,201+0]..[4,201+0])
Pstr_value Nonrec
[
<def>
pattern (src/trie.ml[4,201+0]..[4,201+0])
Ppat_construct "()" (src/trie.ml[4,201+0]..[4,201+0])
None
expression (src/trie.ml[4,201+0]..[4,201+0])
Pexp_apply
expression (src/trie.ml[4,201+0]..[4,201+0])
Pexp_ident "Ppx_inline_test_lib.Runtime.set_lib_and_partition" (src/trie.ml[4,201+0]..[4,201+0])
[
<arg>
Nolabel
expression (src/trie.ml[4,201+0]..[4,201+0])
Pexp_constant PConst_string("trie",None)
<arg>
Nolabel
expression (src/trie.ml[4,201+0]..[4,201+0])
Pexp_constant PConst_string("",None)
]
] The generated code then is instrumented: let () =
___bisect_post_visit___ 0
(Ppx_inline_test_lib.Runtime.set_lib_and_partition "trie" "") I will make an issue on ppx_inline_test for this |
Looks like this issue is being handled in janestreet/ppx_inline_test#33, so closing it here. |
I just found this in our test coverage.
Shouldn't the coverage position be on the next line ?
The text was updated successfully, but these errors were encountered: