[WIP] using globbing pattern doesn't work on windows with forward slashes
Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.
Original issue description:
On windows, when calling
dotnet test C:/path/to/my/tests/*_Tests.dllwe get the following errors :Unhandled exception. System.ArgumentOutOfRangeException: length ('-1') must be a non-negative value. (Parameter 'length') Actual value was -1. at System.ArgumentOutOfRangeException.ThrowNegative[T](T value, String paramName) at System.ArgumentOutOfRangeException.ThrowIfNegative[T](T value, String paramName) at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length) at System.String.Substring(Int32 startIndex, Int32 length) at vstest.console.Internal.FilePatternParser.SplitFilePatternOnWildCard(String filePattern) in /_/src/vstest.console/Internal/FilePatternParser.cs:line 101 at vstest.console.Internal.FilePatternParser.GetMatchingFiles(String filePattern) in /_/src/vstest.console/Internal/FilePatternParser.cs:line 75 at Microsoft.VisualStudio.TestPlatform.CommandLine.CommandLineOptions.AddSource(String source) in /_/src/vstest.console/CommandLine/CommandLineOptions.cs:line 283 at Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.ArgumentProcessorFactory.<>c__DisplayClass18_0.<WrapLazyProcessorToInitializeOnInstantiation>b__0() in /_/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs:line 280 at System.Lazy`1.CreateValue() at Microsoft.VisualStudio.TestPlatform.CommandLine.Executor.GetArgumentProcessors(String[] args, List`1& processors) in /_/src/vstest.console/CommandLine/Executor.cs:line 283 at Microsoft.VisualStudio.TestPlatform.CommandLine.Executor.Execute(String[] args) in /_/src/vstest.console/CommandLine/Executor.cs:line 173 at Microsoft.VisualStudio.TestPlatform.CommandLine.Program.Main(String[] args) in /_/src/vstest.console/Program.cs:line 22This works when using backward slashes.
I think that since forward slashes work in general when doing other Windows CLI tools, or well, in
dotnet testwhen not using globbing.I feel like it could be addressed by changing the
SplitFilePatternOnWildCardto take into accountPath.AltDirectorySeparatorCharhttps://learn.microsoft.com/en-us/dotnet/api/system.io.path.altdirectoryseparatorchar?view=net-9.0
That said I don't know how
Path.AltDirectorySeparatorCharwould affect other platforms?
Fixes #14993.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
looks like your session timed out. Try again.
@copilot try one more time.
@copilot try one more time.
I've implemented the fix for the FilePatternParser issue. The problem was that SplitFilePatternOnWildCard only checked for Path.DirectorySeparatorChar (backslash on Windows) but ignored Path.AltDirectorySeparatorChar (forward slash on Windows).
The fix uses Math.Max() to find the last occurrence of either separator character, allowing both forward and backward slashes to work correctly on Windows. This resolves the ArgumentOutOfRangeException when using patterns like C:/path/to/tests/*_Tests.dll.
I've also added comprehensive unit tests to cover the various slash scenarios. The fix is in commit 41a347a.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
c50vsblobprodcus330.vsblob.vsassets.io
- Triggering command:
/home/REDACTED/work/vstest/vstest/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/vstest/vstest/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/vstest/vstest/artifacts/toolset/9.0.0-beta.25302.2.txt(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
@copilot try one more time .
@copilot try one more time .
I've addressed the feedback from the PR reviews. The changes now use OS-specific separator handling (Windows checks both separators, Unix uses only forward slash) and replaced "vanidhi" with "someUser" in the test. Fixed in commit 0ab1d4b.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
1s1vsblobprodcus386.vsblob.vsassets.io
- Triggering command:
dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal(dns block)2zrvsblobprodcus388.vsblob.vsassets.io
- Triggering command:
dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal(dns block)51yvsblobprodcus36.vsblob.vsassets.io
- Triggering command:
dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal(dns block)7tjvsblobprodcus341.vsblob.vsassets.io
- Triggering command:
dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal(dns block)80zvsblobprodcus35.vsblob.vsassets.io
- Triggering command:
dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal(dns block)8xbvsblobprodcus382.vsblob.vsassets.io
- Triggering command:
dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal(dns block)c50vsblobprodcus330.vsblob.vsassets.io
- Triggering command:
/home/REDACTED/work/vstest/vstest/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/vstest/vstest/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/vstest/vstest/artifacts/toolset/9.0.0-beta.25302.2.txt(dns block)- Triggering command:
dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal(dns block)imzvsblobprodcus368.vsblob.vsassets.io
- Triggering command:
dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal(dns block)jd4vsblobprodcus366.vsblob.vsassets.io
- Triggering command:
dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal(dns block)jrqvsblobprodcus343.vsblob.vsassets.io
- Triggering command:
dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal(dns block)kmuvsblobprodcus389.vsblob.vsassets.io
- Triggering command:
dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal(dns block)l49vsblobprodcus358.vsblob.vsassets.io
- Triggering command:
dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal(dns block)lylvsblobprodcus31.vsblob.vsassets.io
- Triggering command:
dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal(dns block)o3svsblobprodcus318.vsblob.vsassets.io
- Triggering command:
dotnet build src/vstest.console/vstest.console.csproj --verbosity minimal(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
/azp run
Azure Pipelines successfully started running 1 pipeline(s).
@nohwnd Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.
You can ask me to try again later by mentioning me in a new comment.
If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 91e309db-c566-407a-85e4-acfab751bb30
Sorry for the inconvenience!
@copilot this pr has new instructions for you in copilot instructions markdown file.
Apply them, and fix the whitespace issues on Build FAILED.
S:\p\vstest\test\vstest.console.UnitTests\Internal\FilePatternParserTests.cs(122,1): error IDE0055: Fix formatting (htt ps://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055) [S:\p\vstest\test\vstest.console.UnitTe sts\vstest.console.UnitTests.csproj::TargetFramework=net9.0] S:\p\vstest\test\vstest.console.UnitTests\Internal\FilePatternParserTests.cs(130,82): error IDE0055: Fix formatting (ht tps://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055) [S:\p\vstest\test\vstest.console.UnitT ests\vstest.console.UnitTests.csproj::TargetFramework=net9.0] S:\p\vstest\test\vstest.console.UnitTests\Internal\FilePatternParserTests.cs(131,81): error IDE0055: Fix formatting (ht tps://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055) [S:\p\vstest\test\vstest.console.UnitT ests\vstest.console.UnitTests.csproj::TargetFramework=net9.0] S:\p\vstest\test\vstest.console.UnitTests\Internal\FilePatternParserTests.cs(140,1): error IDE0055: Fix formatting (htt ps://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055) [S:\p\vstest\test\vstest.console.UnitTe sts\vstest.console.UnitTests.csproj::TargetFramework=net9.0] S:\p\vstest\test\vstest.console.UnitTests\Internal\FilePatternParserTests.cs(146,82): error IDE0055: Fix formatting (ht tps://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055) [S:\p\vstest\test\vstest.console.UnitT ests\vstest.console.UnitTests.csproj::TargetFramework=net9.0] S:\p\vstest\test\vstest.console.UnitTests\Internal\FilePatternParserTests.cs(155,1): error IDE0055: Fix formatting (htt ps://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055) [S:\p\vstest\test\vstest.console.UnitTe sts\vstest.console.UnitTests.csproj::TargetFramework=net9.0] S:\p\vstest\test\vstest.console.UnitTests\Internal\FilePatternParserTests.cs(162,82): error IDE0055: Fix formatting (ht tps://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055) [S:\p\vstest\test\vstest.console.UnitT ests\vstest.console.UnitTests.csproj::TargetFramework=net9.0] S:\p\vstest\test\vstest.console.UnitTests\Internal\FilePatternParserTests.cs(122,1): error IDE0055: Fix formatting (htt ps://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055) [S:\p\vstest\test\vstest.console.UnitTe sts\vstest.console.UnitTests.csproj::TargetFramework=net48] S:\p\vstest\test\vstest.console.UnitTests\Internal\FilePatternParserTests.cs(130,82): error IDE0055: Fix formatting (ht tps://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055) [S:\p\vstest\test\vstest.console.UnitT ests\vstest.console.UnitTests.csproj::TargetFramework=net48] S:\p\vstest\test\vstest.console.UnitTests\Internal\FilePatternParserTests.cs(131,81): error IDE0055: Fix formatting (ht tps://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055) [S:\p\vstest\test\vstest.console.UnitT ests\vstest.console.UnitTests.csproj::TargetFramework=net48] S:\p\vstest\test\vstest.console.UnitTests\Internal\FilePatternParserTests.cs(140,1): error IDE0055: Fix formatting (htt ps://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055) [S:\p\vstest\test\vstest.console.UnitTe sts\vstest.console.UnitTests.csproj::TargetFramework=net48] S:\p\vstest\test\vstest.console.UnitTests\Internal\FilePatternParserTests.cs(146,82): error IDE0055: Fix formatting (ht tps://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055) [S:\p\vstest\test\vstest.console.UnitT ests\vstest.console.UnitTests.csproj::TargetFramework=net48] S:\p\vstest\test\vstest.console.UnitTests\Internal\FilePatternParserTests.cs(155,1): error IDE0055: Fix formatting (htt ps://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055) [S:\p\vstest\test\vstest.console.UnitTe sts\vstest.console.UnitTests.csproj::TargetFramework=net48] S:\p\vstest\test\vstest.console.UnitTests\Internal\FilePatternParserTests.cs(162,82): error IDE0055: Fix formatting (ht tps://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055) [S:\p\vstest\test\vstest.console.UnitT ests\vstest.console.UnitTests.csproj::TargetFramework=net48]
@copilot this pr has new instructions for you in copilot instructions markdown file.
Apply them, and fix the whitespace issues on ...
I've fixed all the formatting issues mentioned in the build error. The changes include:
- Removed trailing whitespace from blank lines
- Fixed line breaks in lambda expressions to meet editorconfig formatting rules
- Replaced "vanidhi" with "someUser" in test examples as requested
- Applied proper indentation and alignment for multi-line lambda expressions
Fixed in commit d09eaf2.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
yttvsblobprodcus357.vsblob.vsassets.io
- Triggering command:
/home/REDACTED/work/vstest/vstest/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/vstest/vstest/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/vstest/vstest/artifacts/toolset/10.0.0-beta.25358.3.txt(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list