experimentalTestTracking with @soloTest #5735
Copy link
Copy link
Closed
Labels
Description
Describe the bug
The new experimentalTestTracking has a problem when you remove @soloTest annotations (maybe the position with them is wrong from the start).
To Reproduce
Steps to reproduce the behavior:
- Go to
pkg/analysis_server/test/src/services/correction/assist/add_digit_separators_test.dart - Add
@soloTestbefore any test besides the first one - Run the test
- Remove the annotation (see the gutter icon is one line above)
- Run the whole file, see the position is still one line above
Expected behavior
For the gutter icon to be at the line that declares the method return type
Screenshots

Reactions are currently unavailable
Activity
FMorschel commentedon Oct 7, 2025
Can you point me where should I look into if I wanted to fix this myself? Would it be on
test_reflective_loader?DanTup commentedon Oct 7, 2025
I'm not sure what the issue is yet, so I'm not certain where the fix was. My feeling is that it's in Dart-Code in the position tracking code, or updating the position after you re-run the tests.
When we run tests, we run them with a json reporter which provides us the location, and when we get a new test location we try to match it up to an existing test in our model before creating a new one.
I feel like there might be two issues here:
When you remove the
@soloTest, I feel like we should've collapsed the position we were tracking better (to the start of the test).. I'm actually surprised we didn't just delete the marked entirely (because the start position was removed), even though that wouldn't be a great experience eitherWhen you re-run the tests, we should match up the new test result with the existing node in the test model and update its location
I was going to try and look at both the issues you raised in this area shortly, so if you're mostly interested in a fix than fixing it, I'll still do that. If you're interested in trying to fix I'm happy to leave it though (or try to figure out enough to give you better pointers).
FMorschel commentedon Oct 7, 2025
I see. I feel like there are two (maybe three if you separate what you said) problems here:
test_reflective_loadershowing theoffsetof theMethodDeclarationas a whole (which includes metadata and such) and not theMethodDeclaration.name.offset, which might help here like 90% of the timeI'd be happy to take a look at
test_reflective_loaderand see if I can make that work. Currently, if you have a really big method name and a return type, the offset is of the return type, which IMO, is not great UX (I remember some tests had this, but I know none at the top of my head, so a simple stub repro below from a new CL I'm working on).DanTup commentedon Oct 7, 2025
While that sounds like a fair change, test_reflective_loader is using Mirrors and I'm not sure if you can get at this.
See:
FMorschel commentedon Oct 7, 2025
Oh, I see. Then, at least the Mirrors docs are missing the bit on the annotations. I'll get more familiar with how Mirrors work and see if that is really the case. I'll open an issue/PR there then. Thanks!
DanTup commentedon Oct 7, 2025
The docs say:
I think
functionhere means functions_+methods (since methods aren't otherwise mentioned).FMorschel commentedon Oct 7, 2025
Oops, I skipped that part and read this first:
It seems fine then, thanks!
DanTup commentedon Oct 7, 2025
I just tested but couldn't actually repro this. If I delete the text that includes the start of
@soloTestthen the marked disappears:disappears.mp4
And if I keep that position in-tact and delete after it, the marker remains where you'd expect:
good.mp4
Can you confirm exactly what you're deleting when you see it go to the wrong place?
Currently we delete the tracked range if it's inside an area that gets deleted (for ex. you might have deleted the whole test, in which case we don't want the marker to jump to the end/start of what you deleted). Tracking the test name would certainly reduce the weirdness, but I don't know if we can do that given the mirrors (except maybe with some heuristics in Dart-Code that try to ignore comments and annotation lines 🤔).
FMorschel commentedon Oct 7, 2025
Had you already run this test previously? Maybe this only happens on "new tests" (not previously tracked)?
20251007_142825.mp4
This is from a completely clean tracking (restarted the extension host).
DanTup commentedon Oct 8, 2025
Hmm, I still can't repro. Can you confirm exactly what you're doing? This is what I tried:
@soloTestto that test@soloTestand held<shift>then pressed<up><delete>tests.mp4
At the end I re-ran the whole file with Ctrl+F5 just to see everything showed up again as expected.
FMorschel commentedon Oct 8, 2025
Not sure what the difference is between
F5andCtrl+F5, but I've done exactly as you said, and the gutter icon stays on line 67 for me once I delete the@soloTest(I've probably done the same but withBackspaceinstead ofDeleteand justF5instead ofCTRL+F5originally, but I've tested the same as you and no change).Debug logs here
DanTup commentedon Oct 29, 2025
@FMorschel sorry for the delay... I took a look at the log when you posted this and couldn't figure it out, and I'm looking again and still can't.
Are you able to check you definitely have
dart.experimentalTestTracking: truefor this project? When I try to repro, the marker disappears (as I would expect), but for you it does not - and I can see that the code to remove it will only run for the experimental tracking.Can you also try running "Clear test results" and reloading first, just in case there's anything weird with previous data hanging around.
Thanks!
FMorschel commentedon Oct 29, 2025
Oops, sorry! I must've accidentally set this to
falseon my JSON by mistake when I wanted to change some other flag.I've made sure I have this set to true on my profile (which I don't edit much), so this doesn't happen again.
This is all WAI now. Thanks!
DanTup commentedon Oct 29, 2025
Got it, thanks for confirming!
DanTup commentedon Oct 29, 2025
FWIW, I published a pre-release today that removes that flag and replaces it with a temporary flag
dynamicTestTrackingwhich defaults to true (so basically it's enabled by default now, and that flag is just an emergency opt-out, which will be removed in a future version).