You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now the Span of a test case Ident is derived from the macro's call site. This means the observable source location for every test is grouped on the first invocation of test_case, which leads to side effects in tools that utilize those locations (e.g. the rust-analyzer Visual Studio Code extension and some new additions to listing tests in a binary.) I was able to throw together a change which uses Ident::set_span to match the emitted test function to its source attribute, but I'm not very savvy on proc macros/hygiene and wasn't sure if doing so is bad practice. If there aren't any issues with it, I could open a PR to introduce the change. I've included below examples of rust-analyzer's test decorations on the readme's sample code and cargo test -- --list -Zunstable-options --format=json run on nightly both before and after applying the change to demonstrate.
These changes look very useful, it always was a pain point for me that test cases are grouped. I don't mind using Ident::set_span here. If you can put together a PR which changes this behavior we'll be more than happy to accept it :)
Hi,
Right now the
Span
of a test caseIdent
is derived from the macro's call site. This means the observable source location for every test is grouped on the first invocation oftest_case
, which leads to side effects in tools that utilize those locations (e.g. the rust-analyzer Visual Studio Code extension and some new additions to listing tests in a binary.) I was able to throw together a change which usesIdent::set_span
to match the emitted test function to its source attribute, but I'm not very savvy on proc macros/hygiene and wasn't sure if doing so is bad practice. If there aren't any issues with it, I could open a PR to introduce the change. I've included below examples of rust-analyzer's test decorations on the readme's sample code andcargo test -- --list -Zunstable-options --format=json
run on nightly both before and after applying the change to demonstrate.Before
After
The text was updated successfully, but these errors were encountered: