-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always look for adapters in Test Source directory #1574
Changes from 5 commits
c93cd15
91141e1
121146d
e6db9d0
f17bd77
8b6cc5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ public string VSTestSetting | |
set; | ||
} | ||
|
||
public string VSTestTestAdapterPath | ||
public string[] VSTestTestAdapterPath | ||
{ | ||
get; | ||
set; | ||
|
@@ -54,7 +54,7 @@ public string VSTestTestCaseFilter | |
get; | ||
set; | ||
} | ||
public string VSTestLogger | ||
public string[] VSTestLogger | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Should we rename these to reflect the change, VSTestLoggers ? |
||
{ | ||
get; | ||
set; | ||
|
@@ -131,6 +131,7 @@ public void Cancel() | |
|
||
internal IEnumerable<string> CreateArgument() | ||
{ | ||
var isConsoleLoggerEnabled = true; | ||
var allArgs = new List<string>(); | ||
|
||
// TODO log arguments in task | ||
|
@@ -139,16 +140,11 @@ internal IEnumerable<string> CreateArgument() | |
allArgs.Add("--settings:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(this.VSTestSetting)); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(this.VSTestTestAdapterPath)) | ||
if (this.VSTestTestAdapterPath != null && this.VSTestTestAdapterPath.Length > 0) | ||
{ | ||
allArgs.Add("--testAdapterPath:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(this.VSTestTestAdapterPath)); | ||
} | ||
else | ||
{ | ||
// For Full CLR, add source directory as test adapter path. | ||
if (this.VSTestFramework.StartsWith(".NETFramework", StringComparison.OrdinalIgnoreCase)) | ||
foreach (var arg in this.VSTestTestAdapterPath) | ||
{ | ||
allArgs.Add("--testAdapterPath:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(Path.GetDirectoryName(this.TestFileFullPath))); | ||
allArgs.Add("--testAdapterPath:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(arg)); | ||
} | ||
} | ||
|
||
|
@@ -168,9 +164,17 @@ internal IEnumerable<string> CreateArgument() | |
allArgs.Add("--testCaseFilter:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(this.VSTestTestCaseFilter)); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(this.VSTestLogger)) | ||
if (this.VSTestLogger != null && this.VSTestLogger.Length > 0) | ||
{ | ||
allArgs.Add("--logger:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(this.VSTestLogger)); | ||
foreach (var arg in this.VSTestLogger) | ||
{ | ||
allArgs.Add("--logger:" + ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(arg)); | ||
|
||
if (arg.StartsWith("console", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
isConsoleLoggerEnabled = false; | ||
} | ||
} | ||
} | ||
|
||
if (!string.IsNullOrEmpty(this.VSTestResultsDirectory)) | ||
|
@@ -197,8 +201,8 @@ internal IEnumerable<string> CreateArgument() | |
allArgs.Add(ArgumentEscaper.HandleEscapeSequenceInArgForProcessStart(this.TestFileFullPath)); | ||
} | ||
|
||
if (!string.IsNullOrWhiteSpace(this.VSTestVerbosity) && | ||
(string.IsNullOrEmpty(this.VSTestLogger) || !this.VSTestLogger.StartsWith("console", StringComparison.OrdinalIgnoreCase))) | ||
// Console logger was not specified by user, but verbosity was, hence add default console logger with verbosity as specified | ||
if (!string.IsNullOrWhiteSpace(this.VSTestVerbosity) && isConsoleLoggerEnabled) | ||
{ | ||
var normalTestLogging = new List<string>() { "n", "normal", "d", "detailed", "diag", "diagnostic" }; | ||
var quietTestLogging = new List<string>() { "q", "quiet" }; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,6 @@ public class DefaultTestHostManager : ITestRuntimeProvider | |
private StringBuilder testHostProcessStdError; | ||
private IMessageLogger messageLogger; | ||
private bool hostExitedEventRaised; | ||
private bool projectOutputExtensionsRequired; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DefaultTestHostManager"/> class. | ||
|
@@ -192,7 +191,7 @@ public virtual TestProcessStartInfo GetTestHostProcessStartInfo( | |
/// <inheritdoc/> | ||
public IEnumerable<string> GetTestPlatformExtensions(IEnumerable<string> sources, IEnumerable<string> extensions) | ||
{ | ||
if (sources != null && sources.Any() && this.projectOutputExtensionsRequired) | ||
if (sources != null && sources.Any()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove explicitly testadapterpath from acceptance tests. Example. |
||
{ | ||
extensions = extensions.Concat(sources.SelectMany(s => this.fileHelper.EnumerateFiles(Path.GetDirectoryName(s), SearchOption.TopDirectoryOnly, TestAdapterEndsWithPattern))); | ||
} | ||
|
@@ -248,7 +247,6 @@ public void Initialize(IMessageLogger logger, string runsettingsXml) | |
this.testHostProcess = null; | ||
|
||
this.Shared = !runConfiguration.DisableAppDomain; | ||
this.projectOutputExtensionsRequired = !(runConfiguration.TestAdaptersPaths?.Length > 0); | ||
this.hostExitedEventRaised = false; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,7 @@ public void CreateArgumentShouldNotSetConsoleLoggerVerbosityIfConsoleLoggerIsGiv | |
// Add values for required properties. | ||
vstestTask.TestFileFullPath = "abc"; | ||
vstestTask.VSTestFramework = "abc"; | ||
vstestTask.VSTestLogger = "Console;Verbosity=quiet"; | ||
vstestTask.VSTestLogger = new string[] { "Console;Verbosity=quiet" }; | ||
|
||
var allArguments = vstestTask.CreateArgument().ToArray(); | ||
|
||
|
@@ -209,7 +209,7 @@ public void CreateArgumentShouldPreserveWhiteSpaceInLogger() | |
// Add values for required properties. | ||
vstestTask.TestFileFullPath = "abc"; | ||
vstestTask.VSTestFramework = "abc"; | ||
vstestTask.VSTestLogger = "trx;LogFileName=foo bar.trx"; | ||
vstestTask.VSTestLogger = new string[] { "trx;LogFileName=foo bar.trx" }; | ||
|
||
|
||
var allArguments = vstestTask.CreateArgument().ToArray(); | ||
|
@@ -234,5 +234,40 @@ public void CreateArgumentShouldAddOneCollectArgumentForEachCollect() | |
Assert.IsNotNull(allArguments.FirstOrDefault(arg => arg.Contains("--collect:name1"))); | ||
Assert.IsNotNull(allArguments.FirstOrDefault(arg => arg.Contains("--collect:\"name 2\""))); | ||
} | ||
|
||
[TestMethod] | ||
public void CreateArgumentShouldAddMultipleTestAdapterPaths() | ||
{ | ||
var vstestTask = new VSTestTask(); | ||
|
||
// Add values for required properties. | ||
vstestTask.TestFileFullPath = "abc"; | ||
vstestTask.VSTestFramework = "abc"; | ||
|
||
vstestTask.VSTestTestAdapterPath = new string[] { "path1", "path2" }; | ||
|
||
var allArguments = vstestTask.CreateArgument().ToArray(); | ||
|
||
Assert.IsNotNull(allArguments.FirstOrDefault(arg => arg.Contains("--testAdapterPath:path1"))); | ||
Assert.IsNotNull(allArguments.FirstOrDefault(arg => arg.Contains("--testAdapterPath:path2"))); | ||
} | ||
|
||
[TestMethod] | ||
public void CreateArgumentShouldAddMultipleLoggers() | ||
{ | ||
var vstestTask = new VSTestTask(); | ||
|
||
// Add values for required properties. | ||
vstestTask.TestFileFullPath = "abc"; | ||
vstestTask.VSTestFramework = "abc"; | ||
|
||
vstestTask.VSTestLogger = new string[] { "trx;LogFileName=foo bar.trx", "console" }; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: extra line |
||
|
||
var allArguments = vstestTask.CreateArgument().ToArray(); | ||
|
||
Assert.IsNotNull(allArguments.FirstOrDefault(arg => arg.Contains("--logger:\"trx;LogFileName=foo bar.trx\""))); | ||
Assert.IsNotNull(allArguments.FirstOrDefault(arg => arg.Contains("--logger:console"))); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,16 +211,19 @@ public void GetTestPlatformExtensionsShouldReturnExtensionsListAsIsIfSourcesList | |
} | ||
|
||
[TestMethod] | ||
public void GetTestPlatformExtensionsShouldExcludeOutputDirectoryExtensionsIfTestAdapterPathIsSet() | ||
public void GetTestPlatformExtensionsShouldNotExcludeOutputDirectoryExtensionsIfTestAdapterPathIsSet() | ||
{ | ||
List<string> sourcesDir = new List<string> { @"C:\Source1" }; | ||
List<string> sources = new List<string> { @"C:\Source1\source1.dll" }; | ||
|
||
List<string> extensionsList1 = new List<string> { @"C:\Source1\ext1.TestAdapter.dll", @"C:\Source1\ext2.TestAdapter.dll" }; | ||
this.mockFileHelper.Setup(fh => fh.EnumerateFiles(sourcesDir[0], SearchOption.TopDirectoryOnly, "TestAdapter.dll")).Returns(extensionsList1); | ||
|
||
this.mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList1[0])).Returns(new Version(2, 0)); | ||
this.mockFileHelper.Setup(fh => fh.GetFileVersion(extensionsList1[1])).Returns(new Version(5, 5)); | ||
|
||
this.testHostManager.Initialize(this.mockMessageLogger.Object, $"<?xml version=\"1.0\" encoding=\"utf-8\"?><RunSettings> <RunConfiguration><TestAdaptersPaths>C:\\Foo</TestAdaptersPaths></RunConfiguration> </RunSettings>"); | ||
List<string> currentList = new List<string> { @"FooExtension.dll" }; | ||
List<string> currentList = new List<string> { @"FooExtension.dll", @"C:\Source1\ext1.TestAdapter.dll", @"C:\Source1\ext2.TestAdapter.dll" }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change test name. |
||
|
||
// Act | ||
var resultExtensions = this.testHostManager.GetTestPlatformExtensions(sources, currentList).ToList(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: IEnumerable over string[]