Description
Usually when we run tests with the JSON reporter, we get the file/line/col of the test back. We can now also run tests by line number.
However, the file/line/col information is incorrect for tests using package:test_reflective_loader
so if we try to run by line then things don't work right. Or if you try to "Go to Test" that goes to the wrong place. I believe the issue is that when the test()
function is run, the actual location of the test method isn't on the stack at all, so what we end up with is the location of the call to defineReflectiveSuite
:
danny@Dannys-MacBook-Pro analysis_server % dart test -r json test/lsp/call_hierarchy_test.dart --plain-name "PrepareCallHierarchyTest | test_method"
// snip ...
"line": 175,
"column": 28,
"url": "package:test_reflective_loader/test_reflective_loader.dart",
// This is the call to defineReflectiveSuite
"root_line": 12,
"root_column": 3,
"root_url": "file:///Users/danny/Dev/Google/dart-sdk/sdk/pkg/analysis_server/test/lsp/call_hierarchy_test.dart"
// snip ...
So, the request is to support this style of test in a way that the correct location can be reported. The code that's calling test()
lives here:
Looking at the code, it has a MethodMirror
at the point where test
is called, and that has a .location
that looks like it's probably the values we want. However I can't see a way it could pass them to package:test
. Would it be feasible to allow passing an overridden location to test()
(or having some similar API that supported this)?