Skip to content

Commit

Permalink
Preserve trailing space in test names using list discovery
Browse files Browse the repository at this point in the history
Trailing spaces were causing test run results to not match up with
the expected test items.

The same issue still exists for leading spaces in a test name.
However, It's unclear how consistent the indentation of test names
would be in the console output.
Rather than increase the risk of failure,
I opted to retain the potential error for leading spaces.
Leading spaces in a test name should not be common use case and is most likely an mistype
  • Loading branch information
farlee2121 committed Jul 5, 2023
1 parent bb13ef8 commit 07c47f3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Components/TestExplorer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ module DotnetCli =

let listTests projectPath targetFramework (shouldBuild: bool) =
let splitLines (str: string) =
str.Split([| "\n" |], StringSplitOptions.RemoveEmptyEntries)
str.Split([| "\r\n"; "\n\r"; "\n" |], StringSplitOptions.RemoveEmptyEntries)

promise {
let additionalArgs = if not shouldBuild then [| "--no-build" |] else Array.empty
Expand All @@ -388,10 +388,15 @@ module DotnetCli =
let testNames =
stdOutput
|> splitLines
|> Array.map String.trim
|> Array.skipWhile ((<>) "The following Tests are available:")
|> Array.where (not << String.IsNullOrEmpty)
|> Array.skipWhile (((<>) << String.trim) "The following Tests are available:")
|> Array.safeSkip 1
|> Array.choose (fun line ->
let line = line.TrimStart()

if (not << String.IsNullOrEmpty) line then
Some line
else
None)

return testNames
}
Expand Down

0 comments on commit 07c47f3

Please sign in to comment.