-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using globbing pattern doesn't work on windows with forward slashes #14993
Comments
As far as it's supported by |
Yes looks like a bug. Do you want to make a fix for it? |
Sure, I can attempt a fix in the week. Thanks for the prompt reply. |
one thing to maybe look into: I think we might use the globbing package in vstest somewhere, just not here. https://www.nuget.org/packages/Microsoft.Extensions.FileSystemGlobbing So I would look if vstest.console already references that and if it has the needed functionality. |
I reproduced with absolute path only ( |
I was able to reproduce the bug with an Unit test in [TestMethod]
public void FilePatternParserShouldCorrectlySplitPatternAndDirectoryWithAlternateSeparator()
{
var patternMatchingResult = new PatternMatchingResult(new List<FilePatternMatch>());
_mockMatcherHelper.Setup(x => x.Execute(It.IsAny<DirectoryInfoWrapper>())).Returns(patternMatchingResult);
_filePatternParser.GetMatchingFiles(TranslatePath(@"C:/Users/vanidhi/Desktop/a/c/*bc.dll"));
// Assert
_mockMatcherHelper.Verify(x => x.AddInclude(TranslatePath(@"*bc.dll")));
_mockMatcherHelper.Verify(x => x.Execute(It.Is<DirectoryInfoWrapper>(y => y.FullName.Equals(TranslatePath(@"C:\Users\vanidhi\Desktop\a\c")))));
} This indeed doesn't pass with current code. For the fix, I have done the following change to the Added the following line where the fields are declared: private readonly char[] _directorySeparatorCharacters = [Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar]; And then modify line 100, where we search for the last directory separator to look like this: var directorySeparatorIndex = filePattern.Substring(0, splitOnWildCardIndex).LastIndexOfAny(_directorySeparatorCharacters); These changes fixes the previous test. I would've pushed a branch and create a pull request, but I don't seem to have the rights to. Thanks, |
@DavidVilleneuveAnsys yes you don't have permisions to write into this repository. You need to go and fork the repository first to get your own copy where you have permissions. Then you will push the branch to your fork, and then you can create the PR. It should automatically suggest our repository in the PR user interface. Let me know if you need more help making the PR. |
On windows, when calling
dotnet test C:/path/to/my/tests/*_Tests.dll
we get the following errors :This works when using backward slashes.
I think that since forward slashes work in general when doing other Windows CLI tools, or well, in
dotnet test
when not using globbing.I feel like it could be addressed by changing the
SplitFilePatternOnWildCard
to take into accountPath.AltDirectorySeparatorChar
https://learn.microsoft.com/en-us/dotnet/api/system.io.path.altdirectoryseparatorchar?view=net-9.0
That said I don't know how
Path.AltDirectorySeparatorChar
would affect other platforms?The text was updated successfully, but these errors were encountered: