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

Adding /InIsolation flag for backward compatibility #414

Merged
merged 2 commits into from
Feb 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions src/vstest.console/Processors/InIsolationArgumentProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// 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.Processors
{
using System;
using System.Globalization;
using Microsoft.VisualStudio.TestPlatform.Utilities;
using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources;

/// <summary>
/// An argument processor that allows the user to specify whether the execution
/// should happen in the current vstest.console.exe process or a new different process.
/// </summary>
internal class InIsolationArgumentProcessor : IArgumentProcessor
{
#region Constants

public const string CommandName = "/InIsolation";

#endregion

private Lazy<IArgumentProcessorCapabilities> metadata;

private Lazy<IArgumentExecutor> executor;

/// <summary>
/// Gets the metadata.
/// </summary>
public Lazy<IArgumentProcessorCapabilities> Metadata
{
get
{
if (this.metadata == null)
{
this.metadata = new Lazy<IArgumentProcessorCapabilities>(() => new InIsolationArgumentProcessorCapabilities());
}

return this.metadata;
}
}

/// <summary>
/// Gets or sets the executor.
/// </summary>
public Lazy<IArgumentExecutor> Executor
{
get
{
if (this.executor == null)
{
this.executor =
new Lazy<IArgumentExecutor>(
() =>
new InIsolationArgumentExecutor());
}

return this.executor;
}

set
{
this.executor = value;
}
}
}

internal class InIsolationArgumentProcessorCapabilities : BaseArgumentProcessorCapabilities
{
public override string CommandName => InIsolationArgumentProcessor.CommandName;

public override bool AllowMultiple => false;

public override bool IsAction => false;

public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.Normal;

public override HelpContentPriority HelpPriority => HelpContentPriority.InIsolationArgumentProcessorHelpPriority;
}

internal class InIsolationArgumentExecutor : IArgumentExecutor
{
#region Constructors
public InIsolationArgumentExecutor()
{
}
#endregion

#region IArgumentProcessor

/// <summary>
/// Initializes with the argument that was provided with the command.
/// </summary>
/// <param name="argument">Argument that was provided with the command.</param>
public void Initialize(string argument)
{
if (!string.IsNullOrWhiteSpace(argument))
{
throw new CommandLineException(
string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidInIsolationCommand, argument));
}

ConsoleOutput.Instance.WriteLine(CommandLineResources.InIsolationDeprecated, OutputLevel.Information);
}

/// <summary>
/// Execute.
/// </summary>
public ArgumentProcessorResult Execute()
{
// Nothing to do since we updated the parameter during initialize parameter
return ArgumentProcessorResult.Success;
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ public IEnumerable<IArgumentProcessor> GetArgumentProcessorsToAlwaysExecute()
new ParallelArgumentProcessor(),
new EnableDiagArgumentProcessor(),
new CLIRunSettingsArgumentProcessor(),
new ResultsDirectoryArgumentProcessor()
new ResultsDirectoryArgumentProcessor(),
new InIsolationArgumentProcessor()
};

/// <summary>
Expand Down
11 changes: 11 additions & 0 deletions src/vstest.console/Resources/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/vstest.console/Resources/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -634,4 +634,7 @@
<data name="InvalidResultsDirectoryPathCommand" xml:space="preserve">
<value>The path '{0}' specified in the 'ResultsDirectory' is invalid. Error: {1}</value>
</data>
<data name="InIsolationDeprecated" xml:space="preserve">
<value>The /InIsolation flag is deprecated. The tests are always run in a separate process</value>
Copy link
Contributor

Choose a reason for hiding this comment

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

@pvlakshm can you please review the string? We'll show this message to user if she calls vstest.console /inisolation.

</data>
</root>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,11 @@
<target state="new">The path '{0}' specified in the 'ResultsDirectory' is invalid. Error: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="InIsolationDeprecated">
<source>The /InIsolation flag is deprecated. The tests are always run in a separate process</source>
<target state="new">The /InIsolation flag is deprecated. The tests are always run in a separate process</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,11 @@ Standardeinstellungen werden verwendet, wenn die Verwendung der Einstellungsdate
<target state="new">The path '{0}' specified in the 'ResultsDirectory' is invalid. Error: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="InIsolationDeprecated">
<source>The /InIsolation flag is deprecated. The tests are always run in a separate process</source>
<target state="new">The /InIsolation flag is deprecated. The tests are always run in a separate process</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,11 @@
<target state="new">The path '{0}' specified in the 'ResultsDirectory' is invalid. Error: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="InIsolationDeprecated">
<source>The /InIsolation flag is deprecated. The tests are always run in a separate process</source>
<target state="new">The /InIsolation flag is deprecated. The tests are always run in a separate process</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,11 @@
<target state="new">The path '{0}' specified in the 'ResultsDirectory' is invalid. Error: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="InIsolationDeprecated">
<source>The /InIsolation flag is deprecated. The tests are always run in a separate process</source>
<target state="new">The /InIsolation flag is deprecated. The tests are always run in a separate process</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,11 @@
<target state="new">The path '{0}' specified in the 'ResultsDirectory' is invalid. Error: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="InIsolationDeprecated">
<source>The /InIsolation flag is deprecated. The tests are always run in a separate process</source>
<target state="new">The /InIsolation flag is deprecated. The tests are always run in a separate process</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,11 @@
<target state="new">The path '{0}' specified in the 'ResultsDirectory' is invalid. Error: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="InIsolationDeprecated">
<source>The /InIsolation flag is deprecated. The tests are always run in a separate process</source>
<target state="new">The /InIsolation flag is deprecated. The tests are always run in a separate process</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,11 @@
<target state="new">The path '{0}' specified in the 'ResultsDirectory' is invalid. Error: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="InIsolationDeprecated">
<source>The /InIsolation flag is deprecated. The tests are always run in a separate process</source>
<target state="new">The /InIsolation flag is deprecated. The tests are always run in a separate process</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,11 @@
<target state="new">The path '{0}' specified in the 'ResultsDirectory' is invalid. Error: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="InIsolationDeprecated">
<source>The /InIsolation flag is deprecated. The tests are always run in a separate process</source>
<target state="new">The /InIsolation flag is deprecated. The tests are always run in a separate process</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,11 @@
<target state="new">The path '{0}' specified in the 'ResultsDirectory' is invalid. Error: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="InIsolationDeprecated">
<source>The /InIsolation flag is deprecated. The tests are always run in a separate process</source>
<target state="new">The /InIsolation flag is deprecated. The tests are always run in a separate process</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,11 @@
<target state="new">The path '{0}' specified in the 'ResultsDirectory' is invalid. Error: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="InIsolationDeprecated">
<source>The /InIsolation flag is deprecated. The tests are always run in a separate process</source>
<target state="new">The /InIsolation flag is deprecated. The tests are always run in a separate process</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,11 @@
<target state="new">The path '{0}' specified in the 'ResultsDirectory' is invalid. Error: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="InIsolationDeprecated">
<source>The /InIsolation flag is deprecated. The tests are always run in a separate process</source>
<target state="new">The /InIsolation flag is deprecated. The tests are always run in a separate process</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,11 @@
<target state="new">The path '{0}' specified in the 'ResultsDirectory' is invalid. Error: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="InIsolationDeprecated">
<source>The /InIsolation flag is deprecated. The tests are always run in a separate process</source>
<target state="new">The /InIsolation flag is deprecated. The tests are always run in a separate process</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,11 @@
<target state="new">The path '{0}' specified in the 'ResultsDirectory' is invalid. Error: {1}</target>
<note></note>
</trans-unit>
<trans-unit id="InIsolationDeprecated">
<source>The /InIsolation flag is deprecated. The tests are always run in a separate process</source>
<target state="new">The /InIsolation flag is deprecated. The tests are always run in a separate process</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// 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
{
using System.Diagnostics;
using System.IO;

using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Moq;

using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources;

[TestClass]
public class InIsolationArgumentProcessorTests
{
private readonly InIsolationArgumentProcessor isolationProcessor;

public InIsolationArgumentProcessorTests()
{
this.isolationProcessor = new InIsolationArgumentProcessor();
}

[TestMethod]
public void InIsolationArgumentProcessorMetadataShouldProvideAppropriateCapabilities()
{
Assert.IsFalse(this.isolationProcessor.Metadata.Value.AllowMultiple);
Assert.IsFalse(this.isolationProcessor.Metadata.Value.AlwaysExecute);
Assert.IsFalse(this.isolationProcessor.Metadata.Value.IsAction);
Assert.IsFalse(this.isolationProcessor.Metadata.Value.IsSpecialCommand);
Assert.AreEqual(InIsolationArgumentProcessor.CommandName, this.isolationProcessor.Metadata.Value.CommandName);
Assert.AreEqual(null, this.isolationProcessor.Metadata.Value.ShortCommandName);
Assert.AreEqual(ArgumentProcessorPriority.Normal, this.isolationProcessor.Metadata.Value.Priority);
Assert.AreEqual(HelpContentPriority.InIsolationArgumentProcessorHelpPriority, this.isolationProcessor.Metadata.Value.HelpPriority);
}


[TestMethod]
public void InIsolationArgumentProcessorExecutorShouldThrowIfArgumentIsProvided()
{
Assert.ThrowsException<CommandLineException>(() => this.isolationProcessor.Executor.Value.Initialize("foo"));
}

}
}