From 213a399a7c748448316bd48eb281b2bfe01ec00f Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Thu, 18 Jul 2019 16:10:18 +0530 Subject: [PATCH 01/11] Support wildcard in filenames --- .../CommandLine/CommandLineOptions.cs | 32 ++++---- .../Internal/FilePatternParser.cs | 74 ++++++++++++++++++ .../Internal/Interfaces/IMatcherHelper.cs | 24 ++++++ src/vstest.console/Internal/MatcherHelper.cs | 38 ++++++++++ src/vstest.console/vstest.console.csproj | 3 + .../FilePatternParserTests.cs | 75 +++++++++++++++++++ .../Internal/FilePatternParserTests.cs | 63 ++++++++++++++++ 7 files changed, 296 insertions(+), 13 deletions(-) create mode 100644 src/vstest.console/Internal/FilePatternParser.cs create mode 100644 src/vstest.console/Internal/Interfaces/IMatcherHelper.cs create mode 100644 src/vstest.console/Internal/MatcherHelper.cs create mode 100644 test/Microsoft.TestPlatform.AcceptanceTests/FilePatternParserTests.cs create mode 100644 test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs diff --git a/src/vstest.console/CommandLine/CommandLineOptions.cs b/src/vstest.console/CommandLine/CommandLineOptions.cs index 1d0aea2f4c..8e807a4920 100644 --- a/src/vstest.console/CommandLine/CommandLineOptions.cs +++ b/src/vstest.console/CommandLine/CommandLineOptions.cs @@ -15,6 +15,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; using System.IO; + using vstest.console.Internal; /// /// Provides access to the command-line options. @@ -283,28 +284,33 @@ public void AddSource(string source) { throw new CommandLineException(CommandLineResources.CannotBeNullOrEmpty); } - + var filePatternParser = new FilePatternParser(); source = source.Trim(); - + // Convert the relative path to absolute path - if(!Path.IsPathRooted(source)) + if (!Path.IsPathRooted(source)) { source = Path.Combine(FileHelper.GetCurrentDirectory(), source); } - if (!FileHelper.Exists(source)) - { - throw new CommandLineException( - string.Format(CultureInfo.CurrentUICulture, CommandLineResources.TestSourceFileNotFound, source)); - } + var sourceFiles = filePatternParser.GetMatchingFiles(source); - if (this.sources.Contains(source, StringComparer.OrdinalIgnoreCase)) + foreach (var sourceFile in sourceFiles) { - throw new CommandLineException( - string.Format(CultureInfo.CurrentCulture, CommandLineResources.DuplicateSource, source)); - } + if (!FileHelper.Exists(sourceFile)) + { + throw new CommandLineException( + string.Format(CultureInfo.CurrentUICulture, CommandLineResources.TestSourceFileNotFound, source)); + } - this.sources.Add(source); + if (this.sources.Contains(sourceFile, StringComparer.OrdinalIgnoreCase)) + { + throw new CommandLineException( + string.Format(CultureInfo.CurrentCulture, CommandLineResources.DuplicateSource, source)); + } + + this.sources.Add(sourceFile); + } } #endregion diff --git a/src/vstest.console/Internal/FilePatternParser.cs b/src/vstest.console/Internal/FilePatternParser.cs new file mode 100644 index 0000000000..b96c3149ea --- /dev/null +++ b/src/vstest.console/Internal/FilePatternParser.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace vstest.console.Internal +{ + using Microsoft.Extensions.FileSystemGlobbing.Abstractions; + using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; + using System; + using System.Collections.Generic; + using System.IO; + using vstest.console.Internal.Interfaces; + + /// + /// Class for getting matching files from wild card pattern file name + /// Microsoft.Extensions.FileSystemGlobbing methods used to get matching file names + /// + public class FilePatternParser + { + private IMatcherHelper matcherHelper; + private char[] wildCardCharacters = { '*' }; + + public FilePatternParser() + : this(new MatcherHelper()) + { + } + + internal FilePatternParser(IMatcherHelper matcherHelper) + { + this.matcherHelper = matcherHelper; + } + + /// + /// Used to get matching files with pattern + /// + public IEnumerable GetMatchingFiles(string filePattern) + { + var matchingFiles = new List(); + if(filePattern.IndexOfAny(wildCardCharacters) == -1) + { + matchingFiles.Add(filePattern); + return matchingFiles; + } + + var splitPattern = SplitFilePatternOnWildCard(filePattern); + this.matcherHelper.AddInclude(splitPattern.Item2); + var dirinfo = new DirectoryInfoWrapper(new DirectoryInfo(splitPattern.Item1)); + var name = dirinfo.FullName; + var matches = this.matcherHelper.Execute(new DirectoryInfoWrapper(new DirectoryInfo(splitPattern.Item1))); + + foreach(var match in matches.Files) + { + matchingFiles.Add(Path.Combine(splitPattern.Item1, match.Path)); + } + + return matchingFiles; + } + + /// + /// Splits full pattern into search directory and pattern. + /// + private Tuple SplitFilePatternOnWildCard(string filePattern) + { + var splitOnWildCardIndex = filePattern.IndexOfAny(wildCardCharacters); + + var directorySeparatorIndex = filePattern.Substring(0, splitOnWildCardIndex).LastIndexOf(Path.DirectorySeparatorChar); + + string searchDir = filePattern.Substring(0, directorySeparatorIndex); + string pattern = filePattern.Substring(directorySeparatorIndex + 1); + + Tuple splitPattern = new Tuple(searchDir, pattern); + return splitPattern; + } + } +} diff --git a/src/vstest.console/Internal/Interfaces/IMatcherHelper.cs b/src/vstest.console/Internal/Interfaces/IMatcherHelper.cs new file mode 100644 index 0000000000..44bb6e4c1d --- /dev/null +++ b/src/vstest.console/Internal/Interfaces/IMatcherHelper.cs @@ -0,0 +1,24 @@ +// Copyright(c) Microsoft Corporation.All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace vstest.console.Internal.Interfaces +{ + using Microsoft.Extensions.FileSystemGlobbing; + using Microsoft.Extensions.FileSystemGlobbing.Abstractions; + + /// + /// Interface for wrapping the FileSystemGlobbing Matcher class + /// + internal interface IMatcherHelper + { + /// + /// Executes search in the given directory + /// + PatternMatchingResult Execute(DirectoryInfoWrapper directoryInfo); + + /// + /// Includes patterns to search in the matcher + /// + void AddInclude(string pattern); + } +} diff --git a/src/vstest.console/Internal/MatcherHelper.cs b/src/vstest.console/Internal/MatcherHelper.cs new file mode 100644 index 0000000000..25e1abb2ae --- /dev/null +++ b/src/vstest.console/Internal/MatcherHelper.cs @@ -0,0 +1,38 @@ +// Copyright(c) Microsoft Corporation.All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal +{ + using Microsoft.Extensions.FileSystemGlobbing; + using Microsoft.Extensions.FileSystemGlobbing.Abstractions; + using vstest.console.Internal.Interfaces; + + /// + /// Class for implementing the FileSystemGlobbing Matcher class methods + /// + internal class MatcherHelper: IMatcherHelper + { + private Matcher matcher; + + public MatcherHelper() + { + this.matcher = new Matcher(); + } + + /// + /// Executes search in the given directory + /// + public PatternMatchingResult Execute(DirectoryInfoWrapper directoryInfo) + { + return this.matcher.Execute(directoryInfo); + } + + /// + /// Includes patterns to search in the matcher + /// + public void AddInclude(string pattern) + { + this.matcher.AddInclude(pattern); + } + } +} diff --git a/src/vstest.console/vstest.console.csproj b/src/vstest.console/vstest.console.csproj index 859ace0cba..99ce500d11 100644 --- a/src/vstest.console/vstest.console.csproj +++ b/src/vstest.console/vstest.console.csproj @@ -20,6 +20,9 @@ + + + diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/FilePatternParserTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/FilePatternParserTests.cs new file mode 100644 index 0000000000..6c04cbae6f --- /dev/null +++ b/test/Microsoft.TestPlatform.AcceptanceTests/FilePatternParserTests.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information.using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Microsoft.TestPlatform.AcceptanceTests +{ + using Microsoft.VisualStudio.TestTools.UnitTesting; + using System.IO; + + [TestClass] + public class FilePatternParserTests : AcceptanceTestBase + { + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void WildCardPatternShouldCorrectlyWorkOnFiles(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + + var testAssembly = this.GetSampleTestAssembly(); + testAssembly = testAssembly.Replace("SimpleTestProject.dll", "*TestProj*.dll"); + + var arguments = PrepareArguments( + testAssembly, + this.GetTestAdapterPath(), + string.Empty, this.FrameworkArgValue, + runnerInfo.InIsolationValue); + + this.InvokeVsTest(arguments); + this.ValidateSummaryStatus(1, 1, 1); + } + + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void WildCardPatternShouldCorrectlyWorkOnArbitraryDepthDirectories(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + + var testAssembly = this.GetSampleTestAssembly(); + var oldAssemblyPath = Path.Combine("Debug", this.testEnvironment.TargetFramework, "SimpleTestProject.dll"); + var newAssemblyPath = Path.Combine("**", this.testEnvironment.TargetFramework, "*TestProj*.dll"); + testAssembly = testAssembly.Replace(oldAssemblyPath, newAssemblyPath); + + var arguments = PrepareArguments( + testAssembly, + this.GetTestAdapterPath(), + string.Empty, string.Empty, + runnerInfo.InIsolationValue); + + this.InvokeVsTest(arguments); + this.ValidateSummaryStatus(1, 1, 1); + } + + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void WildCardPatternShouldCorrectlyWorkOnMultipleFiles(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + + var testAssembly = this.BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"'); ; + testAssembly = testAssembly.Replace("SimpleTestProject.dll", "*TestProj*.dll"); + testAssembly = testAssembly.Replace("SimpleTestProject2.dll", "*TestProj*.dll"); + + var arguments = PrepareArguments( + testAssembly, + this.GetTestAdapterPath(), + string.Empty, this.FrameworkArgValue, + runnerInfo.InIsolationValue); + + this.InvokeVsTest(arguments); + this.ValidateSummaryStatus(2, 2, 2); + } + } +} diff --git a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs new file mode 100644 index 0000000000..d0cb4d617b --- /dev/null +++ b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs @@ -0,0 +1,63 @@ +// Copyright(c) Microsoft Corporation.All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace vstest.console.UnitTests.Internal +{ + using Microsoft.Extensions.FileSystemGlobbing; + using Microsoft.Extensions.FileSystemGlobbing.Abstractions; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using Moq; + using System.Collections.Generic; + using vstest.console.Internal; + using vstest.console.Internal.Interfaces; + + [TestClass] + public class FilePatternParserTests + { + private FilePatternParser filePatternParser; + private Mock mockMatcherHelper; + + [TestInitialize] + public void TestInit() + { + this.mockMatcherHelper = new Mock(); + this.filePatternParser = new FilePatternParser(this.mockMatcherHelper.Object); + } + + [TestMethod] + public void FilePatternParserShouldCorrectlySplitPatternAndDirectory() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + this.filePatternParser.GetMatchingFiles(@"C:\Users\vanidhi\Desktop\a\c\*bc.dll"); + + //Assert + this.mockMatcherHelper.Verify(x => x.AddInclude(@"*bc.dll")); + this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(@"C:\Users\vanidhi\Desktop\a\c")))); + } + + [TestMethod] + public void FilePatternParserShouldCorrectlySplitWithArbitraryDirectoryDepth() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + this.filePatternParser.GetMatchingFiles(@"C:\Users\vanidhi\**\c\*bc.txt"); + + //Assert + this.mockMatcherHelper.Verify(x => x.AddInclude(@"**\c\*bc.txt")); + this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(@"C:\Users\vanidhi")))); + } + + [TestMethod] + public void FilePatternParserShouldCorrectlySplitWithWildCardInMultipleDirectory() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + this.filePatternParser.GetMatchingFiles(@"E:\path\to\project\tests\**.Tests\**\*.Tests.dll"); + + //Assert + this.mockMatcherHelper.Verify(x => x.AddInclude(@"**.Tests\**\*.Tests.dll")); + this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(@"E:\path\to\project\tests")))); + } + } +} From 1a382e2332e437dae23535a1969f3f16bdfbabb1 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Thu, 18 Jul 2019 17:23:23 +0530 Subject: [PATCH 02/11] Update verify-nupkgs --- scripts/verify-nupkgs.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/verify-nupkgs.ps1 b/scripts/verify-nupkgs.ps1 index 0bff808d7d..e619d2eb69 100644 --- a/scripts/verify-nupkgs.ps1 +++ b/scripts/verify-nupkgs.ps1 @@ -16,7 +16,7 @@ function Verify-Nuget-Packages($packageDirectory) "Microsoft.NET.Test.Sdk" = 13; "Microsoft.TestPlatform" = 421; "Microsoft.TestPlatform.Build" = 19; - "Microsoft.TestPlatform.CLI" = 300; + "Microsoft.TestPlatform.CLI" = 301; "Microsoft.TestPlatform.Extensions.TrxLogger" = 33; "Microsoft.TestPlatform.ObjectModel" = 62; "Microsoft.TestPlatform.Portable" = 469; From 520c1732cbc78ac5b9c4cdcaf16e46374d7d2ebe Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Tue, 23 Jul 2019 15:14:17 +0530 Subject: [PATCH 03/11] Show test source files on console --- scripts/verify-nupkgs.ps1 | 2 +- .../Microsoft.TestPlatform.Portable.nuspec | 2 + .../CommandLine/CommandLineOptions.cs | 3 +- src/vstest.console/Internal/ConsoleLogger.cs | 21 +++++ .../Internal/FilePatternParser.cs | 10 ++- .../Resources/Resources.Designer.cs | 23 ++--- src/vstest.console/Resources/Resources.resx | 6 +- .../Resources/xlf/Resources.cs.xlf | 14 ++- .../Resources/xlf/Resources.de.xlf | 14 ++- .../Resources/xlf/Resources.es.xlf | 14 ++- .../Resources/xlf/Resources.fr.xlf | 14 ++- .../Resources/xlf/Resources.it.xlf | 14 ++- .../Resources/xlf/Resources.ja.xlf | 14 ++- .../Resources/xlf/Resources.ko.xlf | 14 ++- .../Resources/xlf/Resources.pl.xlf | 14 ++- .../Resources/xlf/Resources.pt-BR.xlf | 14 ++- .../Resources/xlf/Resources.ru.xlf | 14 ++- .../Resources/xlf/Resources.tr.xlf | 14 ++- .../Resources/xlf/Resources.xlf | 9 +- .../Resources/xlf/Resources.zh-Hans.xlf | 14 ++- .../Resources/xlf/Resources.zh-Hant.xlf | 14 ++- .../CommandLine/CommandLineOptionsTests.cs | 11 --- .../Internal/ConsoleLoggerTests.cs | 88 ++++++++++++++++++- 23 files changed, 205 insertions(+), 152 deletions(-) diff --git a/scripts/verify-nupkgs.ps1 b/scripts/verify-nupkgs.ps1 index e619d2eb69..2daa6c6078 100644 --- a/scripts/verify-nupkgs.ps1 +++ b/scripts/verify-nupkgs.ps1 @@ -19,7 +19,7 @@ function Verify-Nuget-Packages($packageDirectory) "Microsoft.TestPlatform.CLI" = 301; "Microsoft.TestPlatform.Extensions.TrxLogger" = 33; "Microsoft.TestPlatform.ObjectModel" = 62; - "Microsoft.TestPlatform.Portable" = 469; + "Microsoft.TestPlatform.Portable" = 471; "Microsoft.TestPlatform.TestHost" = 140; "Microsoft.TestPlatform.TranslationLayer" = 121} diff --git a/src/package/nuspec/Microsoft.TestPlatform.Portable.nuspec b/src/package/nuspec/Microsoft.TestPlatform.Portable.nuspec index a0d836efc6..12976de841 100644 --- a/src/package/nuspec/Microsoft.TestPlatform.Portable.nuspec +++ b/src/package/nuspec/Microsoft.TestPlatform.Portable.nuspec @@ -216,6 +216,7 @@ + @@ -486,6 +487,7 @@ + diff --git a/src/vstest.console/CommandLine/CommandLineOptions.cs b/src/vstest.console/CommandLine/CommandLineOptions.cs index 8e807a4920..e6963f6d57 100644 --- a/src/vstest.console/CommandLine/CommandLineOptions.cs +++ b/src/vstest.console/CommandLine/CommandLineOptions.cs @@ -305,8 +305,7 @@ public void AddSource(string source) if (this.sources.Contains(sourceFile, StringComparer.OrdinalIgnoreCase)) { - throw new CommandLineException( - string.Format(CultureInfo.CurrentCulture, CommandLineResources.DuplicateSource, source)); + continue; } this.sources.Add(sourceFile); diff --git a/src/vstest.console/Internal/ConsoleLogger.cs b/src/vstest.console/Internal/ConsoleLogger.cs index 35db258aa7..2162ec0770 100644 --- a/src/vstest.console/Internal/ConsoleLogger.cs +++ b/src/vstest.console/Internal/ConsoleLogger.cs @@ -176,6 +176,7 @@ public void Initialize(TestLoggerEvents events, string testRunDirectory) events.TestRunMessage += this.TestMessageHandler; events.TestResult += this.TestResultHandler; events.TestRunComplete += this.TestRunCompleteHandler; + events.TestRunStart += this.TestRunStartHandler; // Register for the discovery events. events.DiscoveryMessage += this.TestMessageHandler; @@ -358,6 +359,26 @@ private static void DisplayFullInformation(TestResult result) #region Event Handlers + /// + /// Called when a test run start is received + /// + private void TestRunStartHandler(object sender, TestRunStartEventArgs e) + { + ValidateArg.NotNull(sender, "sender"); + ValidateArg.NotNull(e, "e"); + + // Print all test containers. + Output.WriteLine(string.Empty, OutputLevel.Information); + Output.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestSourcesDiscovered, CommandLineOptions.Instance.Sources.Count()), OutputLevel.Information); + if (verbosityLevel == Verbosity.Detailed) + { + foreach (var source in CommandLineOptions.Instance.Sources) + { + Output.WriteLine(source, OutputLevel.Information); + } + } + } + /// /// Called when a test message is received. /// diff --git a/src/vstest.console/Internal/FilePatternParser.cs b/src/vstest.console/Internal/FilePatternParser.cs index b96c3149ea..220b448f6d 100644 --- a/src/vstest.console/Internal/FilePatternParser.cs +++ b/src/vstest.console/Internal/FilePatternParser.cs @@ -35,18 +35,22 @@ internal FilePatternParser(IMatcherHelper matcherHelper) public IEnumerable GetMatchingFiles(string filePattern) { var matchingFiles = new List(); + + // If there is no wildcard, return the filename as it is. if(filePattern.IndexOfAny(wildCardCharacters) == -1) { matchingFiles.Add(filePattern); return matchingFiles; } + // Split the given wildcard into search directory and pattern to be searched. var splitPattern = SplitFilePatternOnWildCard(filePattern); this.matcherHelper.AddInclude(splitPattern.Item2); - var dirinfo = new DirectoryInfoWrapper(new DirectoryInfo(splitPattern.Item1)); - var name = dirinfo.FullName; + + // Execute the given pattern in the search directory. var matches = this.matcherHelper.Execute(new DirectoryInfoWrapper(new DirectoryInfo(splitPattern.Item1))); + // Add all the files to the list of matching files. foreach(var match in matches.Files) { matchingFiles.Add(Path.Combine(splitPattern.Item1, match.Path)); @@ -60,8 +64,8 @@ public IEnumerable GetMatchingFiles(string filePattern) /// private Tuple SplitFilePatternOnWildCard(string filePattern) { + // Split the pattern based on first wildcard character found. var splitOnWildCardIndex = filePattern.IndexOfAny(wildCardCharacters); - var directorySeparatorIndex = filePattern.Substring(0, splitOnWildCardIndex).LastIndexOf(Path.DirectorySeparatorChar); string searchDir = filePattern.Substring(0, directorySeparatorIndex); diff --git a/src/vstest.console/Resources/Resources.Designer.cs b/src/vstest.console/Resources/Resources.Designer.cs index ac592cc5b3..319bfe8957 100644 --- a/src/vstest.console/Resources/Resources.Designer.cs +++ b/src/vstest.console/Resources/Resources.Designer.cs @@ -432,15 +432,6 @@ internal class Resources { } } - /// - /// Looks up a localized string similar to Duplicate source {0} specified.. - /// - internal static string DuplicateSource { - get { - return ResourceManager.GetString("DuplicateSource", resourceCulture); - } - } - /// /// Looks up a localized string similar to --Blame|/Blame:[CollectDump];[CollectAlways]=[Value];[DumpType]=[Value] /// Runs the test in blame mode. This option is helpful in isolating the problematic test causing test host crash. @@ -1616,7 +1607,19 @@ public static string ProgressIndicatorString return ResourceManager.GetString("TestSourceFileNotFound", resourceCulture); } } - + + /// + /// Looks up a localized string similar to A total of {0} test source files are discovered.. + /// + internal static string TestSourcesDiscovered + { + get + { + return ResourceManager.GetString("TestSourcesDiscovered", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Time elapsed :. /// diff --git a/src/vstest.console/Resources/Resources.resx b/src/vstest.console/Resources/Resources.resx index dcd46707d8..0842f18417 100644 --- a/src/vstest.console/Resources/Resources.resx +++ b/src/vstest.console/Resources/Resources.resx @@ -221,9 +221,6 @@ The parameter "{0}" should be provided only once. - - Duplicate source {0} specified. - /EnableCodeCoverage Enables data collector 'CodeCoverage' for the test run. @@ -730,4 +727,7 @@ Test run in progress + + A total of {0} test source files are discovered. + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.cs.xlf b/src/vstest.console/Resources/xlf/Resources.cs.xlf index daddd18995..53bbf97141 100644 --- a/src/vstest.console/Resources/xlf/Resources.cs.xlf +++ b/src/vstest.console/Resources/xlf/Resources.cs.xlf @@ -20,15 +20,6 @@ - - Duplicate source {0} specified. - Zadal se duplicitní zdroj {0}. - - - Doppelte Quelle {0} angegeben. - - fuzzyMatch="15" wordcount="4" adjWordcount="3.4" curWordcount="3.4" - '{0}' not found. {0} se nenašel. @@ -1653,6 +1644,11 @@ Přeskočené: {0} + + A total of {0} test source files are discovered. + A total of {0} test source files are discovered. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.de.xlf b/src/vstest.console/Resources/xlf/Resources.de.xlf index 953c18ca7d..70db2487e5 100644 --- a/src/vstest.console/Resources/xlf/Resources.de.xlf +++ b/src/vstest.console/Resources/xlf/Resources.de.xlf @@ -20,15 +20,6 @@ - - Duplicate source {0} specified. - Es wurde eine doppelte Quelle {0} angegeben. - - - Doppelte Quelle {0} angegeben. - - fuzzyMatch="15" wordcount="4" adjWordcount="3.4" curWordcount="3.4" - '{0}' not found. "{0}" wurde nicht gefunden. @@ -1653,6 +1644,11 @@ Übersprungen: {0} + + A total of {0} test source files are discovered. + A total of {0} test source files are discovered. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.es.xlf b/src/vstest.console/Resources/xlf/Resources.es.xlf index 94c4f15cb5..2eead51384 100644 --- a/src/vstest.console/Resources/xlf/Resources.es.xlf +++ b/src/vstest.console/Resources/xlf/Resources.es.xlf @@ -20,15 +20,6 @@ - - Duplicate source {0} specified. - Se ha especificado un origen duplicado ({0}). - - - Doppelte Quelle {0} angegeben. - - fuzzyMatch="15" wordcount="4" adjWordcount="3.4" curWordcount="3.4" - '{0}' not found. No se encuentra '{0}'. @@ -1655,6 +1646,11 @@ Omitido: {0} + + A total of {0} test source files are discovered. + A total of {0} test source files are discovered. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.fr.xlf b/src/vstest.console/Resources/xlf/Resources.fr.xlf index 788e5c23c8..d95f45a1d3 100644 --- a/src/vstest.console/Resources/xlf/Resources.fr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.fr.xlf @@ -20,15 +20,6 @@ - - Duplicate source {0} specified. - Source dupliquée {0} spécifiée. - - - Doppelte Quelle {0} angegeben. - - fuzzyMatch="15" wordcount="4" adjWordcount="3.4" curWordcount="3.4" - '{0}' not found. '{0}' introuvable. @@ -1653,6 +1644,11 @@ Ignoré(s) : {0} + + A total of {0} test source files are discovered. + A total of {0} test source files are discovered. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.it.xlf b/src/vstest.console/Resources/xlf/Resources.it.xlf index bb6c835e05..ecce1e1b62 100644 --- a/src/vstest.console/Resources/xlf/Resources.it.xlf +++ b/src/vstest.console/Resources/xlf/Resources.it.xlf @@ -20,15 +20,6 @@ - - Duplicate source {0} specified. - L'origine {0} specificata è duplicata. - - - Doppelte Quelle {0} angegeben. - - fuzzyMatch="15" wordcount="4" adjWordcount="3.4" curWordcount="3.4" - '{0}' not found. '{0}' non è stato trovato. @@ -1653,6 +1644,11 @@ Ignorati: {0} + + A total of {0} test source files are discovered. + A total of {0} test source files are discovered. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ja.xlf b/src/vstest.console/Resources/xlf/Resources.ja.xlf index 8511a9f746..9e622e0ea1 100644 --- a/src/vstest.console/Resources/xlf/Resources.ja.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ja.xlf @@ -20,15 +20,6 @@ - - Duplicate source {0} specified. - 重複するソース {0} が指定されています。 - - - Doppelte Quelle {0} angegeben. - - fuzzyMatch="15" wordcount="4" adjWordcount="3.4" curWordcount="3.4" - '{0}' not found. '{0}' が見つかりません。 @@ -1653,6 +1644,11 @@ スキップ: {0} + + A total of {0} test source files are discovered. + A total of {0} test source files are discovered. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ko.xlf b/src/vstest.console/Resources/xlf/Resources.ko.xlf index e3e9bc8c15..ab6b7dbf00 100644 --- a/src/vstest.console/Resources/xlf/Resources.ko.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ko.xlf @@ -20,15 +20,6 @@ - - Duplicate source {0} specified. - 중복 소스 {0}을(를) 지정했습니다. - - - Doppelte Quelle {0} angegeben. - - fuzzyMatch="15" wordcount="4" adjWordcount="3.4" curWordcount="3.4" - '{0}' not found. '{0}'을(를) 찾을 수 없습니다. @@ -1653,6 +1644,11 @@ 건너뜀: {0} + + A total of {0} test source files are discovered. + A total of {0} test source files are discovered. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.pl.xlf b/src/vstest.console/Resources/xlf/Resources.pl.xlf index 9872a4ce0f..b7555b13fd 100644 --- a/src/vstest.console/Resources/xlf/Resources.pl.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pl.xlf @@ -20,15 +20,6 @@ - - Duplicate source {0} specified. - Określono zduplikowane źródło {0}. - - - Doppelte Quelle {0} angegeben. - - fuzzyMatch="15" wordcount="4" adjWordcount="3.4" curWordcount="3.4" - '{0}' not found. Nie można odnaleźć elementu „{0}”. @@ -1653,6 +1644,11 @@ Pominięte: {0} + + A total of {0} test source files are discovered. + A total of {0} test source files are discovered. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf index 7ae7dd4987..8bb09a1011 100644 --- a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf @@ -20,15 +20,6 @@ - - Duplicate source {0} specified. - Fonte duplicada {0} especificada. - - - Doppelte Quelle {0} angegeben. - - fuzzyMatch="15" wordcount="4" adjWordcount="3.4" curWordcount="3.4" - '{0}' not found. '{0}' não encontrado. @@ -1653,6 +1644,11 @@ Altere o prefixo de nível de diagnóstico do agente de console, como mostrado a Ignorados: {0} + + A total of {0} test source files are discovered. + A total of {0} test source files are discovered. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ru.xlf b/src/vstest.console/Resources/xlf/Resources.ru.xlf index 7f87be0933..7a092e3551 100644 --- a/src/vstest.console/Resources/xlf/Resources.ru.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ru.xlf @@ -20,15 +20,6 @@ - - Duplicate source {0} specified. - Указан повторяющийся источник {0}. - - - Doppelte Quelle {0} angegeben. - - fuzzyMatch="15" wordcount="4" adjWordcount="3.4" curWordcount="3.4" - '{0}' not found. "{0}": не найдено. @@ -1653,6 +1644,11 @@ Пропущено: {0} + + A total of {0} test source files are discovered. + A total of {0} test source files are discovered. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.tr.xlf b/src/vstest.console/Resources/xlf/Resources.tr.xlf index df8b4901f5..8645c6d833 100644 --- a/src/vstest.console/Resources/xlf/Resources.tr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.tr.xlf @@ -20,15 +20,6 @@ - - Duplicate source {0} specified. - Yinelenen {0} kaynağı belirtildi. - - - Doppelte Quelle {0} angegeben. - - fuzzyMatch="15" wordcount="4" adjWordcount="3.4" curWordcount="3.4" - '{0}' not found. '{0}' bulunamadı. @@ -1653,6 +1644,11 @@ Günlükler için izleme düzeyini aşağıda gösterildiği gibi değiştirin Atlandı: {0} + + A total of {0} test source files are discovered. + A total of {0} test source files are discovered. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.xlf b/src/vstest.console/Resources/xlf/Resources.xlf index cdaa74fa6a..d79a7a31d9 100644 --- a/src/vstest.console/Resources/xlf/Resources.xlf +++ b/src/vstest.console/Resources/xlf/Resources.xlf @@ -2,10 +2,6 @@ - - Duplicate source {0} specified. - - '{0}' not found. @@ -840,6 +836,11 @@ Skipped: {0} + + A total of {0} test source files are discovered. + A total of {0} test source files are discovered. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf index 0f597fdba8..dd3fdea0bc 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf @@ -20,15 +20,6 @@ - - Duplicate source {0} specified. - 指定了重复的源 {0}。 - - - Doppelte Quelle {0} angegeben. - - fuzzyMatch="15" wordcount="4" adjWordcount="3.4" curWordcount="3.4" - '{0}' not found. 未找到“{0}”。 @@ -1652,6 +1643,11 @@ 跳过数: {0} + + A total of {0} test source files are discovered. + A total of {0} test source files are discovered. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf index 89ea9c6c11..245dc46f8b 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf @@ -20,15 +20,6 @@ - - Duplicate source {0} specified. - 指定了重複的來源 {0}。 - - - Doppelte Quelle {0} angegeben. - - fuzzyMatch="15" wordcount="4" adjWordcount="3.4" curWordcount="3.4" - '{0}' not found. 找不到 '{0}'。 @@ -1654,6 +1645,11 @@ 跳過: {0} + + A total of {0} test source files are discovered. + A total of {0} test source files are discovered. + + \ No newline at end of file diff --git a/test/vstest.console.UnitTests/CommandLine/CommandLineOptionsTests.cs b/test/vstest.console.UnitTests/CommandLine/CommandLineOptionsTests.cs index 1d7a0c5cac..0a9189e7ee 100644 --- a/test/vstest.console.UnitTests/CommandLine/CommandLineOptionsTests.cs +++ b/test/vstest.console.UnitTests/CommandLine/CommandLineOptionsTests.cs @@ -80,17 +80,6 @@ public void CommandLineOptionsAddSourceShouldThrowCommandLineExceptionForInvalid Assert.ThrowsException(() => CommandLineOptions.Instance.AddSource("DummySource")); } - [TestMethod] - public void CommandLineOptionsAddSourceShouldAddSourceThrowExceptionIfDuplicateSource() - { - var testFilePath = "C:\\DummyTestFile.txt"; - this.fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); - - CommandLineOptions.Instance.AddSource(testFilePath); - Assert.That.Throws(() => CommandLineOptions.Instance.AddSource(testFilePath)) - .WithExactMessage("Duplicate source " + testFilePath + " specified."); - } - [TestMethod] public void CommandLineOptionsAddSourceShouldAddSourceForValidSource() { diff --git a/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs b/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs index 7d17c8bb77..6c7c4a4b03 100644 --- a/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs +++ b/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs @@ -7,6 +7,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Internal using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; + using System.Linq; using System.Threading; using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; @@ -16,6 +17,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Internal using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; using Microsoft.VisualStudio.TestPlatform.Utilities; + using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; @@ -812,6 +814,90 @@ public void TestRunCompleteHandlerShouldWriteToConsoleIfTestsAbortedWithoutRunni this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.TestRunAborted, OutputLevel.Error), Times.Once()); } + [TestMethod] + public void TestRunStartHandlerShouldWriteNumberOfTestSourcesDiscoveredOnConsole() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + + var fileHelper = new Mock(); + CommandLineOptions.Instance.Reset(); + CommandLineOptions.Instance.FileHelper = fileHelper.Object; + string testFilePath = "C:\\DummyTestFile.dll"; + fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); + string testFilePath2 = "C:\\DummyTestFile2.dll"; + fileHelper.Setup(fh => fh.Exists(testFilePath2)).Returns(true); + + CommandLineOptions.Instance.AddSource(testFilePath); + + var parameters = new Dictionary(); + parameters.Add("verbosity", "normal"); + this.consoleLogger.Initialize(loggerEvents, parameters); + + var testRunStartEventArgs = new TestRunStartEventArgs(new TestRunCriteria(new List { "C:\\DummyTestFile.dll" }, 1)); + loggerEvents.RaiseTestRunStart(testRunStartEventArgs); + + this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestSourcesDiscovered, CommandLineOptions.Instance.Sources.Count()), OutputLevel.Information), Times.Once()); + } + + [TestMethod] + public void TestRunStartHandlerShouldWriteTestSourcesDiscoveredOnConsoleIfVerbosityDetailed() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + + var fileHelper = new Mock(); + CommandLineOptions.Instance.Reset(); + CommandLineOptions.Instance.FileHelper = fileHelper.Object; + string testFilePath = "C:\\DummyTestFile.dll"; + fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); + string testFilePath2 = "C:\\DummyTestFile2.dll"; + fileHelper.Setup(fh => fh.Exists(testFilePath2)).Returns(true); + + CommandLineOptions.Instance.AddSource(testFilePath); + CommandLineOptions.Instance.AddSource(testFilePath2); + + var parameters = new Dictionary(); + parameters.Add("verbosity", "detailed"); + this.consoleLogger.Initialize(loggerEvents, parameters); + + var testRunStartEventArgs = new TestRunStartEventArgs(new TestRunCriteria(new List { "C:\\DummyTestFile.dll" }, 1)); + loggerEvents.RaiseTestRunStart(testRunStartEventArgs); + + this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestSourcesDiscovered, CommandLineOptions.Instance.Sources.Count()), OutputLevel.Information), Times.Once()); + this.mockOutput.Verify(o => o.WriteLine("C:\\DummyTestFile.dll", OutputLevel.Information), Times.Once); + this.mockOutput.Verify(o => o.WriteLine("C:\\DummyTestFile2.dll", OutputLevel.Information), Times.Once); + } + + [TestMethod] + public void TestRunStartHandlerShouldNotWriteTestSourcesDiscoveredOnConsoleIfVerbosityNotDetailed() + { + var loggerEvents = new InternalTestLoggerEvents(TestSessionMessageLogger.Instance); + loggerEvents.EnableEvents(); + + var fileHelper = new Mock(); + CommandLineOptions.Instance.Reset(); + CommandLineOptions.Instance.FileHelper = fileHelper.Object; + string testFilePath = "C:\\DummyTestFile.dll"; + fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); + string testFilePath2 = "C:\\DummyTestFile2.dll"; + fileHelper.Setup(fh => fh.Exists(testFilePath2)).Returns(true); + + CommandLineOptions.Instance.AddSource(testFilePath); + CommandLineOptions.Instance.AddSource(testFilePath2); + + var parameters = new Dictionary(); + parameters.Add("verbosity", "normal"); + this.consoleLogger.Initialize(loggerEvents, parameters); + + var testRunStartEventArgs = new TestRunStartEventArgs(new TestRunCriteria(new List { "C:\\DummyTestFile.dll" }, 1)); + loggerEvents.RaiseTestRunStart(testRunStartEventArgs); + + this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestSourcesDiscovered, CommandLineOptions.Instance.Sources.Count()), OutputLevel.Information), Times.Once()); + this.mockOutput.Verify(o => o.WriteLine("C:\\DummyTestFile.dll", OutputLevel.Information), Times.Never); + this.mockOutput.Verify(o => o.WriteLine("C:\\DummyTestFile2.dll", OutputLevel.Information), Times.Never); + } + [TestMethod] public void PrintTimeHandlerShouldPrintElapsedTimeOnConsole() { @@ -882,7 +968,7 @@ public void DisplayFullInformationShouldWriteStdMessageWithNewLine() this.mockOutput.Verify(o => o.Write(PassedTestIndicator, OutputLevel.Information), Times.Once()); this.mockOutput.Verify(o => o.WriteLine("TestName", OutputLevel.Information), Times.Once()); this.mockOutput.Verify(o => o.WriteLine(" Hello", OutputLevel.Information), Times.Once()); - this.mockOutput.Verify(o => o.WriteLine(String.Empty, OutputLevel.Information), Times.Once()); + this.mockOutput.Verify(o => o.WriteLine(String.Empty, OutputLevel.Information), Times.AtLeastOnce); } [TestMethod] From ebb0fd64a490e5a4f96eabede057a55027936a84 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Wed, 24 Jul 2019 14:35:33 +0530 Subject: [PATCH 04/11] Fixing flaky ConsoleLoggerTests --- test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs b/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs index 6c7c4a4b03..4a788898f8 100644 --- a/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs +++ b/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs @@ -825,8 +825,6 @@ public void TestRunStartHandlerShouldWriteNumberOfTestSourcesDiscoveredOnConsole CommandLineOptions.Instance.FileHelper = fileHelper.Object; string testFilePath = "C:\\DummyTestFile.dll"; fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); - string testFilePath2 = "C:\\DummyTestFile2.dll"; - fileHelper.Setup(fh => fh.Exists(testFilePath2)).Returns(true); CommandLineOptions.Instance.AddSource(testFilePath); @@ -836,6 +834,7 @@ public void TestRunStartHandlerShouldWriteNumberOfTestSourcesDiscoveredOnConsole var testRunStartEventArgs = new TestRunStartEventArgs(new TestRunCriteria(new List { "C:\\DummyTestFile.dll" }, 1)); loggerEvents.RaiseTestRunStart(testRunStartEventArgs); + loggerEvents.WaitForEventCompletion(); this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestSourcesDiscovered, CommandLineOptions.Instance.Sources.Count()), OutputLevel.Information), Times.Once()); } @@ -863,6 +862,7 @@ public void TestRunStartHandlerShouldWriteTestSourcesDiscoveredOnConsoleIfVerbos var testRunStartEventArgs = new TestRunStartEventArgs(new TestRunCriteria(new List { "C:\\DummyTestFile.dll" }, 1)); loggerEvents.RaiseTestRunStart(testRunStartEventArgs); + loggerEvents.WaitForEventCompletion(); this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestSourcesDiscovered, CommandLineOptions.Instance.Sources.Count()), OutputLevel.Information), Times.Once()); this.mockOutput.Verify(o => o.WriteLine("C:\\DummyTestFile.dll", OutputLevel.Information), Times.Once); @@ -892,6 +892,7 @@ public void TestRunStartHandlerShouldNotWriteTestSourcesDiscoveredOnConsoleIfVer var testRunStartEventArgs = new TestRunStartEventArgs(new TestRunCriteria(new List { "C:\\DummyTestFile.dll" }, 1)); loggerEvents.RaiseTestRunStart(testRunStartEventArgs); + loggerEvents.WaitForEventCompletion(); this.mockOutput.Verify(o => o.WriteLine(string.Format(CultureInfo.CurrentCulture, CommandLineResources.TestSourcesDiscovered, CommandLineOptions.Instance.Sources.Count()), OutputLevel.Information), Times.Once()); this.mockOutput.Verify(o => o.WriteLine("C:\\DummyTestFile.dll", OutputLevel.Information), Times.Never); From 4725fbf72ceafd49c9066d50b58547cc0255a176 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Fri, 26 Jul 2019 15:10:28 +0530 Subject: [PATCH 05/11] Review comments addressed --- .../CommandLine/CommandLineOptions.cs | 27 ++++++--- .../Internal/FilePatternParser.cs | 33 ++++++----- .../Internal/Interfaces/IMatcherHelper.cs | 24 -------- src/vstest.console/Internal/MatcherHelper.cs | 38 ------------- src/vstest.console/Resources/Resources.resx | 7 ++- .../Resources/xlf/Resources.cs.xlf | 11 ++-- .../Resources/xlf/Resources.de.xlf | 11 ++-- .../Resources/xlf/Resources.es.xlf | 11 ++-- .../Resources/xlf/Resources.fr.xlf | 11 ++-- .../Resources/xlf/Resources.it.xlf | 11 ++-- .../Resources/xlf/Resources.ja.xlf | 11 ++-- .../Resources/xlf/Resources.ko.xlf | 11 ++-- .../Resources/xlf/Resources.pl.xlf | 11 ++-- .../Resources/xlf/Resources.pt-BR.xlf | 11 ++-- .../Resources/xlf/Resources.ru.xlf | 11 ++-- .../Resources/xlf/Resources.tr.xlf | 11 ++-- .../Resources/xlf/Resources.xlf | 7 ++- .../Resources/xlf/Resources.zh-Hans.xlf | 11 ++-- .../Resources/xlf/Resources.zh-Hant.xlf | 11 ++-- .../Internal/FilePatternParserTests.cs | 57 +++++++++++++++++-- .../RunTestsArgumentProcessorTests.cs | 2 +- 21 files changed, 176 insertions(+), 162 deletions(-) delete mode 100644 src/vstest.console/Internal/Interfaces/IMatcherHelper.cs delete mode 100644 src/vstest.console/Internal/MatcherHelper.cs diff --git a/src/vstest.console/CommandLine/CommandLineOptions.cs b/src/vstest.console/CommandLine/CommandLineOptions.cs index e6963f6d57..a20ca4778c 100644 --- a/src/vstest.console/CommandLine/CommandLineOptions.cs +++ b/src/vstest.console/CommandLine/CommandLineOptions.cs @@ -284,7 +284,7 @@ public void AddSource(string source) { throw new CommandLineException(CommandLineResources.CannotBeNullOrEmpty); } - var filePatternParser = new FilePatternParser(); + source = source.Trim(); // Convert the relative path to absolute path @@ -293,22 +293,35 @@ public void AddSource(string source) source = Path.Combine(FileHelper.GetCurrentDirectory(), source); } - var sourceFiles = filePatternParser.GetMatchingFiles(source); + var filePatternParser = new FilePatternParser(); + var sourceFiles = new List(); + var isValidPattern = filePatternParser.IsValidPattern(source, out sourceFiles); - foreach (var sourceFile in sourceFiles) + // If the given file is a full path and not a pattern + if (!isValidPattern) { - if (!FileHelper.Exists(sourceFile)) + if (!FileHelper.Exists(source)) { throw new CommandLineException( string.Format(CultureInfo.CurrentUICulture, CommandLineResources.TestSourceFileNotFound, source)); } - if (this.sources.Contains(sourceFile, StringComparer.OrdinalIgnoreCase)) + if (!this.sources.Contains(source, StringComparer.OrdinalIgnoreCase)) { - continue; + this.sources.Add(source); } + } + else + { + foreach (var sourceFile in sourceFiles) + { + if (this.sources.Contains(sourceFile, StringComparer.OrdinalIgnoreCase)) + { + continue; + } - this.sources.Add(sourceFile); + this.sources.Add(sourceFile); + } } } diff --git a/src/vstest.console/Internal/FilePatternParser.cs b/src/vstest.console/Internal/FilePatternParser.cs index 220b448f6d..de57e9ec2b 100644 --- a/src/vstest.console/Internal/FilePatternParser.cs +++ b/src/vstest.console/Internal/FilePatternParser.cs @@ -3,12 +3,12 @@ namespace vstest.console.Internal { + using Microsoft.Extensions.FileSystemGlobbing; using Microsoft.Extensions.FileSystemGlobbing.Abstractions; - using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; + using Microsoft.VisualStudio.TestPlatform.ObjectModel; using System; using System.Collections.Generic; using System.IO; - using vstest.console.Internal.Interfaces; /// /// Class for getting matching files from wild card pattern file name @@ -16,47 +16,50 @@ namespace vstest.console.Internal /// public class FilePatternParser { - private IMatcherHelper matcherHelper; + private Matcher matcher; private char[] wildCardCharacters = { '*' }; public FilePatternParser() - : this(new MatcherHelper()) + : this(new Matcher()) { } - internal FilePatternParser(IMatcherHelper matcherHelper) + internal FilePatternParser(Matcher matcher) { - this.matcherHelper = matcherHelper; + this.matcher = matcher; } /// /// Used to get matching files with pattern /// - public IEnumerable GetMatchingFiles(string filePattern) + /// If the file is a valid pattern or full path. Returns true if it is valid pattern + public bool IsValidPattern(string filePattern, out List matchingFiles) { - var matchingFiles = new List(); + matchingFiles = new List(); - // If there is no wildcard, return the filename as it is. + // If there is no wildcard, return false. if(filePattern.IndexOfAny(wildCardCharacters) == -1) { - matchingFiles.Add(filePattern); - return matchingFiles; + EqtTrace.Info($"FilePatternParser: The given file {filePattern} is a full path."); + return false; } // Split the given wildcard into search directory and pattern to be searched. var splitPattern = SplitFilePatternOnWildCard(filePattern); - this.matcherHelper.AddInclude(splitPattern.Item2); + EqtTrace.Info($"FilePatternParser: Matching file pattern '{splitPattern.Item2}' within directory '{splitPattern.Item1}'"); + + this.matcher.AddInclude(splitPattern.Item2); // Execute the given pattern in the search directory. - var matches = this.matcherHelper.Execute(new DirectoryInfoWrapper(new DirectoryInfo(splitPattern.Item1))); + var matches = this.matcher.Execute(new DirectoryInfoWrapper(new DirectoryInfo(splitPattern.Item1))); // Add all the files to the list of matching files. - foreach(var match in matches.Files) + foreach (var match in matches.Files) { matchingFiles.Add(Path.Combine(splitPattern.Item1, match.Path)); } - return matchingFiles; + return true; } /// diff --git a/src/vstest.console/Internal/Interfaces/IMatcherHelper.cs b/src/vstest.console/Internal/Interfaces/IMatcherHelper.cs deleted file mode 100644 index 44bb6e4c1d..0000000000 --- a/src/vstest.console/Internal/Interfaces/IMatcherHelper.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright(c) Microsoft Corporation.All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace vstest.console.Internal.Interfaces -{ - using Microsoft.Extensions.FileSystemGlobbing; - using Microsoft.Extensions.FileSystemGlobbing.Abstractions; - - /// - /// Interface for wrapping the FileSystemGlobbing Matcher class - /// - internal interface IMatcherHelper - { - /// - /// Executes search in the given directory - /// - PatternMatchingResult Execute(DirectoryInfoWrapper directoryInfo); - - /// - /// Includes patterns to search in the matcher - /// - void AddInclude(string pattern); - } -} diff --git a/src/vstest.console/Internal/MatcherHelper.cs b/src/vstest.console/Internal/MatcherHelper.cs deleted file mode 100644 index 25e1abb2ae..0000000000 --- a/src/vstest.console/Internal/MatcherHelper.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright(c) Microsoft Corporation.All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal -{ - using Microsoft.Extensions.FileSystemGlobbing; - using Microsoft.Extensions.FileSystemGlobbing.Abstractions; - using vstest.console.Internal.Interfaces; - - /// - /// Class for implementing the FileSystemGlobbing Matcher class methods - /// - internal class MatcherHelper: IMatcherHelper - { - private Matcher matcher; - - public MatcherHelper() - { - this.matcher = new Matcher(); - } - - /// - /// Executes search in the given directory - /// - public PatternMatchingResult Execute(DirectoryInfoWrapper directoryInfo) - { - return this.matcher.Execute(directoryInfo); - } - - /// - /// Includes patterns to search in the matcher - /// - public void AddInclude(string pattern) - { - this.matcher.AddInclude(pattern); - } - } -} diff --git a/src/vstest.console/Resources/Resources.resx b/src/vstest.console/Resources/Resources.resx index 0842f18417..24dbe39952 100644 --- a/src/vstest.console/Resources/Resources.resx +++ b/src/vstest.console/Resources/Resources.resx @@ -483,10 +483,11 @@ [TestFileNames] - Run tests from the specified files. Separate multiple test file names + Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern by spaces. Examples: mytestproject.dll - mytestproject.dll myothertestproject.exe + mytestproject.dll myothertestproject.exe + e:\code\**\*testproject.dll mytestproject.dll , @@ -728,6 +729,6 @@ Test run in progress - A total of {0} test source files are discovered. + A total of {0} test source files are matched with the specified files/pattern. \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.cs.xlf b/src/vstest.console/Resources/xlf/Resources.cs.xlf index 53bbf97141..6deaef7cae 100644 --- a/src/vstest.console/Resources/xlf/Resources.cs.xlf +++ b/src/vstest.console/Resources/xlf/Resources.cs.xlf @@ -290,16 +290,17 @@ [TestFileNames] - Run tests from the specified files. Separate multiple test file names + Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern by spaces. Examples: mytestproject.dll - mytestproject.dll myothertestproject.exe - [TestFileNames] + mytestproject.dll myothertestproject.exe + e:\code\**\*testproject.dll mytestproject.dll + [TestFileNames] Spustí testy ze zadaných souborů. Pokud máte názvů souborů více, oddělte je mezerami. Příklad: mytestproject.dll mytestproject.dll myothertestproject.exe - + [TestFileNames] Führen Sie Tests aus den angegebenen Dateien. Trennen Sie mehrere Test-Dateinamen @@ -1645,7 +1646,7 @@ - A total of {0} test source files are discovered. + A total of {0} test source files are matched with the specified files/pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.de.xlf b/src/vstest.console/Resources/xlf/Resources.de.xlf index 70db2487e5..2d91f27379 100644 --- a/src/vstest.console/Resources/xlf/Resources.de.xlf +++ b/src/vstest.console/Resources/xlf/Resources.de.xlf @@ -290,16 +290,17 @@ [TestFileNames] - Run tests from the specified files. Separate multiple test file names + Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern by spaces. Examples: mytestproject.dll - mytestproject.dll myothertestproject.exe - [TestFileNames] + mytestproject.dll myothertestproject.exe + e:\code\**\*testproject.dll mytestproject.dll + [TestFileNames] Führt Tests aus den angegebenen Dateien aus. Trennen Sie mehrere Testdateinamen durch Leerzeichen. Beispiele: mytestproject.dll mytestproject.dll myothertestproject.exe - + [TestFileNames] Führen Sie Tests aus den angegebenen Dateien. Trennen Sie mehrere Test-Dateinamen @@ -1645,7 +1646,7 @@ - A total of {0} test source files are discovered. + A total of {0} test source files are matched with the specified files/pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.es.xlf b/src/vstest.console/Resources/xlf/Resources.es.xlf index 2eead51384..a9f608b0e7 100644 --- a/src/vstest.console/Resources/xlf/Resources.es.xlf +++ b/src/vstest.console/Resources/xlf/Resources.es.xlf @@ -290,16 +290,17 @@ [TestFileNames] - Run tests from the specified files. Separate multiple test file names + Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern by spaces. Examples: mytestproject.dll - mytestproject.dll myothertestproject.exe - [NombresDeArchivosDePrueba] + mytestproject.dll myothertestproject.exe + e:\code\**\*testproject.dll mytestproject.dll + [NombresDeArchivosDePrueba] Ejecutar pruebas de los archivos especificados. Separe varios nombres de archivo con espacios. Ejemplos: mytestproject.dll mytestproject.dll myothertestproject.exe - + [TestFileNames] Führen Sie Tests aus den angegebenen Dateien. Trennen Sie mehrere Test-Dateinamen @@ -1647,7 +1648,7 @@ - A total of {0} test source files are discovered. + A total of {0} test source files are matched with the specified files/pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.fr.xlf b/src/vstest.console/Resources/xlf/Resources.fr.xlf index d95f45a1d3..ff4be987a9 100644 --- a/src/vstest.console/Resources/xlf/Resources.fr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.fr.xlf @@ -290,16 +290,17 @@ [TestFileNames] - Run tests from the specified files. Separate multiple test file names + Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern by spaces. Examples: mytestproject.dll - mytestproject.dll myothertestproject.exe - [TestFileNames] + mytestproject.dll myothertestproject.exe + e:\code\**\*testproject.dll mytestproject.dll + [TestFileNames] Exécutez les tests à partir des fichiers spécifiés. Séparez plusieurs noms de fichiers de test par des espaces. Exemples : mytestproject.dll mytestproject.dll myothertestproject.exe - + [TestFileNames] Führen Sie Tests aus den angegebenen Dateien. Trennen Sie mehrere Test-Dateinamen @@ -1645,7 +1646,7 @@ - A total of {0} test source files are discovered. + A total of {0} test source files are matched with the specified files/pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.it.xlf b/src/vstest.console/Resources/xlf/Resources.it.xlf index ecce1e1b62..8ca5a48893 100644 --- a/src/vstest.console/Resources/xlf/Resources.it.xlf +++ b/src/vstest.console/Resources/xlf/Resources.it.xlf @@ -290,16 +290,17 @@ [TestFileNames] - Run tests from the specified files. Separate multiple test file names + Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern by spaces. Examples: mytestproject.dll - mytestproject.dll myothertestproject.exe - [NomiFileTest] + mytestproject.dll myothertestproject.exe + e:\code\**\*testproject.dll mytestproject.dll + [NomiFileTest] Esegue test dai file specificati. Separare più nomi di file di test con spazi. Esempi: mytestproject.dll mytestproject.dll myothertestproject.exe - + [TestFileNames] Führen Sie Tests aus den angegebenen Dateien. Trennen Sie mehrere Test-Dateinamen @@ -1645,7 +1646,7 @@ - A total of {0} test source files are discovered. + A total of {0} test source files are matched with the specified files/pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.ja.xlf b/src/vstest.console/Resources/xlf/Resources.ja.xlf index 9e622e0ea1..20a77bfdfe 100644 --- a/src/vstest.console/Resources/xlf/Resources.ja.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ja.xlf @@ -290,16 +290,17 @@ [TestFileNames] - Run tests from the specified files. Separate multiple test file names + Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern by spaces. Examples: mytestproject.dll - mytestproject.dll myothertestproject.exe - [テストファイル名] + mytestproject.dll myothertestproject.exe + e:\code\**\*testproject.dll mytestproject.dll + [テストファイル名] 指定されたファイルからテストを実行します。複数のテスト ファイルがある場合は、 名前をスペースで区切ってください。 例: mytestproject.dll mytestproject.dll myothertestproject.exe - + [TestFileNames] Führen Sie Tests aus den angegebenen Dateien. Trennen Sie mehrere Test-Dateinamen @@ -1645,7 +1646,7 @@ - A total of {0} test source files are discovered. + A total of {0} test source files are matched with the specified files/pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.ko.xlf b/src/vstest.console/Resources/xlf/Resources.ko.xlf index ab6b7dbf00..9d5775a062 100644 --- a/src/vstest.console/Resources/xlf/Resources.ko.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ko.xlf @@ -290,16 +290,17 @@ [TestFileNames] - Run tests from the specified files. Separate multiple test file names + Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern by spaces. Examples: mytestproject.dll - mytestproject.dll myothertestproject.exe - [TestFileNames] + mytestproject.dll myothertestproject.exe + e:\code\**\*testproject.dll mytestproject.dll + [TestFileNames] 지정한 파일에서 테스트를 실행합니다. 테스트 파일 이름이 여러 개이면 공백으로 구분합니다. 예: mytestproject.dll mytestproject.dll myothertestproject.exe - + [TestFileNames] Führen Sie Tests aus den angegebenen Dateien. Trennen Sie mehrere Test-Dateinamen @@ -1645,7 +1646,7 @@ - A total of {0} test source files are discovered. + A total of {0} test source files are matched with the specified files/pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.pl.xlf b/src/vstest.console/Resources/xlf/Resources.pl.xlf index b7555b13fd..9d7173eb1f 100644 --- a/src/vstest.console/Resources/xlf/Resources.pl.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pl.xlf @@ -290,16 +290,17 @@ [TestFileNames] - Run tests from the specified files. Separate multiple test file names + Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern by spaces. Examples: mytestproject.dll - mytestproject.dll myothertestproject.exe - [TestFileNames] + mytestproject.dll myothertestproject.exe + e:\code\**\*testproject.dll mytestproject.dll + [TestFileNames] Uruchamia testy z określonych plików. Oddziel wiele nazw plików testowych spacjami. Przykłady: mojProjektTestowy.dll mojProjektTestowy.dll mojInnyProjektTestowy.exe - + [TestFileNames] Führen Sie Tests aus den angegebenen Dateien. Trennen Sie mehrere Test-Dateinamen @@ -1645,7 +1646,7 @@ - A total of {0} test source files are discovered. + A total of {0} test source files are matched with the specified files/pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf index 8bb09a1011..6de1bb1e48 100644 --- a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf @@ -290,16 +290,17 @@ Altere o prefixo de nível de diagnóstico do agente de console, como mostrado a [TestFileNames] - Run tests from the specified files. Separate multiple test file names + Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern by spaces. Examples: mytestproject.dll - mytestproject.dll myothertestproject.exe - [TestFileNames] + mytestproject.dll myothertestproject.exe + e:\code\**\*testproject.dll mytestproject.dll + [TestFileNames] Executar testes dos arquivos especificados. Use espaços para separar vários nomes de arquivo de teste. Exemplos: mytestproject.dll mytestproject.dll myothertestproject.exe - + [TestFileNames] Führen Sie Tests aus den angegebenen Dateien. Trennen Sie mehrere Test-Dateinamen @@ -1645,7 +1646,7 @@ Altere o prefixo de nível de diagnóstico do agente de console, como mostrado a - A total of {0} test source files are discovered. + A total of {0} test source files are matched with the specified files/pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.ru.xlf b/src/vstest.console/Resources/xlf/Resources.ru.xlf index 7a092e3551..9b3618bdff 100644 --- a/src/vstest.console/Resources/xlf/Resources.ru.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ru.xlf @@ -290,16 +290,17 @@ [TestFileNames] - Run tests from the specified files. Separate multiple test file names + Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern by spaces. Examples: mytestproject.dll - mytestproject.dll myothertestproject.exe - [TestFileNames] + mytestproject.dll myothertestproject.exe + e:\code\**\*testproject.dll mytestproject.dll + [TestFileNames] Выполнение тестов из указанных файлов. При вводе нескольких имен файла теста они разделяются пробелами. Примеры: mytestproject.dll mytestproject.dll myothertestproject.exe - + [TestFileNames] Führen Sie Tests aus den angegebenen Dateien. Trennen Sie mehrere Test-Dateinamen @@ -1645,7 +1646,7 @@ - A total of {0} test source files are discovered. + A total of {0} test source files are matched with the specified files/pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.tr.xlf b/src/vstest.console/Resources/xlf/Resources.tr.xlf index 8645c6d833..3e4a5b8471 100644 --- a/src/vstest.console/Resources/xlf/Resources.tr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.tr.xlf @@ -290,16 +290,17 @@ [TestFileNames] - Run tests from the specified files. Separate multiple test file names + Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern by spaces. Examples: mytestproject.dll - mytestproject.dll myothertestproject.exe - [TestFileNames] + mytestproject.dll myothertestproject.exe + e:\code\**\*testproject.dll mytestproject.dll + [TestFileNames] Belirtilen dosyalardan testleri çalıştırır. Birden fazla test dosyası adını boşlukla ayırın. Örnekler: mytestproject.dll mytestproject.dll myothertestproject.exe - + [TestFileNames] Führen Sie Tests aus den angegebenen Dateien. Trennen Sie mehrere Test-Dateinamen @@ -1645,7 +1646,7 @@ Günlükler için izleme düzeyini aşağıda gösterildiği gibi değiştirin - A total of {0} test source files are discovered. + A total of {0} test source files are matched with the specified files/pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.xlf b/src/vstest.console/Resources/xlf/Resources.xlf index d79a7a31d9..b669422ecf 100644 --- a/src/vstest.console/Resources/xlf/Resources.xlf +++ b/src/vstest.console/Resources/xlf/Resources.xlf @@ -120,10 +120,11 @@ [TestFileNames] - Run tests from the specified files. Separate multiple test file names + Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern by spaces. Examples: mytestproject.dll - mytestproject.dll myothertestproject.exe + mytestproject.dll myothertestproject.exe + e:\code\**\*testproject.dll mytestproject.dll @@ -837,7 +838,7 @@ - A total of {0} test source files are discovered. + A total of {0} test source files are matched with the specified files/pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf index dd3fdea0bc..f92c6846cc 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf @@ -289,16 +289,17 @@ [TestFileNames] - Run tests from the specified files. Separate multiple test file names + Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern by spaces. Examples: mytestproject.dll - mytestproject.dll myothertestproject.exe - [TestFileNames] + mytestproject.dll myothertestproject.exe + e:\code\**\*testproject.dll mytestproject.dll + [TestFileNames] 从指定文件运行测试。使用空格分隔多个测试文件 名称。 实例: mytestproject.dll mytestproject.dll myothertestproject.exe - + [TestFileNames] Führen Sie Tests aus den angegebenen Dateien. Trennen Sie mehrere Test-Dateinamen @@ -1644,7 +1645,7 @@ - A total of {0} test source files are discovered. + A total of {0} test source files are matched with the specified files/pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf index 245dc46f8b..b556de91b3 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf @@ -291,16 +291,17 @@ [TestFileNames] - Run tests from the specified files. Separate multiple test file names + Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern by spaces. Examples: mytestproject.dll - mytestproject.dll myothertestproject.exe - [TestFileNames] + mytestproject.dll myothertestproject.exe + e:\code\**\*testproject.dll mytestproject.dll + [TestFileNames] 從指定的檔案執行測試。請以空格分隔多個 測試檔案名稱。 範例: mytestproject.dll mytestproject.dll myothertestproject.exe - + [TestFileNames] Führen Sie Tests aus den angegebenen Dateien. Trennen Sie mehrere Test-Dateinamen @@ -1646,7 +1647,7 @@ - A total of {0} test source files are discovered. + A total of {0} test source files are matched with the specified files/pattern. A total of {0} test source files are discovered. diff --git a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs index d0cb4d617b..1ed0fea059 100644 --- a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs +++ b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs @@ -9,18 +9,17 @@ namespace vstest.console.UnitTests.Internal using Moq; using System.Collections.Generic; using vstest.console.Internal; - using vstest.console.Internal.Interfaces; [TestClass] public class FilePatternParserTests { private FilePatternParser filePatternParser; - private Mock mockMatcherHelper; + private Mock mockMatcherHelper; [TestInitialize] public void TestInit() { - this.mockMatcherHelper = new Mock(); + this.mockMatcherHelper = new Mock(); this.filePatternParser = new FilePatternParser(this.mockMatcherHelper.Object); } @@ -28,10 +27,12 @@ public void TestInit() public void FilePatternParserShouldCorrectlySplitPatternAndDirectory() { var patternMatchingResult = new PatternMatchingResult(new List()); + var sourceFiles = new List(); this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - this.filePatternParser.GetMatchingFiles(@"C:\Users\vanidhi\Desktop\a\c\*bc.dll"); + var isValidPattern = this.filePatternParser.IsValidPattern(@"C:\Users\vanidhi\Desktop\a\c\*bc.dll", out sourceFiles); //Assert + Assert.IsTrue(isValidPattern); this.mockMatcherHelper.Verify(x => x.AddInclude(@"*bc.dll")); this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(@"C:\Users\vanidhi\Desktop\a\c")))); } @@ -40,10 +41,12 @@ public void FilePatternParserShouldCorrectlySplitPatternAndDirectory() public void FilePatternParserShouldCorrectlySplitWithArbitraryDirectoryDepth() { var patternMatchingResult = new PatternMatchingResult(new List()); + var sourceFiles = new List(); this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - this.filePatternParser.GetMatchingFiles(@"C:\Users\vanidhi\**\c\*bc.txt"); + var isValidPattern = this.filePatternParser.IsValidPattern(@"C:\Users\vanidhi\**\c\*bc.txt", out sourceFiles); //Assert + Assert.IsTrue(isValidPattern); this.mockMatcherHelper.Verify(x => x.AddInclude(@"**\c\*bc.txt")); this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(@"C:\Users\vanidhi")))); } @@ -52,12 +55,54 @@ public void FilePatternParserShouldCorrectlySplitWithArbitraryDirectoryDepth() public void FilePatternParserShouldCorrectlySplitWithWildCardInMultipleDirectory() { var patternMatchingResult = new PatternMatchingResult(new List()); + var sourceFiles = new List(); this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - this.filePatternParser.GetMatchingFiles(@"E:\path\to\project\tests\**.Tests\**\*.Tests.dll"); + var isValidPattern = this.filePatternParser.IsValidPattern(@"E:\path\to\project\tests\**.Tests\**\*.Tests.dll", out sourceFiles); //Assert + Assert.IsTrue(isValidPattern); this.mockMatcherHelper.Verify(x => x.AddInclude(@"**.Tests\**\*.Tests.dll")); this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(@"E:\path\to\project\tests")))); } + + [TestMethod] + public void FilePatternParserShouldCorrectlySplitWithMultpleWildCardInPattern() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + var sourceFiles = new List(); + this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + var isValidPattern = this.filePatternParser.IsValidPattern(@"E:\path\to\project\tests\Tests*.Blame*.dll", out sourceFiles); + + //Assert + Assert.IsTrue(isValidPattern); + this.mockMatcherHelper.Verify(x => x.AddInclude(@"Tests*.Blame*.dll")); + this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(@"E:\path\to\project\tests")))); + } + + [TestMethod] + public void FilePatternParserShouldCorrectlySplitWithMultpleWildCardInMultipleDirectory() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + var sourceFiles = new List(); + this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + var isValidPattern = this.filePatternParser.IsValidPattern(@"E:\path\to\project\*tests\Tests*.Blame*.dll", out sourceFiles); + + //Assert + Assert.IsTrue(isValidPattern); + this.mockMatcherHelper.Verify(x => x.AddInclude(@"*tests\Tests*.Blame*.dll")); + this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(@"E:\path\to\project")))); + } + + [TestMethod] + public void IsValidPatternShouldReturnFalseForAbsoluteSourcePath() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + var sourceFiles = new List(); + this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + var isValidPattern = this.filePatternParser.IsValidPattern(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll", out sourceFiles); + + //Assert + Assert.IsFalse(isValidPattern); + } } } diff --git a/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs index 61cd561cbf..a4d6097d98 100644 --- a/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs @@ -83,7 +83,7 @@ public void CapabilitiesShouldReturnAppropriateProperties() { RunTestsArgumentProcessorCapabilities capabilities = new RunTestsArgumentProcessorCapabilities(); Assert.AreEqual("/RunTests", capabilities.CommandName); - Assert.AreEqual("[TestFileNames]" + Environment.NewLine + " Run tests from the specified files. Separate multiple test file names" + Environment.NewLine + " by spaces." + Environment.NewLine + " Examples: mytestproject.dll" + Environment.NewLine + " mytestproject.dll myothertestproject.exe", capabilities.HelpContentResourceName); + Assert.AreEqual("[TestFileNames]" + Environment.NewLine + " Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern" + Environment.NewLine + " by spaces." + Environment.NewLine + " Examples: mytestproject.dll" + Environment.NewLine + " mytestproject.dll myothertestproject.exe" + Environment.NewLine + @" e:\code\**\*testproject.dll mytestproject.dll", capabilities.HelpContentResourceName); Assert.AreEqual(HelpContentPriority.RunTestsArgumentProcessorHelpPriority, capabilities.HelpPriority); Assert.AreEqual(true, capabilities.IsAction); From 024860d2dd7f415215201b4939fedfcd9d772dc7 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Fri, 26 Jul 2019 17:09:18 +0530 Subject: [PATCH 06/11] Adding tests --- scripts/build/TestPlatform.Dependencies.props | 1 + src/vstest.console/vstest.console.csproj | 4 +++- .../CommandLine/CommandLineOptionsTests.cs | 23 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/scripts/build/TestPlatform.Dependencies.props b/scripts/build/TestPlatform.Dependencies.props index 30fcabab0e..04a239235d 100644 --- a/scripts/build/TestPlatform.Dependencies.props +++ b/scripts/build/TestPlatform.Dependencies.props @@ -19,6 +19,7 @@ 3.8.0 4.3.7 + 1.1.1 9.0.1 4.7.63 diff --git a/src/vstest.console/vstest.console.csproj b/src/vstest.console/vstest.console.csproj index 99ce500d11..6843aaf587 100644 --- a/src/vstest.console/vstest.console.csproj +++ b/src/vstest.console/vstest.console.csproj @@ -21,7 +21,9 @@ - + + $(FileSystemGlobbingVersion) + diff --git a/test/vstest.console.UnitTests/CommandLine/CommandLineOptionsTests.cs b/test/vstest.console.UnitTests/CommandLine/CommandLineOptionsTests.cs index 0a9189e7ee..5cce8a278f 100644 --- a/test/vstest.console.UnitTests/CommandLine/CommandLineOptionsTests.cs +++ b/test/vstest.console.UnitTests/CommandLine/CommandLineOptionsTests.cs @@ -90,5 +90,28 @@ public void CommandLineOptionsAddSourceShouldAddSourceForValidSource() Assert.IsTrue(CommandLineOptions.Instance.Sources.Contains(testFilePath)); } + + [TestMethod] + public void CommandLineOptionsShouldCheckIfFileExistesIfFilePathDoesNotContainPattern() + { + string testFilePath = "C:\\DummyTestFile.txt"; + this.fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); + + CommandLineOptions.Instance.AddSource(testFilePath); + + this.fileHelper.Verify(x => x.Exists("C:\\DummyTestFile.txt"), Times.Once); + Assert.IsTrue(CommandLineOptions.Instance.Sources.Contains(testFilePath)); + } + + [TestMethod] + public void CommandLineOptionsShouldCheckIfFileExistesIfFilePathContainsPattern() + { + string testFilePath = "C:\\Folder1\\Folder*\\DummyTestFile.txt"; + this.fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); + + CommandLineOptions.Instance.AddSource(testFilePath); + + this.fileHelper.Verify(x => x.Exists(It.IsAny()), Times.Never); + } } } From 9b75e67b95c96c9f04bff8bd690f821598e6e5d5 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Fri, 26 Jul 2019 21:25:31 +0530 Subject: [PATCH 07/11] Review comments --- .../CommandLine/CommandLineOptions.cs | 32 ++++++++++--------- src/vstest.console/Resources/Resources.resx | 6 ++-- .../Resources/xlf/Resources.cs.xlf | 6 ++-- .../Resources/xlf/Resources.de.xlf | 6 ++-- .../Resources/xlf/Resources.es.xlf | 6 ++-- .../Resources/xlf/Resources.fr.xlf | 6 ++-- .../Resources/xlf/Resources.it.xlf | 6 ++-- .../Resources/xlf/Resources.ja.xlf | 6 ++-- .../Resources/xlf/Resources.ko.xlf | 6 ++-- .../Resources/xlf/Resources.pl.xlf | 6 ++-- .../Resources/xlf/Resources.pt-BR.xlf | 6 ++-- .../Resources/xlf/Resources.ru.xlf | 6 ++-- .../Resources/xlf/Resources.tr.xlf | 6 ++-- .../Resources/xlf/Resources.xlf | 6 ++-- .../Resources/xlf/Resources.zh-Hans.xlf | 6 ++-- .../Resources/xlf/Resources.zh-Hant.xlf | 6 ++-- .../FilePatternParserTests.cs | 28 ++++++++++++++++ .../RunTestsArgumentProcessorTests.cs | 2 +- 18 files changed, 91 insertions(+), 61 deletions(-) diff --git a/src/vstest.console/CommandLine/CommandLineOptions.cs b/src/vstest.console/CommandLine/CommandLineOptions.cs index a20ca4778c..bb44d3e7be 100644 --- a/src/vstest.console/CommandLine/CommandLineOptions.cs +++ b/src/vstest.console/CommandLine/CommandLineOptions.cs @@ -297,21 +297,8 @@ public void AddSource(string source) var sourceFiles = new List(); var isValidPattern = filePatternParser.IsValidPattern(source, out sourceFiles); - // If the given file is a full path and not a pattern - if (!isValidPattern) - { - if (!FileHelper.Exists(source)) - { - throw new CommandLineException( - string.Format(CultureInfo.CurrentUICulture, CommandLineResources.TestSourceFileNotFound, source)); - } - - if (!this.sources.Contains(source, StringComparer.OrdinalIgnoreCase)) - { - this.sources.Add(source); - } - } - else + // If the given file is a valid pattern + if (isValidPattern) { foreach (var sourceFile in sourceFiles) { @@ -322,6 +309,21 @@ public void AddSource(string source) this.sources.Add(sourceFile); } + + return; + } + + // If the given file is not a pattern, check if it exists. + if (!FileHelper.Exists(source)) + { + throw new CommandLineException( + string.Format(CultureInfo.CurrentUICulture, CommandLineResources.TestSourceFileNotFound, source)); + } + + // Add the file to the source list if not already present. + if (!this.sources.Contains(source, StringComparer.OrdinalIgnoreCase)) + { + this.sources.Add(source); } } diff --git a/src/vstest.console/Resources/Resources.resx b/src/vstest.console/Resources/Resources.resx index 24dbe39952..f701775aa4 100644 --- a/src/vstest.console/Resources/Resources.resx +++ b/src/vstest.console/Resources/Resources.resx @@ -484,10 +484,10 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. + by spaces. Use detailed verbosity to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe - e:\code\**\*testproject.dll mytestproject.dll + testproject*.dll my*project.dll , @@ -729,6 +729,6 @@ Test run in progress - A total of {0} test source files are matched with the specified files/pattern. + A total of {0} test files matched the specified pattern. \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.cs.xlf b/src/vstest.console/Resources/xlf/Resources.cs.xlf index 6deaef7cae..54f222554c 100644 --- a/src/vstest.console/Resources/xlf/Resources.cs.xlf +++ b/src/vstest.console/Resources/xlf/Resources.cs.xlf @@ -291,10 +291,10 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. + by spaces. Use detailed verbosity to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe - e:\code\**\*testproject.dll mytestproject.dll + testproject*.dll my*project.dll [TestFileNames] Spustí testy ze zadaných souborů. Pokud máte názvů souborů více, oddělte je mezerami. @@ -1646,7 +1646,7 @@ - A total of {0} test source files are matched with the specified files/pattern. + A total of {0} test files matched the specified pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.de.xlf b/src/vstest.console/Resources/xlf/Resources.de.xlf index 2d91f27379..db37c0a061 100644 --- a/src/vstest.console/Resources/xlf/Resources.de.xlf +++ b/src/vstest.console/Resources/xlf/Resources.de.xlf @@ -291,10 +291,10 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. + by spaces. Use detailed verbosity to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe - e:\code\**\*testproject.dll mytestproject.dll + testproject*.dll my*project.dll [TestFileNames] Führt Tests aus den angegebenen Dateien aus. Trennen Sie mehrere Testdateinamen durch Leerzeichen. @@ -1646,7 +1646,7 @@ - A total of {0} test source files are matched with the specified files/pattern. + A total of {0} test files matched the specified pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.es.xlf b/src/vstest.console/Resources/xlf/Resources.es.xlf index a9f608b0e7..7bbf7376ab 100644 --- a/src/vstest.console/Resources/xlf/Resources.es.xlf +++ b/src/vstest.console/Resources/xlf/Resources.es.xlf @@ -291,10 +291,10 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. + by spaces. Use detailed verbosity to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe - e:\code\**\*testproject.dll mytestproject.dll + testproject*.dll my*project.dll [NombresDeArchivosDePrueba] Ejecutar pruebas de los archivos especificados. Separe varios nombres de archivo con espacios. @@ -1648,7 +1648,7 @@ - A total of {0} test source files are matched with the specified files/pattern. + A total of {0} test files matched the specified pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.fr.xlf b/src/vstest.console/Resources/xlf/Resources.fr.xlf index ff4be987a9..0efc061cb9 100644 --- a/src/vstest.console/Resources/xlf/Resources.fr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.fr.xlf @@ -291,10 +291,10 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. + by spaces. Use detailed verbosity to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe - e:\code\**\*testproject.dll mytestproject.dll + testproject*.dll my*project.dll [TestFileNames] Exécutez les tests à partir des fichiers spécifiés. Séparez plusieurs noms de fichiers de test par des espaces. @@ -1646,7 +1646,7 @@ - A total of {0} test source files are matched with the specified files/pattern. + A total of {0} test files matched the specified pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.it.xlf b/src/vstest.console/Resources/xlf/Resources.it.xlf index 8ca5a48893..01d271631c 100644 --- a/src/vstest.console/Resources/xlf/Resources.it.xlf +++ b/src/vstest.console/Resources/xlf/Resources.it.xlf @@ -291,10 +291,10 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. + by spaces. Use detailed verbosity to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe - e:\code\**\*testproject.dll mytestproject.dll + testproject*.dll my*project.dll [NomiFileTest] Esegue test dai file specificati. Separare più nomi di file di test con spazi. @@ -1646,7 +1646,7 @@ - A total of {0} test source files are matched with the specified files/pattern. + A total of {0} test files matched the specified pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.ja.xlf b/src/vstest.console/Resources/xlf/Resources.ja.xlf index 20a77bfdfe..b39a56f285 100644 --- a/src/vstest.console/Resources/xlf/Resources.ja.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ja.xlf @@ -291,10 +291,10 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. + by spaces. Use detailed verbosity to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe - e:\code\**\*testproject.dll mytestproject.dll + testproject*.dll my*project.dll [テストファイル名] 指定されたファイルからテストを実行します。複数のテスト ファイルがある場合は、 名前をスペースで区切ってください。 @@ -1646,7 +1646,7 @@ - A total of {0} test source files are matched with the specified files/pattern. + A total of {0} test files matched the specified pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.ko.xlf b/src/vstest.console/Resources/xlf/Resources.ko.xlf index 9d5775a062..2e6064df44 100644 --- a/src/vstest.console/Resources/xlf/Resources.ko.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ko.xlf @@ -291,10 +291,10 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. + by spaces. Use detailed verbosity to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe - e:\code\**\*testproject.dll mytestproject.dll + testproject*.dll my*project.dll [TestFileNames] 지정한 파일에서 테스트를 실행합니다. 테스트 파일 이름이 여러 개이면 공백으로 구분합니다. @@ -1646,7 +1646,7 @@ - A total of {0} test source files are matched with the specified files/pattern. + A total of {0} test files matched the specified pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.pl.xlf b/src/vstest.console/Resources/xlf/Resources.pl.xlf index 9d7173eb1f..b7623bb957 100644 --- a/src/vstest.console/Resources/xlf/Resources.pl.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pl.xlf @@ -291,10 +291,10 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. + by spaces. Use detailed verbosity to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe - e:\code\**\*testproject.dll mytestproject.dll + testproject*.dll my*project.dll [TestFileNames] Uruchamia testy z określonych plików. Oddziel wiele nazw plików testowych spacjami. @@ -1646,7 +1646,7 @@ - A total of {0} test source files are matched with the specified files/pattern. + A total of {0} test files matched the specified pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf index 6de1bb1e48..1f40286041 100644 --- a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf @@ -291,10 +291,10 @@ Altere o prefixo de nível de diagnóstico do agente de console, como mostrado a [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. + by spaces. Use detailed verbosity to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe - e:\code\**\*testproject.dll mytestproject.dll + testproject*.dll my*project.dll [TestFileNames] Executar testes dos arquivos especificados. Use espaços para separar vários nomes de arquivo de teste. @@ -1646,7 +1646,7 @@ Altere o prefixo de nível de diagnóstico do agente de console, como mostrado a - A total of {0} test source files are matched with the specified files/pattern. + A total of {0} test files matched the specified pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.ru.xlf b/src/vstest.console/Resources/xlf/Resources.ru.xlf index 9b3618bdff..bf80e39445 100644 --- a/src/vstest.console/Resources/xlf/Resources.ru.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ru.xlf @@ -291,10 +291,10 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. + by spaces. Use detailed verbosity to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe - e:\code\**\*testproject.dll mytestproject.dll + testproject*.dll my*project.dll [TestFileNames] Выполнение тестов из указанных файлов. При вводе нескольких имен файла теста они разделяются пробелами. @@ -1646,7 +1646,7 @@ - A total of {0} test source files are matched with the specified files/pattern. + A total of {0} test files matched the specified pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.tr.xlf b/src/vstest.console/Resources/xlf/Resources.tr.xlf index 3e4a5b8471..5ad19a3297 100644 --- a/src/vstest.console/Resources/xlf/Resources.tr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.tr.xlf @@ -291,10 +291,10 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. + by spaces. Use detailed verbosity to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe - e:\code\**\*testproject.dll mytestproject.dll + testproject*.dll my*project.dll [TestFileNames] Belirtilen dosyalardan testleri çalıştırır. Birden fazla test dosyası adını boşlukla ayırın. @@ -1646,7 +1646,7 @@ Günlükler için izleme düzeyini aşağıda gösterildiği gibi değiştirin - A total of {0} test source files are matched with the specified files/pattern. + A total of {0} test files matched the specified pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.xlf b/src/vstest.console/Resources/xlf/Resources.xlf index b669422ecf..dc53530297 100644 --- a/src/vstest.console/Resources/xlf/Resources.xlf +++ b/src/vstest.console/Resources/xlf/Resources.xlf @@ -121,10 +121,10 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. + by spaces. Use detailed verbosity to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe - e:\code\**\*testproject.dll mytestproject.dll + testproject*.dll my*project.dll @@ -838,7 +838,7 @@ - A total of {0} test source files are matched with the specified files/pattern. + A total of {0} test files matched the specified pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf index f92c6846cc..7dbade84aa 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf @@ -290,10 +290,10 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. + by spaces. Use detailed verbosity to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe - e:\code\**\*testproject.dll mytestproject.dll + testproject*.dll my*project.dll [TestFileNames] 从指定文件运行测试。使用空格分隔多个测试文件 名称。 @@ -1645,7 +1645,7 @@ - A total of {0} test source files are matched with the specified files/pattern. + A total of {0} test files matched the specified pattern. A total of {0} test source files are discovered. diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf index b556de91b3..da0a14edcb 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf @@ -292,10 +292,10 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. + by spaces. Use detailed verbosity to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe - e:\code\**\*testproject.dll mytestproject.dll + testproject*.dll my*project.dll [TestFileNames] 從指定的檔案執行測試。請以空格分隔多個 測試檔案名稱。 @@ -1647,7 +1647,7 @@ - A total of {0} test source files are matched with the specified files/pattern. + A total of {0} test files matched the specified pattern. A total of {0} test source files are discovered. diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/FilePatternParserTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/FilePatternParserTests.cs index 6c04cbae6f..403011e883 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/FilePatternParserTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/FilePatternParserTests.cs @@ -51,6 +51,34 @@ public void WildCardPatternShouldCorrectlyWorkOnArbitraryDepthDirectories(Runner this.ValidateSummaryStatus(1, 1, 1); } + [TestMethod] + [NetFullTargetFrameworkDataSource] + [NetCoreTargetFrameworkDataSource] + public void WildCardPatternShouldCorrectlyWorkForRelativeAssemblyPath(RunnerInfo runnerInfo) + { + AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); + + var testAssembly = this.GetSampleTestAssembly(); + var oldAssemblyPath = Path.Combine("Debug", this.testEnvironment.TargetFramework, "SimpleTestProject.dll"); + var newAssemblyPath = Path.Combine("**", this.testEnvironment.TargetFramework, "*TestProj*.dll"); + testAssembly = testAssembly.Replace(oldAssemblyPath, newAssemblyPath); + + var wildCardIndex = testAssembly.IndexOfAny(new char[] { '*' }); + var testAssemblyDirectory = testAssembly.Substring(0, wildCardIndex); + testAssembly = testAssembly.Substring(wildCardIndex); + + Directory.SetCurrentDirectory(testAssemblyDirectory); + + var arguments = PrepareArguments( + testAssembly, + this.GetTestAdapterPath(), + string.Empty, string.Empty, + runnerInfo.InIsolationValue); + + this.InvokeVsTest(arguments); + this.ValidateSummaryStatus(1, 1, 1); + } + [TestMethod] [NetFullTargetFrameworkDataSource] [NetCoreTargetFrameworkDataSource] diff --git a/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs index a4d6097d98..5dc309b8e9 100644 --- a/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs @@ -83,7 +83,7 @@ public void CapabilitiesShouldReturnAppropriateProperties() { RunTestsArgumentProcessorCapabilities capabilities = new RunTestsArgumentProcessorCapabilities(); Assert.AreEqual("/RunTests", capabilities.CommandName); - Assert.AreEqual("[TestFileNames]" + Environment.NewLine + " Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern" + Environment.NewLine + " by spaces." + Environment.NewLine + " Examples: mytestproject.dll" + Environment.NewLine + " mytestproject.dll myothertestproject.exe" + Environment.NewLine + @" e:\code\**\*testproject.dll mytestproject.dll", capabilities.HelpContentResourceName); + Assert.AreEqual("[TestFileNames]" + Environment.NewLine + " Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern" + Environment.NewLine + " by spaces. Use detailed verbosity to view matched test files." + Environment.NewLine + " Examples: mytestproject.dll" + Environment.NewLine + " mytestproject.dll myothertestproject.exe" + Environment.NewLine + @" testproject*.dll my*project.dll", capabilities.HelpContentResourceName); Assert.AreEqual(HelpContentPriority.RunTestsArgumentProcessorHelpPriority, capabilities.HelpPriority); Assert.AreEqual(true, capabilities.IsAction); From e8106657cecd114ba7de47c908362bf2f281194a Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Fri, 26 Jul 2019 22:46:44 +0530 Subject: [PATCH 08/11] Update Acceptance tests --- .../FilePatternParserTests.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/FilePatternParserTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/FilePatternParserTests.cs index 403011e883..d8f281a7c0 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/FilePatternParserTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/FilePatternParserTests.cs @@ -59,9 +59,7 @@ public void WildCardPatternShouldCorrectlyWorkForRelativeAssemblyPath(RunnerInfo AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); var testAssembly = this.GetSampleTestAssembly(); - var oldAssemblyPath = Path.Combine("Debug", this.testEnvironment.TargetFramework, "SimpleTestProject.dll"); - var newAssemblyPath = Path.Combine("**", this.testEnvironment.TargetFramework, "*TestProj*.dll"); - testAssembly = testAssembly.Replace(oldAssemblyPath, newAssemblyPath); + testAssembly = testAssembly.Replace("SimpleTestProject.dll", "*TestProj*.dll"); var wildCardIndex = testAssembly.IndexOfAny(new char[] { '*' }); var testAssemblyDirectory = testAssembly.Substring(0, wildCardIndex); From 424d693e72ef417d5a29fee7b2fffde980bb6bf7 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Mon, 29 Jul 2019 14:44:26 +0530 Subject: [PATCH 09/11] Adding fileglobbing to TestPlatform nuget --- scripts/verify-nupkgs.ps1 | 2 +- src/package/nuspec/Microsoft.TestPlatform.nuspec | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/verify-nupkgs.ps1 b/scripts/verify-nupkgs.ps1 index 2daa6c6078..84ed4d6a4e 100644 --- a/scripts/verify-nupkgs.ps1 +++ b/scripts/verify-nupkgs.ps1 @@ -14,7 +14,7 @@ function Verify-Nuget-Packages($packageDirectory) Write-Log "Starting Verify-Nuget-Packages." $expectedNumOfFiles = @{"Microsoft.CodeCoverage" = 29; "Microsoft.NET.Test.Sdk" = 13; - "Microsoft.TestPlatform" = 421; + "Microsoft.TestPlatform" = 422; "Microsoft.TestPlatform.Build" = 19; "Microsoft.TestPlatform.CLI" = 301; "Microsoft.TestPlatform.Extensions.TrxLogger" = 33; diff --git a/src/package/nuspec/Microsoft.TestPlatform.nuspec b/src/package/nuspec/Microsoft.TestPlatform.nuspec index 9ca82f4d67..de164d2d71 100644 --- a/src/package/nuspec/Microsoft.TestPlatform.nuspec +++ b/src/package/nuspec/Microsoft.TestPlatform.nuspec @@ -97,6 +97,7 @@ + From a83aa3ef19c4a37c87991505359dcfd4ea483e9c Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Wed, 7 Aug 2019 19:25:29 +0530 Subject: [PATCH 10/11] Revie comments --- .../CommandLine/CommandLineOptions.cs | 39 +++---------- .../Internal/FilePatternParser.cs | 34 ++++++++--- src/vstest.console/Resources/Resources.resx | 2 +- .../Resources/xlf/Resources.cs.xlf | 2 +- .../Resources/xlf/Resources.de.xlf | 2 +- .../Resources/xlf/Resources.es.xlf | 2 +- .../Resources/xlf/Resources.fr.xlf | 2 +- .../Resources/xlf/Resources.it.xlf | 2 +- .../Resources/xlf/Resources.ja.xlf | 2 +- .../Resources/xlf/Resources.ko.xlf | 2 +- .../Resources/xlf/Resources.pl.xlf | 2 +- .../Resources/xlf/Resources.pt-BR.xlf | 2 +- .../Resources/xlf/Resources.ru.xlf | 2 +- .../Resources/xlf/Resources.tr.xlf | 2 +- .../Resources/xlf/Resources.xlf | 2 +- .../Resources/xlf/Resources.zh-Hans.xlf | 2 +- .../Resources/xlf/Resources.zh-Hant.xlf | 2 +- .../CommandLine/CommandLineOptionsTests.cs | 28 ++------- .../Internal/FilePatternParserTests.cs | 57 ++++++++++--------- 19 files changed, 84 insertions(+), 104 deletions(-) diff --git a/src/vstest.console/CommandLine/CommandLineOptions.cs b/src/vstest.console/CommandLine/CommandLineOptions.cs index bb44d3e7be..04e3c7e392 100644 --- a/src/vstest.console/CommandLine/CommandLineOptions.cs +++ b/src/vstest.console/CommandLine/CommandLineOptions.cs @@ -5,7 +5,6 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine { using System; using System.Collections.Generic; - using System.Globalization; using System.Linq; using Microsoft.VisualStudio.TestPlatform.ObjectModel; @@ -84,6 +83,7 @@ protected CommandLineOptions() this.BatchSize = DefaultBatchSize; this.TestStatsEventTimeout = this.DefaultRetrievalTimeout; this.FileHelper = new FileHelper(); + this.FilePatternParser = new FilePatternParser(); #if TODO UseVsixExtensions = Utilities.GetAppSettingValue(UseVsixExtensionsKey, false); #endif @@ -239,6 +239,8 @@ public bool ShouldCollectSourceInformation internal IFileHelper FileHelper { get; set; } + internal FilePatternParser FilePatternParser { get; set; } + /// /// Gets or sets the target Framework version for test run. /// @@ -293,38 +295,11 @@ public void AddSource(string source) source = Path.Combine(FileHelper.GetCurrentDirectory(), source); } - var filePatternParser = new FilePatternParser(); - var sourceFiles = new List(); - var isValidPattern = filePatternParser.IsValidPattern(source, out sourceFiles); - - // If the given file is a valid pattern - if (isValidPattern) - { - foreach (var sourceFile in sourceFiles) - { - if (this.sources.Contains(sourceFile, StringComparer.OrdinalIgnoreCase)) - { - continue; - } + // Get matching files from file pattern parser + var matchingFiles = FilePatternParser.GetMatchingFiles(source); - this.sources.Add(sourceFile); - } - - return; - } - - // If the given file is not a pattern, check if it exists. - if (!FileHelper.Exists(source)) - { - throw new CommandLineException( - string.Format(CultureInfo.CurrentUICulture, CommandLineResources.TestSourceFileNotFound, source)); - } - - // Add the file to the source list if not already present. - if (!this.sources.Contains(source, StringComparer.OrdinalIgnoreCase)) - { - this.sources.Add(source); - } + // Add the matching files to source list + this.sources = this.sources.Union(matchingFiles).ToList(); } #endregion diff --git a/src/vstest.console/Internal/FilePatternParser.cs b/src/vstest.console/Internal/FilePatternParser.cs index de57e9ec2b..923a96a252 100644 --- a/src/vstest.console/Internal/FilePatternParser.cs +++ b/src/vstest.console/Internal/FilePatternParser.cs @@ -5,11 +5,17 @@ namespace vstest.console.Internal { using Microsoft.Extensions.FileSystemGlobbing; using Microsoft.Extensions.FileSystemGlobbing.Abstractions; + using Microsoft.VisualStudio.TestPlatform.CommandLine; using Microsoft.VisualStudio.TestPlatform.ObjectModel; + using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers; + using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; using System; using System.Collections.Generic; + using System.Globalization; using System.IO; + using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; + /// /// Class for getting matching files from wild card pattern file name /// Microsoft.Extensions.FileSystemGlobbing methods used to get matching file names @@ -17,31 +23,43 @@ namespace vstest.console.Internal public class FilePatternParser { private Matcher matcher; + private IFileHelper fileHelper; private char[] wildCardCharacters = { '*' }; public FilePatternParser() - : this(new Matcher()) + : this(new Matcher(), new FileHelper()) { } - internal FilePatternParser(Matcher matcher) + internal FilePatternParser(Matcher matcher, IFileHelper fileHelper) { this.matcher = matcher; + this.fileHelper = fileHelper; } /// /// Used to get matching files with pattern /// - /// If the file is a valid pattern or full path. Returns true if it is valid pattern - public bool IsValidPattern(string filePattern, out List matchingFiles) + /// Returns the list of matching files + public List GetMatchingFiles(string filePattern) { - matchingFiles = new List(); + var matchingFiles = new List(); - // If there is no wildcard, return false. + // If there is no wildcard simply add the file to the list of matching files. if(filePattern.IndexOfAny(wildCardCharacters) == -1) { EqtTrace.Info($"FilePatternParser: The given file {filePattern} is a full path."); - return false; + + // Check if the file exists. + if (!this.fileHelper.Exists(filePattern)) + { + throw new CommandLineException( + string.Format(CultureInfo.CurrentUICulture, CommandLineResources.TestSourceFileNotFound, filePattern)); + } + + matchingFiles.Add(filePattern); + + return matchingFiles; } // Split the given wildcard into search directory and pattern to be searched. @@ -59,7 +77,7 @@ public bool IsValidPattern(string filePattern, out List matchingFiles) matchingFiles.Add(Path.Combine(splitPattern.Item1, match.Path)); } - return true; + return matchingFiles; } /// diff --git a/src/vstest.console/Resources/Resources.resx b/src/vstest.console/Resources/Resources.resx index f701775aa4..a15a20c6e9 100644 --- a/src/vstest.console/Resources/Resources.resx +++ b/src/vstest.console/Resources/Resources.resx @@ -484,7 +484,7 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. Use detailed verbosity to view matched test files. + by spaces. Set console logger verbosity to detailed to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe testproject*.dll my*project.dll diff --git a/src/vstest.console/Resources/xlf/Resources.cs.xlf b/src/vstest.console/Resources/xlf/Resources.cs.xlf index 54f222554c..f225d94f37 100644 --- a/src/vstest.console/Resources/xlf/Resources.cs.xlf +++ b/src/vstest.console/Resources/xlf/Resources.cs.xlf @@ -291,7 +291,7 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. Use detailed verbosity to view matched test files. + by spaces. Set console logger verbosity to detailed to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe testproject*.dll my*project.dll diff --git a/src/vstest.console/Resources/xlf/Resources.de.xlf b/src/vstest.console/Resources/xlf/Resources.de.xlf index db37c0a061..f04a059b9c 100644 --- a/src/vstest.console/Resources/xlf/Resources.de.xlf +++ b/src/vstest.console/Resources/xlf/Resources.de.xlf @@ -291,7 +291,7 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. Use detailed verbosity to view matched test files. + by spaces. Set console logger verbosity to detailed to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe testproject*.dll my*project.dll diff --git a/src/vstest.console/Resources/xlf/Resources.es.xlf b/src/vstest.console/Resources/xlf/Resources.es.xlf index 7bbf7376ab..31fd55ce9d 100644 --- a/src/vstest.console/Resources/xlf/Resources.es.xlf +++ b/src/vstest.console/Resources/xlf/Resources.es.xlf @@ -291,7 +291,7 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. Use detailed verbosity to view matched test files. + by spaces. Set console logger verbosity to detailed to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe testproject*.dll my*project.dll diff --git a/src/vstest.console/Resources/xlf/Resources.fr.xlf b/src/vstest.console/Resources/xlf/Resources.fr.xlf index 0efc061cb9..d7f61f2967 100644 --- a/src/vstest.console/Resources/xlf/Resources.fr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.fr.xlf @@ -291,7 +291,7 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. Use detailed verbosity to view matched test files. + by spaces. Set console logger verbosity to detailed to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe testproject*.dll my*project.dll diff --git a/src/vstest.console/Resources/xlf/Resources.it.xlf b/src/vstest.console/Resources/xlf/Resources.it.xlf index 01d271631c..171804d646 100644 --- a/src/vstest.console/Resources/xlf/Resources.it.xlf +++ b/src/vstest.console/Resources/xlf/Resources.it.xlf @@ -291,7 +291,7 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. Use detailed verbosity to view matched test files. + by spaces. Set console logger verbosity to detailed to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe testproject*.dll my*project.dll diff --git a/src/vstest.console/Resources/xlf/Resources.ja.xlf b/src/vstest.console/Resources/xlf/Resources.ja.xlf index b39a56f285..9c3952efe9 100644 --- a/src/vstest.console/Resources/xlf/Resources.ja.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ja.xlf @@ -291,7 +291,7 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. Use detailed verbosity to view matched test files. + by spaces. Set console logger verbosity to detailed to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe testproject*.dll my*project.dll diff --git a/src/vstest.console/Resources/xlf/Resources.ko.xlf b/src/vstest.console/Resources/xlf/Resources.ko.xlf index 2e6064df44..9fa52e3dc0 100644 --- a/src/vstest.console/Resources/xlf/Resources.ko.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ko.xlf @@ -291,7 +291,7 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. Use detailed verbosity to view matched test files. + by spaces. Set console logger verbosity to detailed to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe testproject*.dll my*project.dll diff --git a/src/vstest.console/Resources/xlf/Resources.pl.xlf b/src/vstest.console/Resources/xlf/Resources.pl.xlf index b7623bb957..c210a4da1e 100644 --- a/src/vstest.console/Resources/xlf/Resources.pl.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pl.xlf @@ -291,7 +291,7 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. Use detailed verbosity to view matched test files. + by spaces. Set console logger verbosity to detailed to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe testproject*.dll my*project.dll diff --git a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf index 1f40286041..f62a73019a 100644 --- a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf @@ -291,7 +291,7 @@ Altere o prefixo de nível de diagnóstico do agente de console, como mostrado a [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. Use detailed verbosity to view matched test files. + by spaces. Set console logger verbosity to detailed to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe testproject*.dll my*project.dll diff --git a/src/vstest.console/Resources/xlf/Resources.ru.xlf b/src/vstest.console/Resources/xlf/Resources.ru.xlf index bf80e39445..24644230a5 100644 --- a/src/vstest.console/Resources/xlf/Resources.ru.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ru.xlf @@ -291,7 +291,7 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. Use detailed verbosity to view matched test files. + by spaces. Set console logger verbosity to detailed to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe testproject*.dll my*project.dll diff --git a/src/vstest.console/Resources/xlf/Resources.tr.xlf b/src/vstest.console/Resources/xlf/Resources.tr.xlf index 5ad19a3297..9535b66c8d 100644 --- a/src/vstest.console/Resources/xlf/Resources.tr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.tr.xlf @@ -291,7 +291,7 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. Use detailed verbosity to view matched test files. + by spaces. Set console logger verbosity to detailed to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe testproject*.dll my*project.dll diff --git a/src/vstest.console/Resources/xlf/Resources.xlf b/src/vstest.console/Resources/xlf/Resources.xlf index dc53530297..4615d0fa70 100644 --- a/src/vstest.console/Resources/xlf/Resources.xlf +++ b/src/vstest.console/Resources/xlf/Resources.xlf @@ -121,7 +121,7 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. Use detailed verbosity to view matched test files. + by spaces. Set console logger verbosity to detailed to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe testproject*.dll my*project.dll diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf index 7dbade84aa..9183942b4c 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf @@ -290,7 +290,7 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. Use detailed verbosity to view matched test files. + by spaces. Set console logger verbosity to detailed to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe testproject*.dll my*project.dll diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf index da0a14edcb..7aa01f9cc3 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf @@ -292,7 +292,7 @@ [TestFileNames] Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern - by spaces. Use detailed verbosity to view matched test files. + by spaces. Set console logger verbosity to detailed to view matched test files. Examples: mytestproject.dll mytestproject.dll myothertestproject.exe testproject*.dll my*project.dll diff --git a/test/vstest.console.UnitTests/CommandLine/CommandLineOptionsTests.cs b/test/vstest.console.UnitTests/CommandLine/CommandLineOptionsTests.cs index 5cce8a278f..458ce9a5a5 100644 --- a/test/vstest.console.UnitTests/CommandLine/CommandLineOptionsTests.cs +++ b/test/vstest.console.UnitTests/CommandLine/CommandLineOptionsTests.cs @@ -12,18 +12,23 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.CommandLine using Moq; using System.IO; using MSTest.TestFramework.AssertExtensions; + using vstest.console.Internal; + using Microsoft.Extensions.FileSystemGlobbing; [TestClass] public class CommandLineOptionsTests { private readonly Mock fileHelper; + private FilePatternParser filePatternParser; private readonly string currentDirectory = @"C:\\Temp"; public CommandLineOptionsTests() { this.fileHelper = new Mock(); + this.filePatternParser = new FilePatternParser(new Mock().Object, this.fileHelper.Object); CommandLineOptions.Instance.Reset(); CommandLineOptions.Instance.FileHelper = this.fileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = this.filePatternParser; this.fileHelper.Setup(fh => fh.GetCurrentDirectory()).Returns(currentDirectory); } @@ -90,28 +95,5 @@ public void CommandLineOptionsAddSourceShouldAddSourceForValidSource() Assert.IsTrue(CommandLineOptions.Instance.Sources.Contains(testFilePath)); } - - [TestMethod] - public void CommandLineOptionsShouldCheckIfFileExistesIfFilePathDoesNotContainPattern() - { - string testFilePath = "C:\\DummyTestFile.txt"; - this.fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); - - CommandLineOptions.Instance.AddSource(testFilePath); - - this.fileHelper.Verify(x => x.Exists("C:\\DummyTestFile.txt"), Times.Once); - Assert.IsTrue(CommandLineOptions.Instance.Sources.Contains(testFilePath)); - } - - [TestMethod] - public void CommandLineOptionsShouldCheckIfFileExistesIfFilePathContainsPattern() - { - string testFilePath = "C:\\Folder1\\Folder*\\DummyTestFile.txt"; - this.fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); - - CommandLineOptions.Instance.AddSource(testFilePath); - - this.fileHelper.Verify(x => x.Exists(It.IsAny()), Times.Never); - } } } diff --git a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs index 1ed0fea059..7117a7f0ac 100644 --- a/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs +++ b/test/vstest.console.UnitTests/Internal/FilePatternParserTests.cs @@ -5,6 +5,8 @@ namespace vstest.console.UnitTests.Internal { using Microsoft.Extensions.FileSystemGlobbing; using Microsoft.Extensions.FileSystemGlobbing.Abstractions; + using Microsoft.VisualStudio.TestPlatform.CommandLine; + using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using System.Collections.Generic; @@ -15,24 +17,24 @@ public class FilePatternParserTests { private FilePatternParser filePatternParser; private Mock mockMatcherHelper; + private Mock mockFileHelper; [TestInitialize] public void TestInit() { this.mockMatcherHelper = new Mock(); - this.filePatternParser = new FilePatternParser(this.mockMatcherHelper.Object); + this.mockFileHelper = new Mock(); + this.filePatternParser = new FilePatternParser(this.mockMatcherHelper.Object, this.mockFileHelper.Object); } [TestMethod] public void FilePatternParserShouldCorrectlySplitPatternAndDirectory() { var patternMatchingResult = new PatternMatchingResult(new List()); - var sourceFiles = new List(); this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - var isValidPattern = this.filePatternParser.IsValidPattern(@"C:\Users\vanidhi\Desktop\a\c\*bc.dll", out sourceFiles); + this.filePatternParser.GetMatchingFiles(@"C:\Users\vanidhi\Desktop\a\c\*bc.dll"); - //Assert - Assert.IsTrue(isValidPattern); + // Assert this.mockMatcherHelper.Verify(x => x.AddInclude(@"*bc.dll")); this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(@"C:\Users\vanidhi\Desktop\a\c")))); } @@ -41,12 +43,10 @@ public void FilePatternParserShouldCorrectlySplitPatternAndDirectory() public void FilePatternParserShouldCorrectlySplitWithArbitraryDirectoryDepth() { var patternMatchingResult = new PatternMatchingResult(new List()); - var sourceFiles = new List(); this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - var isValidPattern = this.filePatternParser.IsValidPattern(@"C:\Users\vanidhi\**\c\*bc.txt", out sourceFiles); + this.filePatternParser.GetMatchingFiles(@"C:\Users\vanidhi\**\c\*bc.txt"); - //Assert - Assert.IsTrue(isValidPattern); + // Assert this.mockMatcherHelper.Verify(x => x.AddInclude(@"**\c\*bc.txt")); this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(@"C:\Users\vanidhi")))); } @@ -55,12 +55,10 @@ public void FilePatternParserShouldCorrectlySplitWithArbitraryDirectoryDepth() public void FilePatternParserShouldCorrectlySplitWithWildCardInMultipleDirectory() { var patternMatchingResult = new PatternMatchingResult(new List()); - var sourceFiles = new List(); this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - var isValidPattern = this.filePatternParser.IsValidPattern(@"E:\path\to\project\tests\**.Tests\**\*.Tests.dll", out sourceFiles); + this.filePatternParser.GetMatchingFiles(@"E:\path\to\project\tests\**.Tests\**\*.Tests.dll"); - //Assert - Assert.IsTrue(isValidPattern); + // Assert this.mockMatcherHelper.Verify(x => x.AddInclude(@"**.Tests\**\*.Tests.dll")); this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(@"E:\path\to\project\tests")))); } @@ -69,12 +67,10 @@ public void FilePatternParserShouldCorrectlySplitWithWildCardInMultipleDirectory public void FilePatternParserShouldCorrectlySplitWithMultpleWildCardInPattern() { var patternMatchingResult = new PatternMatchingResult(new List()); - var sourceFiles = new List(); this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - var isValidPattern = this.filePatternParser.IsValidPattern(@"E:\path\to\project\tests\Tests*.Blame*.dll", out sourceFiles); + this.filePatternParser.GetMatchingFiles(@"E:\path\to\project\tests\Tests*.Blame*.dll"); - //Assert - Assert.IsTrue(isValidPattern); + // Assert this.mockMatcherHelper.Verify(x => x.AddInclude(@"Tests*.Blame*.dll")); this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(@"E:\path\to\project\tests")))); } @@ -83,26 +79,35 @@ public void FilePatternParserShouldCorrectlySplitWithMultpleWildCardInPattern() public void FilePatternParserShouldCorrectlySplitWithMultpleWildCardInMultipleDirectory() { var patternMatchingResult = new PatternMatchingResult(new List()); - var sourceFiles = new List(); this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - var isValidPattern = this.filePatternParser.IsValidPattern(@"E:\path\to\project\*tests\Tests*.Blame*.dll", out sourceFiles); + this.filePatternParser.GetMatchingFiles(@"E:\path\to\project\*tests\Tests*.Blame*.dll"); - //Assert - Assert.IsTrue(isValidPattern); + // Assert this.mockMatcherHelper.Verify(x => x.AddInclude(@"*tests\Tests*.Blame*.dll")); this.mockMatcherHelper.Verify(x => x.Execute(It.Is(y => y.FullName.Equals(@"E:\path\to\project")))); } [TestMethod] - public void IsValidPatternShouldReturnFalseForAbsoluteSourcePath() + public void FilePatternParserShouldCheckIfFileExistsIfFullPathGiven() { var patternMatchingResult = new PatternMatchingResult(new List()); - var sourceFiles = new List(); + this.mockFileHelper.Setup(x => x.Exists(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll")).Returns(true); this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); - var isValidPattern = this.filePatternParser.IsValidPattern(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll", out sourceFiles); + var matchingFiles = this.filePatternParser.GetMatchingFiles(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll"); - //Assert - Assert.IsFalse(isValidPattern); + // Assert + this.mockFileHelper.Verify(x => x.Exists(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll")); + Assert.IsTrue(matchingFiles.Contains(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll")); + } + + [TestMethod] + public void FilePatternParserShouldThrowCommandLineExceptionIfFileDoesNotExist() + { + var patternMatchingResult = new PatternMatchingResult(new List()); + this.mockFileHelper.Setup(x => x.Exists(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll")).Returns(false); + this.mockMatcherHelper.Setup(x => x.Execute(It.IsAny())).Returns(patternMatchingResult); + + Assert.ThrowsException(() => this.filePatternParser.GetMatchingFiles(@"E:\path\to\project\tests\Blame.Tests\\abc.Tests.dll")); } } } From 4d549967e62bf5839e388af57319d7c8526ac001 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Wed, 7 Aug 2019 21:34:26 +0530 Subject: [PATCH 11/11] Unit tests fixed --- src/package/nuspec/Microsoft.TestPlatform.Portable.nuspec | 4 ++-- .../vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs | 6 +++++- .../ListFullyQualifiedTestsArgumentProcessorTests.cs | 5 ++++- .../Processors/ListTestsArgumentProcessorTests.cs | 6 ++++-- .../Processors/RunSpecificTestsArgumentProcessorTests.cs | 4 +++- .../Processors/RunTestsArgumentProcessorTests.cs | 6 ++++-- .../Processors/TestSourceArgumentProcessorTests.cs | 4 +++- 7 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/package/nuspec/Microsoft.TestPlatform.Portable.nuspec b/src/package/nuspec/Microsoft.TestPlatform.Portable.nuspec index 12976de841..81d63e9f40 100644 --- a/src/package/nuspec/Microsoft.TestPlatform.Portable.nuspec +++ b/src/package/nuspec/Microsoft.TestPlatform.Portable.nuspec @@ -22,6 +22,7 @@ + @@ -216,7 +217,6 @@ - @@ -225,6 +225,7 @@ + @@ -487,7 +488,6 @@ - diff --git a/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs b/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs index 4a788898f8..0773f9d24d 100644 --- a/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs +++ b/test/vstest.console.UnitTests/Internal/ConsoleLoggerTests.cs @@ -9,7 +9,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Internal using System.Globalization; using System.Linq; using System.Threading; - + using Microsoft.Extensions.FileSystemGlobbing; using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; using Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors; using Microsoft.VisualStudio.TestPlatform.Common.Logging; @@ -20,6 +20,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Internal using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; + using vstest.console.Internal; using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; [TestClass] @@ -823,6 +824,7 @@ public void TestRunStartHandlerShouldWriteNumberOfTestSourcesDiscoveredOnConsole var fileHelper = new Mock(); CommandLineOptions.Instance.Reset(); CommandLineOptions.Instance.FileHelper = fileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, fileHelper.Object); string testFilePath = "C:\\DummyTestFile.dll"; fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); @@ -848,6 +850,7 @@ public void TestRunStartHandlerShouldWriteTestSourcesDiscoveredOnConsoleIfVerbos var fileHelper = new Mock(); CommandLineOptions.Instance.Reset(); CommandLineOptions.Instance.FileHelper = fileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, fileHelper.Object); string testFilePath = "C:\\DummyTestFile.dll"; fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); string testFilePath2 = "C:\\DummyTestFile2.dll"; @@ -878,6 +881,7 @@ public void TestRunStartHandlerShouldNotWriteTestSourcesDiscoveredOnConsoleIfVer var fileHelper = new Mock(); CommandLineOptions.Instance.Reset(); CommandLineOptions.Instance.FileHelper = fileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, fileHelper.Object); string testFilePath = "C:\\DummyTestFile.dll"; fileHelper.Setup(fh => fh.Exists(testFilePath)).Returns(true); string testFilePath2 = "C:\\DummyTestFile2.dll"; diff --git a/test/vstest.console.UnitTests/Processors/ListFullyQualifiedTestsArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/ListFullyQualifiedTestsArgumentProcessorTests.cs index 90067b0b14..56e617f45e 100644 --- a/test/vstest.console.UnitTests/Processors/ListFullyQualifiedTestsArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/ListFullyQualifiedTestsArgumentProcessorTests.cs @@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors using System.Threading.Tasks; using CoreUtilities.Tracing.Interfaces; - + using Microsoft.Extensions.FileSystemGlobbing; using Microsoft.VisualStudio.TestPlatform.Client; using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; @@ -25,6 +25,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors using ObjectModel.Client; using TestPlatform.Utilities; using TestPlatformHelpers; + using vstest.console.Internal; using vstest.console.UnitTests.Processors; // @@ -119,6 +120,7 @@ public void CapabilitiesShouldReturnAppropriateProperties() public void ExecutorInitializeWithValidSourceShouldAddItToTestSources() { CommandLineOptions.Instance.FileHelper = this.mockFileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, this.mockFileHelper.Object); var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask); var executor = GetExecutor(testRequestManager, null); @@ -320,6 +322,7 @@ private void ResetAndAddSourceToCommandLineOptions(bool legitPath) CommandLineOptions.Instance.Reset(); CommandLineOptions.Instance.FileHelper = this.mockFileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, this.mockFileHelper.Object); CommandLineOptions.Instance.AddSource(this.dummyTestFilePath); if (legitPath) { diff --git a/test/vstest.console.UnitTests/Processors/ListTestsArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/ListTestsArgumentProcessorTests.cs index 0407de27fb..40c0109145 100644 --- a/test/vstest.console.UnitTests/Processors/ListTestsArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/ListTestsArgumentProcessorTests.cs @@ -10,7 +10,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors using System.Threading.Tasks; using CoreUtilities.Tracing.Interfaces; - + using Microsoft.Extensions.FileSystemGlobbing; using Microsoft.VisualStudio.TestPlatform.Client; using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; @@ -24,6 +24,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors using ObjectModel.Client; using TestPlatform.Utilities; using TestPlatformHelpers; + using vstest.console.Internal; using vstest.console.UnitTests.Processors; // @@ -120,7 +121,7 @@ public void CapabilitiesShouldReturnAppropriateProperties() public void ExecutorInitializeWithValidSourceShouldAddItToTestSources() { CommandLineOptions.Instance.FileHelper = this.mockFileHelper.Object; - + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, this.mockFileHelper.Object); var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, TestPlatformFactory.GetTestPlatform(), TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask); var executor = GetExecutor(testRequestManager, null); @@ -268,6 +269,7 @@ private void ResetAndAddSourceToCommandLineOptions() CommandLineOptions.Instance.Reset(); CommandLineOptions.Instance.FileHelper = this.mockFileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, this.mockFileHelper.Object); CommandLineOptions.Instance.AddSource(this.dummyTestFilePath); } } diff --git a/test/vstest.console.UnitTests/Processors/RunSpecificTestsArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/RunSpecificTestsArgumentProcessorTests.cs index a569d331c9..08c10972c5 100644 --- a/test/vstest.console.UnitTests/Processors/RunSpecificTestsArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/RunSpecificTestsArgumentProcessorTests.cs @@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors using CommandLineUtilities; using CoreUtilities.Tracing.Interfaces; - + using Microsoft.Extensions.FileSystemGlobbing; using Microsoft.VisualStudio.TestPlatform.Client; using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; @@ -24,6 +24,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; + using vstest.console.Internal; using vstest.console.UnitTests.Processors; [TestClass] @@ -546,6 +547,7 @@ private void ResetAndAddSourceToCommandLineOptions() { CommandLineOptions.Instance.Reset(); CommandLineOptions.Instance.TestCaseFilterValue = null; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, this.mockFileHelper.Object); CommandLineOptions.Instance.FileHelper = this.mockFileHelper.Object; CommandLineOptions.Instance.AddSource(this.dummyTestFilePath); } diff --git a/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs index 5dc309b8e9..7aea9780e9 100644 --- a/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs @@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors using System.Reflection; using System.Runtime.Versioning; using System.Threading.Tasks; - + using Microsoft.Extensions.FileSystemGlobbing; using Microsoft.VisualStudio.TestPlatform.Client; using Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; using Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; @@ -28,6 +28,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; + using vstest.console.Internal; using vstest.console.UnitTests.Processors; /// @@ -83,7 +84,7 @@ public void CapabilitiesShouldReturnAppropriateProperties() { RunTestsArgumentProcessorCapabilities capabilities = new RunTestsArgumentProcessorCapabilities(); Assert.AreEqual("/RunTests", capabilities.CommandName); - Assert.AreEqual("[TestFileNames]" + Environment.NewLine + " Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern" + Environment.NewLine + " by spaces. Use detailed verbosity to view matched test files." + Environment.NewLine + " Examples: mytestproject.dll" + Environment.NewLine + " mytestproject.dll myothertestproject.exe" + Environment.NewLine + @" testproject*.dll my*project.dll", capabilities.HelpContentResourceName); + Assert.AreEqual("[TestFileNames]" + Environment.NewLine + " Run tests from the specified files or wild card pattern. Separate multiple test file names or pattern" + Environment.NewLine + " by spaces. Set console logger verbosity to detailed to view matched test files." + Environment.NewLine + " Examples: mytestproject.dll" + Environment.NewLine + " mytestproject.dll myothertestproject.exe" + Environment.NewLine + @" testproject*.dll my*project.dll", capabilities.HelpContentResourceName); Assert.AreEqual(HelpContentPriority.RunTestsArgumentProcessorHelpPriority, capabilities.HelpPriority); Assert.AreEqual(true, capabilities.IsAction); @@ -258,6 +259,7 @@ private void ResetAndAddSourceToCommandLineOptions() CommandLineOptions.Instance.Reset(); CommandLineOptions.Instance.FileHelper = this.mockFileHelper.Object; + CommandLineOptions.Instance.FilePatternParser = new FilePatternParser(new Mock().Object, this.mockFileHelper.Object); CommandLineOptions.Instance.AddSource(this.dummyTestFilePath); } diff --git a/test/vstest.console.UnitTests/Processors/TestSourceArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/TestSourceArgumentProcessorTests.cs index 8d23ff924c..bf3fcb4f88 100644 --- a/test/vstest.console.UnitTests/Processors/TestSourceArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/TestSourceArgumentProcessorTests.cs @@ -5,12 +5,13 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.UnitTests.Processors { using System; using System.Linq; - + using Microsoft.Extensions.FileSystemGlobbing; using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; + using vstest.console.Internal; // // Tests for TestSourceArgumentProcessor @@ -94,6 +95,7 @@ public void ExecuterInitializeWithValidSourceShouldAddItToTestSources() var options = CommandLineOptions.Instance; options.Reset(); options.FileHelper = mockFileHelper.Object; + options.FilePatternParser = new FilePatternParser(new Mock().Object, mockFileHelper.Object); var executor = new TestSourceArgumentExecutor(options); executor.Initialize(testFilePath);