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
{{ message }}
Repository navigation
Run/debug test buttons disappears if test description has double quotes #2053
Thanks for the report! It looks like the outline data for these tests always comes through with double quotes, so when there's a double quote in the name we get this:
This confuses the code I wrote to extract the test name (where I wanted to avoid having to handle all the details of Dart string parsing in TypeScript). I'll see if I can tweak it a little - in theory it can probably just strip test(" from the start and ") from the end, and then remove any unescape any remaining quotes. It'll never be completely reliable, since you could put variables and things inside them in Dart which wouldn't come through in the outline.
@scheglov is it expected that the quotes come through like this (the single quotes in the source code became double quotes in the outline node element name, even though there were quotes contained within), or is that also a bug?
@DanTup Well, it is implemented as wrapping "description" into double quotes. The description is either the string literal values of AstNode.toSource() for cases when the name if a variable. It was intended to give the user a way to navigate between groups and tests, and the name is to give some description to them. It seems that you are using it now for something more than just a hint to the user. So, I don't know what it the right answer here. How do you use it?
In VS Code we add these "code lens" links above each test/group (the run/debug links):
Clicking these will run just that test - but in order to do that we need to run pub run test --name "^test name$" (where test name is the name of the test). This means we need to extract the test name from the Outline data. It's not foolproof - if your test is named "test $counter" or similar, it's not going to work - but things that are just static strings should.
I've improved this for now by just stripping the test(" and ") from the string and using the rest as-is (after escaping and wrapping quotes for executing via a shell), so if there's not a clear improvement for the analyzer, then don't worry about changing anything. It looked weird to have "string " string", but unless there was a field that didn't include the test("") part, I don't think it's be easy to represent (and since the outline is pretty generic, adding test-specific fields might not make sense).
Activity
DanTup commentedon Oct 16, 2019
Thanks for the report! It looks like the outline data for these tests always comes through with double quotes, so when there's a double quote in the name we get this:
This confuses the code I wrote to extract the test name (where I wanted to avoid having to handle all the details of Dart string parsing in TypeScript). I'll see if I can tweak it a little - in theory it can probably just strip
test("from the start and")from the end, and then remove any unescape any remaining quotes. It'll never be completely reliable, since you could put variables and things inside them in Dart which wouldn't come through in the outline.@scheglov is it expected that the quotes come through like this (the single quotes in the source code became double quotes in the outline node element name, even though there were quotes contained within), or is that also a bug?
Handles quotes in test names better
Ensure some tests in tests have quotes in name
scheglov commentedon Oct 16, 2019
@DanTup Well, it is implemented as wrapping "description" into double quotes. The description is either the string literal values of
AstNode.toSource()for cases when the name if a variable. It was intended to give the user a way to navigate between groups and tests, and the name is to give some description to them. It seems that you are using it now for something more than just a hint to the user. So, I don't know what it the right answer here. How do you use it?scheglov commentedon Oct 16, 2019
I prototyped a CL, but Paul gave me an idea that maybe we should not just change, but first analyze what the clients need :-)
DanTup commentedon Oct 17, 2019
Ah, I see :)
In VS Code we add these "code lens" links above each test/group (the run/debug links):
Clicking these will run just that test - but in order to do that we need to run
pub run test --name "^test name$"(wheretest nameis the name of the test). This means we need to extract the test name from the Outline data. It's not foolproof - if your test is named"test $counter"or similar, it's not going to work - but things that are just static strings should.I've improved this for now by just stripping the
test("and")from the string and using the rest as-is (after escaping and wrapping quotes for executing via a shell), so if there's not a clear improvement for the analyzer, then don't worry about changing anything. It looked weird to have"string " string", but unless there was a field that didn't include thetest("")part, I don't think it's be easy to represent (and since the outline is pretty generic, adding test-specific fields might not make sense).Handles quotes in test names better
Ensure some tests in tests have quotes in name
scheglov commentedon Oct 17, 2019
Thank you for the explanation!