From 92317288346905906955d037cdfdf512e4da52ec Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Jun 2025 13:36:30 +0000 Subject: [PATCH 01/10] Initial plan for issue From 41a347a5a4c1dfba76fb77e06dc0c2af0734e6ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:53:00 +0000 Subject: [PATCH 02/10] Fix FilePatternParser to handle forward slashes on Windows Co-authored-by: nohwnd <5735905+nohwnd@users.noreply.github.com> --- .../Internal/FilePatternParser.cs | 9 +++- .../Internal/FilePatternParserTests.cs | 47 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/vstest.console/Internal/FilePatternParser.cs b/src/vstest.console/Internal/FilePatternParser.cs index 804739ca7e..27a28fda0b 100644 --- a/src/vstest.console/Internal/FilePatternParser.cs +++ b/src/vstest.console/Internal/FilePatternParser.cs @@ -96,7 +96,14 @@ private Tuple SplitFilePatternOnWildCard(string filePattern) { // Split the pattern based on first wild card character found. var splitOnWildCardIndex = filePattern.IndexOfAny(_wildCardCharacters); - var directorySeparatorIndex = filePattern.Substring(0, splitOnWildCardIndex).LastIndexOf(Path.DirectorySeparatorChar); + var pathBeforeWildCard = filePattern.Substring(0, splitOnWildCardIndex); + + // Find the last directory separator (either \ or /) before the wildcard + // On Windows, both \ and / are valid directory separators + // On Unix-like systems, only / is typically valid, but this approach is safe for both + var directorySeparatorIndex = Math.Max( + pathBeforeWildCard.LastIndexOf(Path.DirectorySeparatorChar), + pathBeforeWildCard.LastIndexOf(Path.AltDirectorySeparatorChar)); string searchDir = filePattern.Substring(0, directorySeparatorIndex); string pattern = filePattern.Substring(directorySeparatorIndex + 1); diff --git a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs index 571936d859..1930165f14 100644 --- a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs +++ b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs @@ -114,6 +114,53 @@ public void FilePatternParserShouldThrowCommandLineExceptionIfFileDoesNotExist() Assert.ThrowsException(() => _filePatternParser.GetMatchingFiles(TranslatePath(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll"))); } + [TestMethod] + public void FilePatternParserShouldCorrectlySplitPatternAndDirectoryWithForwardSlashes() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + + // Test with forward slashes - this should work on all platforms + _filePatternParser.GetMatchingFiles("C:/Users/vanidhi/Desktop/a/c/*bc.dll"); + + // Assert that the pattern is parsed correctly + _mockMatcherHelper.Verify(x => x.AddInclude("*bc.dll")); + // The directory path might be normalized by the OS, so we check for both possible formats + _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => + y.FullName.Contains("vanidhi") && y.FullName.Contains("Desktop") && y.FullName.Contains("a") && y.FullName.Contains("c")))); + } + + [TestMethod] + public void FilePatternParserShouldCorrectlySplitWithArbitraryDirectoryDepthWithForwardSlashes() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + + // Test with forward slashes and recursive patterns + _filePatternParser.GetMatchingFiles("C:/Users/vanidhi/**/c/*bc.txt"); + + // Assert + _mockMatcherHelper.Verify(x => x.AddInclude("**/c/*bc.txt")); + _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => + y.FullName.Contains("vanidhi")))); + } + + [TestMethod] + public void FilePatternParserShouldCorrectlySplitWithMixedSlashes() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + + // Test behavior with mixed forward and backward slashes + // This is primarily relevant on Windows where both are valid + _filePatternParser.GetMatchingFiles("C:/Users/vanidhi/Desktop/a/c/*bc.dll"); + + // Assert that the pattern is parsed correctly - should find the last separator regardless of type + _mockMatcherHelper.Verify(x => x.AddInclude("*bc.dll")); + _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => + y.FullName.Contains("vanidhi") && y.FullName.Contains("Desktop") && y.FullName.Contains("a") && y.FullName.Contains("c")))); + } + private static string TranslatePath(string path) { // RuntimeInformation has conflict when used From 94968fec9518450bb0cea6476f8e33bc356dcf62 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:55:09 +0000 Subject: [PATCH 03/10] Improve test coverage and documentation for forward slash fix Co-authored-by: nohwnd <5735905+nohwnd@users.noreply.github.com> --- .../Internal/FilePatternParserTests.cs | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs index 1930165f14..e5384cce86 100644 --- a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs +++ b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs @@ -121,13 +121,15 @@ public void FilePatternParserShouldCorrectlySplitPatternAndDirectoryWithForwardS _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); // Test with forward slashes - this should work on all platforms + // This specifically tests the fix for issue #14993 _filePatternParser.GetMatchingFiles("C:/Users/vanidhi/Desktop/a/c/*bc.dll"); // Assert that the pattern is parsed correctly _mockMatcherHelper.Verify(x => x.AddInclude("*bc.dll")); - // The directory path might be normalized by the OS, so we check for both possible formats + // On Windows, the path may be normalized, so we verify the key components are present _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => - y.FullName.Contains("vanidhi") && y.FullName.Contains("Desktop") && y.FullName.Contains("a") && y.FullName.Contains("c")))); + y.FullName.Contains("vanidhi") && y.FullName.Contains("Desktop") && + y.FullName.Contains("a") && y.FullName.EndsWith("c")))); } [TestMethod] @@ -146,19 +148,19 @@ public void FilePatternParserShouldCorrectlySplitWithArbitraryDirectoryDepthWith } [TestMethod] - public void FilePatternParserShouldCorrectlySplitWithMixedSlashes() + public void FilePatternParserShouldHandleForwardSlashesWithoutThrowingException() { var patternMatchingResult = new PatternMatchingResult(new List()); _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - // Test behavior with mixed forward and backward slashes - // This is primarily relevant on Windows where both are valid - _filePatternParser.GetMatchingFiles("C:/Users/vanidhi/Desktop/a/c/*bc.dll"); + // This is the specific case from the original bug report that was throwing ArgumentOutOfRangeException + // Before the fix: System.ArgumentOutOfRangeException: length ('-1') must be a non-negative value + _filePatternParser.GetMatchingFiles("C:/path/to/my/tests/*_Tests.dll"); - // Assert that the pattern is parsed correctly - should find the last separator regardless of type - _mockMatcherHelper.Verify(x => x.AddInclude("*bc.dll")); + // Assert that we successfully parse without throwing and get the expected pattern + _mockMatcherHelper.Verify(x => x.AddInclude("*_Tests.dll")); _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => - y.FullName.Contains("vanidhi") && y.FullName.Contains("Desktop") && y.FullName.Contains("a") && y.FullName.Contains("c")))); + y.FullName.Contains("path") && y.FullName.Contains("tests")))); } private static string TranslatePath(string path) From 0ab1d4b1b70543d8c51268b70fe704907fe13a07 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Jun 2025 12:19:40 +0000 Subject: [PATCH 04/10] Address PR feedback: OS-specific separator handling and fix test username Co-authored-by: nohwnd <5735905+nohwnd@users.noreply.github.com> --- .../Internal/FilePatternParser.cs | 23 ++++++++++++++----- .../Internal/FilePatternParserTests.cs | 4 ++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/vstest.console/Internal/FilePatternParser.cs b/src/vstest.console/Internal/FilePatternParser.cs index 27a28fda0b..9d725b13fa 100644 --- a/src/vstest.console/Internal/FilePatternParser.cs +++ b/src/vstest.console/Internal/FilePatternParser.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Runtime.InteropServices; using Microsoft.Extensions.FileSystemGlobbing; using Microsoft.Extensions.FileSystemGlobbing.Abstractions; @@ -98,12 +99,22 @@ private Tuple SplitFilePatternOnWildCard(string filePattern) var splitOnWildCardIndex = filePattern.IndexOfAny(_wildCardCharacters); var pathBeforeWildCard = filePattern.Substring(0, splitOnWildCardIndex); - // Find the last directory separator (either \ or /) before the wildcard - // On Windows, both \ and / are valid directory separators - // On Unix-like systems, only / is typically valid, but this approach is safe for both - var directorySeparatorIndex = Math.Max( - pathBeforeWildCard.LastIndexOf(Path.DirectorySeparatorChar), - pathBeforeWildCard.LastIndexOf(Path.AltDirectorySeparatorChar)); + // Find the last directory separator before the wildcard + // On Windows, we need to check both \ and / as both are valid + // On Unix-like systems, only / is the directory separator + int directorySeparatorIndex; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + // On Windows, check both separators and take the last one found + directorySeparatorIndex = Math.Max( + pathBeforeWildCard.LastIndexOf(Path.DirectorySeparatorChar), + pathBeforeWildCard.LastIndexOf(Path.AltDirectorySeparatorChar)); + } + else + { + // On Unix-like systems, only use the forward slash + directorySeparatorIndex = pathBeforeWildCard.LastIndexOf(Path.DirectorySeparatorChar); + } string searchDir = filePattern.Substring(0, directorySeparatorIndex); string pattern = filePattern.Substring(directorySeparatorIndex + 1); diff --git a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs index e5384cce86..d43aae6481 100644 --- a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs +++ b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs @@ -122,13 +122,13 @@ public void FilePatternParserShouldCorrectlySplitPatternAndDirectoryWithForwardS // Test with forward slashes - this should work on all platforms // This specifically tests the fix for issue #14993 - _filePatternParser.GetMatchingFiles("C:/Users/vanidhi/Desktop/a/c/*bc.dll"); + _filePatternParser.GetMatchingFiles("C:/Users/someUser/Desktop/a/c/*bc.dll"); // Assert that the pattern is parsed correctly _mockMatcherHelper.Verify(x => x.AddInclude("*bc.dll")); // On Windows, the path may be normalized, so we verify the key components are present _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => - y.FullName.Contains("vanidhi") && y.FullName.Contains("Desktop") && + y.FullName.Contains("someUser") && y.FullName.Contains("Desktop") && y.FullName.Contains("a") && y.FullName.EndsWith("c")))); } From da85db9422987ade301161dd7926dbdb250d475f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Thu, 19 Jun 2025 16:16:12 +0200 Subject: [PATCH 05/10] fix formatting --- src/vstest.console/Internal/FilePatternParser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vstest.console/Internal/FilePatternParser.cs b/src/vstest.console/Internal/FilePatternParser.cs index 9d725b13fa..9dfcd08678 100644 --- a/src/vstest.console/Internal/FilePatternParser.cs +++ b/src/vstest.console/Internal/FilePatternParser.cs @@ -98,7 +98,7 @@ private Tuple SplitFilePatternOnWildCard(string filePattern) // Split the pattern based on first wild card character found. var splitOnWildCardIndex = filePattern.IndexOfAny(_wildCardCharacters); var pathBeforeWildCard = filePattern.Substring(0, splitOnWildCardIndex); - + // Find the last directory separator before the wildcard // On Windows, we need to check both \ and / as both are valid // On Unix-like systems, only / is the directory separator From ccbfd86cfb1d50bd66271a1e37ac809b89212021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Thu, 17 Jul 2025 12:47:32 +0200 Subject: [PATCH 06/10] Disable fomatting checks --- .editorconfig | 2 +- .../Internal/FilePatternParserTests.cs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.editorconfig b/.editorconfig index 39f9dc14c9..48e953d007 100644 --- a/.editorconfig +++ b/.editorconfig @@ -329,7 +329,7 @@ csharp_style_prefer_parameter_null_checking = false # not default, disabled as n #### .NET Formatting Rules #### # IDE0055: Fix formatting - Set the severity of all .NET and C# formatting rules (https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules) -dotnet_diagnostic.IDE0055.severity = warning # ensure all formatting rules are enforced on build +dotnet_diagnostic.IDE0055.severity = none # Nice formatting is great, but when copilot changes code we more than not end up with some extra whitespace. # IDE0057: Use range operator dotnet_diagnostic.IDE0057.severity = none # Range operator is not supported in some TFMs. diff --git a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs index d43aae6481..b3763ca55b 100644 --- a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs +++ b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs @@ -119,7 +119,7 @@ public void FilePatternParserShouldCorrectlySplitPatternAndDirectoryWithForwardS { var patternMatchingResult = new PatternMatchingResult(new List()); _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - + // Test with forward slashes - this should work on all platforms // This specifically tests the fix for issue #14993 _filePatternParser.GetMatchingFiles("C:/Users/someUser/Desktop/a/c/*bc.dll"); @@ -127,8 +127,8 @@ public void FilePatternParserShouldCorrectlySplitPatternAndDirectoryWithForwardS // Assert that the pattern is parsed correctly _mockMatcherHelper.Verify(x => x.AddInclude("*bc.dll")); // On Windows, the path may be normalized, so we verify the key components are present - _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => - y.FullName.Contains("someUser") && y.FullName.Contains("Desktop") && + _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => + y.FullName.Contains("someUser") && y.FullName.Contains("Desktop") && y.FullName.Contains("a") && y.FullName.EndsWith("c")))); } @@ -137,13 +137,13 @@ public void FilePatternParserShouldCorrectlySplitWithArbitraryDirectoryDepthWith { var patternMatchingResult = new PatternMatchingResult(new List()); _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - + // Test with forward slashes and recursive patterns _filePatternParser.GetMatchingFiles("C:/Users/vanidhi/**/c/*bc.txt"); // Assert _mockMatcherHelper.Verify(x => x.AddInclude("**/c/*bc.txt")); - _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => + _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Contains("vanidhi")))); } @@ -152,7 +152,7 @@ public void FilePatternParserShouldHandleForwardSlashesWithoutThrowingException( { var patternMatchingResult = new PatternMatchingResult(new List()); _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - + // This is the specific case from the original bug report that was throwing ArgumentOutOfRangeException // Before the fix: System.ArgumentOutOfRangeException: length ('-1') must be a non-negative value _filePatternParser.GetMatchingFiles("C:/path/to/my/tests/*_Tests.dll"); From 7c5eb2bce2ed79c8289e39f06e8ede2a1a6515e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Thu, 17 Jul 2025 12:54:33 +0200 Subject: [PATCH 07/10] Revert "Disable fomatting checks" This reverts commit ccbfd86cfb1d50bd66271a1e37ac809b89212021. --- .editorconfig | 2 +- .../Internal/FilePatternParserTests.cs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.editorconfig b/.editorconfig index 48e953d007..39f9dc14c9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -329,7 +329,7 @@ csharp_style_prefer_parameter_null_checking = false # not default, disabled as n #### .NET Formatting Rules #### # IDE0055: Fix formatting - Set the severity of all .NET and C# formatting rules (https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules) -dotnet_diagnostic.IDE0055.severity = none # Nice formatting is great, but when copilot changes code we more than not end up with some extra whitespace. +dotnet_diagnostic.IDE0055.severity = warning # ensure all formatting rules are enforced on build # IDE0057: Use range operator dotnet_diagnostic.IDE0057.severity = none # Range operator is not supported in some TFMs. diff --git a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs index b3763ca55b..d43aae6481 100644 --- a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs +++ b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs @@ -119,7 +119,7 @@ public void FilePatternParserShouldCorrectlySplitPatternAndDirectoryWithForwardS { var patternMatchingResult = new PatternMatchingResult(new List()); _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - + // Test with forward slashes - this should work on all platforms // This specifically tests the fix for issue #14993 _filePatternParser.GetMatchingFiles("C:/Users/someUser/Desktop/a/c/*bc.dll"); @@ -127,8 +127,8 @@ public void FilePatternParserShouldCorrectlySplitPatternAndDirectoryWithForwardS // Assert that the pattern is parsed correctly _mockMatcherHelper.Verify(x => x.AddInclude("*bc.dll")); // On Windows, the path may be normalized, so we verify the key components are present - _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => - y.FullName.Contains("someUser") && y.FullName.Contains("Desktop") && + _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => + y.FullName.Contains("someUser") && y.FullName.Contains("Desktop") && y.FullName.Contains("a") && y.FullName.EndsWith("c")))); } @@ -137,13 +137,13 @@ public void FilePatternParserShouldCorrectlySplitWithArbitraryDirectoryDepthWith { var patternMatchingResult = new PatternMatchingResult(new List()); _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - + // Test with forward slashes and recursive patterns _filePatternParser.GetMatchingFiles("C:/Users/vanidhi/**/c/*bc.txt"); // Assert _mockMatcherHelper.Verify(x => x.AddInclude("**/c/*bc.txt")); - _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => + _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Contains("vanidhi")))); } @@ -152,7 +152,7 @@ public void FilePatternParserShouldHandleForwardSlashesWithoutThrowingException( { var patternMatchingResult = new PatternMatchingResult(new List()); _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - + // This is the specific case from the original bug report that was throwing ArgumentOutOfRangeException // Before the fix: System.ArgumentOutOfRangeException: length ('-1') must be a non-negative value _filePatternParser.GetMatchingFiles("C:/path/to/my/tests/*_Tests.dll"); From e81f387dd0f03ebde9cd6bc9725913eaa0367ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Thu, 17 Jul 2025 12:58:43 +0200 Subject: [PATCH 08/10] Add copilot instructions --- .github/copilot-instructions.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/copilot-instructions.md diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000000..19be10e2fa --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,30 @@ +This is a .NET based repository that contains the VSTest test platform. Please follow these guidelines when contributing: + +## Code Standards + +You MUST follow all code-formatting and naming conventions defined in [`.editorconfig`](../.editorconfig). + +In addition to the rules enforced by `.editorconfig`, you SHOULD: + +- Favor style and conventions that are consistent with the existing codebase. +- Prefer file-scoped namespace declarations and single-line using directives. +- Ensure that the final return statement of a method is on its own line. +- Use pattern matching and switch expressions wherever possible. +- Use `nameof` instead of string literals when referring to member names. +- Always use `is null` or `is not null` instead of `== null` or `!= null`. +- Trust the C# null annotations and don't add null checks when the type system says a value cannot be null. +- Prefer `?.` if applicable (e.g. `scope?.Dispose()`). +- Use `ObjectDisposedException.ThrowIf` where applicable. +- Respect StyleCop.Analyzers rules, in particular: + - SA1028: Code must not contain trailing whitespace + - SA1316: Tuple element names should use correct casing + - SA1518: File is required to end with a single newline character + +You MUST minimize adding public API surface area but any newly added public API MUST be declared in the related `PublicAPI.Unshipped.txt` file. + +## Localization Guidelines + +Anytime you add a new localization resource, you MUST: +- Add a corresponding entry in the localization resource file. +- Add an entry in all `*.xlf` files related to the modified `.resx` file. +- Do not modify existing entries in '*.xlf' files unless you are also modifying the corresponding `.resx` file. From d09eaf2769d6b174b63a38d6ab2a69b6d0a1508b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 17 Jul 2025 11:04:24 +0000 Subject: [PATCH 09/10] Fix formatting issues: remove trailing whitespace, fix line breaks, and replace vanidhi with someUser Co-authored-by: nohwnd <5735905+nohwnd@users.noreply.github.com> --- .../Internal/FilePatternParserTests.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs index d43aae6481..c9c042e684 100644 --- a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs +++ b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs @@ -119,7 +119,7 @@ public void FilePatternParserShouldCorrectlySplitPatternAndDirectoryWithForwardS { var patternMatchingResult = new PatternMatchingResult(new List()); _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - + // Test with forward slashes - this should work on all platforms // This specifically tests the fix for issue #14993 _filePatternParser.GetMatchingFiles("C:/Users/someUser/Desktop/a/c/*bc.dll"); @@ -127,8 +127,8 @@ public void FilePatternParserShouldCorrectlySplitPatternAndDirectoryWithForwardS // Assert that the pattern is parsed correctly _mockMatcherHelper.Verify(x => x.AddInclude("*bc.dll")); // On Windows, the path may be normalized, so we verify the key components are present - _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => - y.FullName.Contains("someUser") && y.FullName.Contains("Desktop") && + _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => + y.FullName.Contains("someUser") && y.FullName.Contains("Desktop") && y.FullName.Contains("a") && y.FullName.EndsWith("c")))); } @@ -137,14 +137,14 @@ public void FilePatternParserShouldCorrectlySplitWithArbitraryDirectoryDepthWith { var patternMatchingResult = new PatternMatchingResult(new List()); _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - + // Test with forward slashes and recursive patterns - _filePatternParser.GetMatchingFiles("C:/Users/vanidhi/**/c/*bc.txt"); + _filePatternParser.GetMatchingFiles("C:/Users/someUser/**/c/*bc.txt"); // Assert _mockMatcherHelper.Verify(x => x.AddInclude("**/c/*bc.txt")); - _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => - y.FullName.Contains("vanidhi")))); + _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => + y.FullName.Contains("someUser")))); } [TestMethod] @@ -152,14 +152,14 @@ public void FilePatternParserShouldHandleForwardSlashesWithoutThrowingException( { var patternMatchingResult = new PatternMatchingResult(new List()); _mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - + // This is the specific case from the original bug report that was throwing ArgumentOutOfRangeException // Before the fix: System.ArgumentOutOfRangeException: length ('-1') must be a non-negative value _filePatternParser.GetMatchingFiles("C:/path/to/my/tests/*_Tests.dll"); // Assert that we successfully parse without throwing and get the expected pattern _mockMatcherHelper.Verify(x => x.AddInclude("*_Tests.dll")); - _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => + _mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Contains("path") && y.FullName.Contains("tests")))); } From f67d9968a53b709ae2c1b9fb0efb8933131b2ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Thu, 17 Jul 2025 16:10:11 +0200 Subject: [PATCH 10/10] Fix tests which are windows only --- .../Internal/FilePatternParserTests.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs index c9c042e684..4c7e7e0f29 100644 --- a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs +++ b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs @@ -115,6 +115,8 @@ public void FilePatternParserShouldThrowCommandLineExceptionIfFileDoesNotExist() } [TestMethod] + // only on windows because we don't translate the path to be valid linux / mac path + [OSCondition(OperatingSystems.Windows)] public void FilePatternParserShouldCorrectlySplitPatternAndDirectoryWithForwardSlashes() { var patternMatchingResult = new PatternMatchingResult(new List()); @@ -133,6 +135,8 @@ public void FilePatternParserShouldCorrectlySplitPatternAndDirectoryWithForwardS } [TestMethod] + // only on windows because we don't translate the path to be valid linux / mac path + [OSCondition(OperatingSystems.Windows)] public void FilePatternParserShouldCorrectlySplitWithArbitraryDirectoryDepthWithForwardSlashes() { var patternMatchingResult = new PatternMatchingResult(new List()); @@ -148,6 +152,8 @@ public void FilePatternParserShouldCorrectlySplitWithArbitraryDirectoryDepthWith } [TestMethod] + // only on windows because we don't translate the path to be valid linux / mac path + [OSCondition(OperatingSystems.Windows)] public void FilePatternParserShouldHandleForwardSlashesWithoutThrowingException() { var patternMatchingResult = new PatternMatchingResult(new List());