-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding /InIsolation flag for backward compatibility (#414)
- Loading branch information
1 parent
a55b993
commit 982cf7c
Showing
18 changed files
with
246 additions
and
1 deletion.
There are no files selected for viewing
116 changes: 116 additions & 0 deletions
116
src/vstest.console/Processors/InIsolationArgumentProcessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
test/vstest.console.UnitTests/Processors/InIsolationArgumentProcessorTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | ||
} | ||
|
||
} | ||
} |