Fix answer file splitting by nohwnd · Pull Request #15306 · microsoft/vstest (original) (raw)
Description
The code was last touched here #1196 fixing some indeterminate issues with the parsing. Seeing the examples in tests it handles quotes differently and backslashes.
However the code runs out of bounds (not a problem but throws index out of range unnecessarilly).
And fails to recognize \" that is in quoted string. It detects the \", but the index is not advanced past that ", so in the next steps is incorrectly stops being a quoted string and spaces will split the command into more tokens.
This is problematic for providing /Tests: which provides the whole test name including spaces etc, in format like this:
/Tests:"UpdateTest.CheckUpdate("C:\\Data\\Config.xml","C:\\Data\\Config","C:\\Data\\User"),UpdateTest.MyTest(\"Lorem Ipsum\")"
mytests.dll
The previous logic would split the parameters to be:
/Tests:UpdateTest.CheckUpdate("C:\\Data\\Config.xml","C:\\Data\\Config","C:\\Data\\User"),UpdateTest.MyTest(\"Lorem
Ipsum\")
mytests.dll
And would fail with Ipsum\") test source not found.
New logic correctly splits it to:
/Tests:UpdateTest.CheckUpdate("C:\\Data\\Config.xml","C:\\Data\\Config","C:\\Data\\User"),UpdateTest.MyTest(\"Lorem Ipsum\")
mytests.dll
I have a much larger file from the issue, but it contains customer data, and the spaces are the only edge case that triggers this problem.
Related issue
https://developercommunity.visualstudio.com/t/vstest-task-fails-with-Unhandled-Except/10527048