Skip to content
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

Add ResultsDirectory arg to cli #322

Merged
merged 12 commits into from
Jan 9, 2017
Merged

Add ResultsDirectory arg to cli #322

merged 12 commits into from
Jan 9, 2017

Conversation

smadala
Copy link
Contributor

@smadala smadala commented Jan 6, 2017

  • Add ResultsDirectory arg to cli
  • Change precedence to CLIRunSettings > CLIOptions > Settings file for run settings

Related Issue: #299


if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("Using .Net Framework version:{0}", commandLineOptions.TargetFrameworkVersion);
}

if (this.commandLineOptions.TargetFrameworkVersion != Framework.DefaultFramework
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get more context on why this warning is interesting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Comment.

@@ -190,6 +192,9 @@ private int GetArgumentProcessors(string[] args, out List<IArgumentProcessor> pr
var processorsToAlwaysExecute = processorFactory.GetArgumentProcessorsToAlwaysExecute();
processors.AddRange(processorsToAlwaysExecute);

// Initialize Runsettings with defaults
RunSettingsUtilities.AddDefaultRunSettings(RunSettingsManager.Instance);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the defaults be initialized on the first query to ActiveRunSettings?

Copy link
Contributor Author

@smadala smadala Jan 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currenlty we can't assign defaults on first query, because it is public type in different assembly.

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Xml;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move within namespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

argument = Path.GetFullPath(argument);
}
}
catch (Exception ex)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we catch only expected exceptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Added expecting exceptions.

@@ -173,19 +173,12 @@ private IXPathNavigable GetRunSettingsDocument(string runSettingsFile)
{
runSettingsDocument = XmlRunSettingsUtilities.CreateDefaultRunSettings();

#if NET46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not required. Legacy never supports FrameworkCore10.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@@ -69,6 +69,11 @@ internal enum HelpContentPriority
ParallelArgumentProcessorHelpPriority,

/// <summary>
/// ResultsDirectoryArgumentProcessor Help
/// </summary>
ResultsDirectoryArgumentProcessorHelpPriority,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please get the help display approved from @pvlakshm


runSettings = GetEffectiveRunSettings(runSettings, commandlineOptions);
public static void UpdateRunSettingsXmlDocument(XmlDocument xmlDocument, string key, string value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API should take IRunSettingsProvider similar to other APIs in the class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method exists to make efficient updates from CLIRunSettingsArgumentProcessor.cs. Making it private method for clean design.

runSettings = GetEffectiveRunSettings(runSettings, commandlineOptions);
public static void UpdateRunSettingsXmlDocument(XmlDocument xmlDocument, string key, string value)
{
var node = GetXmlNode(xmlDocument, key) ?? RunSettingsUtilities.CreateNode(xmlDocument, key.Split('.'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, we should keep the logic of splitting by . restricted to one place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to CreateNode().

/// <param name="commandlineOptions"> The command line options specified. </param>
/// <returns></returns>
internal static string GetRunSettings(IRunSettingsProvider runSettingsProvider, CommandLineOptions commandlineOptions)
public static void UpdateRunSettings(IRunSettingsProvider runSettingsManager, string runsettingsXml)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class can possibly become RunSettingsProviderExtensions and all APIs can be extension methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Done.

{
var settingsXml = runSettingsProvider.ActiveRunSettings.SettingsXml;

#if net46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/net46/NET46/g

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

{
runSettings = EmptyRunSettings;
#if net46
doc = (XmlDocument)XmlRunSettingsUtilities.CreateDefaultRunSettings();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fix formatting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

#if net46
doc = (XmlDocument)XmlRunSettingsUtilities.CreateDefaultRunSettings();
#else
using (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unnecessary #if.


runSettings = GetEffectiveRunSettings(runSettings, commandlineOptions);
public static void UpdateRunSettingsXmlDocument(XmlDocument xmlDocument, string key, string value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value is a keyword. We can use some other name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to data.

@@ -623,4 +623,16 @@
<data name="MalformedRunSettingsKey" xml:space="preserve">
<value>One or more runsettings provided contain invalid token</value>
</data>
<data name="ResultsDirectoryArgumentHelp" xml:space="preserve">
<value>--ResultsDirectory|/ResultsDirectory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tagging @pvlakshm for review.


this.InvokeVsTest(arguments);

Assert.IsTrue(File.Exists(trxFilePath), $"Expexted Trx file: {trxFilePath} not created in results directory");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Expexted/Expected

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Assert.IsTrue(File.Exists(trxFilePath), $"Expexted Trx file: {trxFilePath} not created in results directory");
}

//Getting Current directory C:\Windows\system32 https://github.com/Microsoft/vstest/issues/311
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @singhsarab has a fix for #311 in pr. We can remove this after merge from master.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR has been reverted, keeping it as Ignored.

@@ -74,39 +77,42 @@ public void InitializeShouldThrowIfArgumentIsEmpty()
[TestMethod]
public void InitializeShouldThrowIfArgumentIsInvalid()
{
var executor = new FrameworkArgumentExecutor(CommandLineOptions.Instance);
var executor = new FrameworkArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use mocks for static singletons.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to Moq limitation of unable to mock extensions methods, using TestableRunSettingsProvider.

@@ -54,7 +57,7 @@ public void CapabilitiesShouldReturnAppropriateProperties()
[TestMethod]
public void InitializeShouldThrowIfArgumentIsNonNull()
{
var executor = new ParallelArgumentExecutor(CommandLineOptions.Instance);
var executor = new ParallelArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make executor an instance variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Done.

@@ -36,7 +40,7 @@ public void CapabilitiesShouldReturnAppropriateProperties()
{
var capabilities = new PlatformArgumentProcessorCapabilities();
Assert.AreEqual("/Platform", capabilities.CommandName);
Assert.AreEqual("--Platform|/Platform:<Platform type>\n Target platform architecture to be used for test execution. \n Valid values are x86, x64 and ARM.", capabilities.HelpContentResourceName);
Assert.AreEqual("--Platform|/Platform:<Platform type>" + Environment.NewLine + " Target platform architecture to be used for test execution. " + Environment.NewLine + " Valid values are x86, x64 and ARM.", capabilities.HelpContentResourceName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

[TestMethod]
public void InitializeShouldThrowIfArgumentIsNull()
{
var executor = new ResultsDirectoryArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DRY violation. Please move to ctor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to instance variable.

@@ -1,6 +1,7 @@
// 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.UnitTests.Processors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change RunSettingsArgumentProcessortTests.cs to RunSettingsArgumentProcessorTests.cs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -180,6 +240,7 @@ public void InitializeShouldSetActiveRunSettingsForTestSettingsFiles()
StringAssert.Contains(settingsProvider.ActiveRunSettings.SettingsXml, "<RunSettings>\r\n <RunConfiguration>\r\n <TargetPlatform>X86</TargetPlatform>\r\n <TargetFrameworkVersion>Framework45</TargetFrameworkVersion>\r\n </RunConfiguration>\r\n <MSTest>\r\n <SettingsFile>C:\\temp\\r.testsettings</SettingsFile>\r\n <ForcedLegacyMode>true</ForcedLegacyMode>\r\n </MSTest>\r\n <DataCollectionRunSettings>\r\n <DataCollectors />\r\n </DataCollectionRunSettings>\r\n</RunSettings>");
}

[Ignore] // Code coverage yet to add
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need not ignore this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the test and removed [Ignore].

@@ -63,9 +77,10 @@ public void GetExecuterShouldReturnRunTestsArgumentProcessorCapabilities()
[TestMethod]
public void CapabilitiesShouldReturnAppropriateProperties()
{
System.Diagnostics.Debugger.Launch();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱 Done.

}

[TestMethod]
public void GetRunSettingsShouldReturnDefaultRunSettingsIfProviderIsNull()
public void UpdateRunSettingsShouldUpdateGivenSettingsXml()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add unit tests for other APIs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Done

Copy link
Contributor

@codito codito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good over all. Please merge after fixing comments.

@@ -91,7 +91,7 @@ public string PublishDirectory
get
{
string value = string.Empty;
if (this.runningInCli)
if (this.runningInCli || true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not suppose to commit, this is work around to run Integration tests from IDE. will be removed .

@smadala smadala merged commit 27be24d into microsoft:master Jan 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants