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 dotnet vstest deprecation message #4297

Merged
merged 8 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
16 changes: 14 additions & 2 deletions src/vstest.console/CommandLine/Executor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ internal int Execute(params string[]? args)
// If we're postprocessing we don't need to show the splash
if (!ArtifactProcessingPostProcessModeProcessor.ContainsPostProcessCommand(args))
{
PrintSplashScreen(isDiag);
PrintSplashScreen(isDiag, args);
}
}

Expand Down Expand Up @@ -434,7 +434,7 @@ private bool ExecuteArgumentProcessor(IArgumentProcessor processor, ref int exit
/// <summary>
/// Displays the Company and Copyright splash title info immediately after launch
/// </summary>
private void PrintSplashScreen(bool isDiag)
private void PrintSplashScreen(bool isDiag, string[]? args)
{
string? assemblyVersion = Product.Version;
if (!isDiag)
Expand All @@ -452,9 +452,21 @@ private void PrintSplashScreen(bool isDiag)
Output.WriteLine(commandLineBanner, OutputLevel.Information);
Output.WriteLine(CommandLineResources.CopyrightCommandLineTitle, OutputLevel.Information);
PrintWarningIfRunningEmulatedOnArm64();
PrintWarningIfInvokedThroughDotnetVSTest(args);
Output.WriteLine(string.Empty, OutputLevel.Information);
}

/// <summary>
/// Display a warning if we're executed through `dotnet vstest`
/// </summary>
private void PrintWarningIfInvokedThroughDotnetVSTest(string[]? args)
{
if (ShowDeprecateDotnetVStestMessageArgumentProcessor.ContainsShowDeprecateDotnetVSTestMessageCommand(args))
{
Output.Warning(false, CommandLineResources.VSTestDeprecationMessage);
}
}

/// <summary>
/// Display a warning if we're running the runner on ARM64 but with a different current process architecture.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// 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;
using System.Linq;

namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors;
internal class ShowDeprecateDotnetVStestMessageArgumentProcessor : IArgumentProcessor
{
public const string CommandName = "/ShowDeprecateDotnetVSTestMessage";
private Lazy<IArgumentProcessorCapabilities>? _metadata;
private Lazy<IArgumentExecutor>? _executor;

public Lazy<IArgumentExecutor>? Executor
{
get => _executor ??= new Lazy<IArgumentExecutor>(() =>
new ShowDeprecateDotnetVStestMessageProcessorExecutor());

set => _executor = value;
}

public Lazy<IArgumentProcessorCapabilities> Metadata
=> _metadata ??= new Lazy<IArgumentProcessorCapabilities>(() => new ShowDeprecateDotnetVStestMessageProcessorCapabilities());

public static bool ContainsShowDeprecateDotnetVSTestMessageCommand(string[]? args) =>
args?.Contains("--ShowDeprecateDotnetVSTestMessage", StringComparer.OrdinalIgnoreCase) == true;
}

internal class ShowDeprecateDotnetVStestMessageProcessorCapabilities : BaseArgumentProcessorCapabilities
{
public override string CommandName => ShowDeprecateDotnetVStestMessageArgumentProcessor.CommandName;

public override bool AllowMultiple => false;

public override ArgumentProcessorPriority Priority => ArgumentProcessorPriority.CliRunSettings;

public override HelpContentPriority HelpPriority => HelpContentPriority.None;

public override string? HelpContentResourceName => null;
}

internal class ShowDeprecateDotnetVStestMessageProcessorExecutor : IArgumentExecutor
{
public ArgumentProcessorResult Execute() => ArgumentProcessorResult.Success;

public void Initialize(string? argument) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ public IEnumerable<IArgumentProcessor> GetArgumentProcessorsToAlwaysExecute()
new ListSettingsProvidersArgumentProcessor(),
new ListFullyQualifiedTestsArgumentProcessor(),
new ListTestsTargetPathArgumentProcessor(),
new ShowDeprecateDotnetVStestMessageArgumentProcessor(),
new EnvironmentArgumentProcessor()
};

Expand Down
11 changes: 10 additions & 1 deletion src/vstest.console/Resources/Resources.Designer.cs

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

5 changes: 4 additions & 1 deletion src/vstest.console/Resources/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -843,4 +843,7 @@
<data name="ErrorHostingCommunicationChannel" xml:space="preserve">
<value>Error hosting communication channel.</value>
</data>
</root>
<data name="VSTestDeprecationMessage" xml:space="preserve">
<value>The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</value>
</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 @@ -1234,6 +1234,11 @@
<target state="translated">Argument AeDebugger {0} není platný.</target>
<note></note>
</trans-unit>
<trans-unit id="VSTestDeprecationMessage">
<source>The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</source>
<target state="new">The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</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 @@ -1234,6 +1234,11 @@
<target state="translated">Das AeDebugger-Argument "{0}" ist ungültig.</target>
<note></note>
</trans-unit>
<trans-unit id="VSTestDeprecationMessage">
<source>The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</source>
<target state="new">The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</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 @@ -1237,6 +1237,11 @@
<target state="translated">El argumento AeDebugger '{0}' no es válido.</target>
<note></note>
</trans-unit>
<trans-unit id="VSTestDeprecationMessage">
<source>The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</source>
<target state="new">The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</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 @@ -1234,6 +1234,11 @@ Comportements actuellement pris en charge :
<target state="translated">L’argument AeDebugger '{0}' n’est pas valide.</target>
<note></note>
</trans-unit>
<trans-unit id="VSTestDeprecationMessage">
<source>The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</source>
<target state="new">The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</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 @@ -1234,6 +1234,11 @@
<target state="translated">L'argomento '{0}' di AeDebugger non è valido.</target>
<note></note>
</trans-unit>
<trans-unit id="VSTestDeprecationMessage">
<source>The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</source>
<target state="new">The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</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 @@ -1234,6 +1234,11 @@
<target state="translated">AeDebugger 引数 '{0}' は無効です。</target>
<note></note>
</trans-unit>
<trans-unit id="VSTestDeprecationMessage">
<source>The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</source>
<target state="new">The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</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 @@ -1234,6 +1234,11 @@
<target state="translated">AeDebugger 인수 '{0}'이(가) 유효하지 않습니다.</target>
<note></note>
</trans-unit>
<trans-unit id="VSTestDeprecationMessage">
<source>The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</source>
<target state="new">The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</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 @@ -1234,6 +1234,11 @@
<target state="translated">Argument AeDebugger „{0}” jest nieprawidłowy.</target>
<note></note>
</trans-unit>
<trans-unit id="VSTestDeprecationMessage">
<source>The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</source>
<target state="new">The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</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 @@ -1234,6 +1234,11 @@ Altere o prefixo de nível de diagnóstico do agente de console, como mostrado a
<target state="translated">O argumento do AeDebugger '{0}' não é válido.</target>
<note></note>
</trans-unit>
<trans-unit id="VSTestDeprecationMessage">
<source>The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</source>
<target state="new">The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</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 @@ -1234,6 +1234,11 @@
<target state="translated">Аргумент AeDebugger "{0}" недопустим.</target>
<note></note>
</trans-unit>
<trans-unit id="VSTestDeprecationMessage">
<source>The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</source>
<target state="new">The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</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 @@ -1234,6 +1234,11 @@ Günlükler için izleme düzeyini aşağıda gösterildiği gibi değiştirin
<target state="translated">'{0}' AeDebugger bağımsız değişkeni geçerli değil.</target>
<note></note>
</trans-unit>
<trans-unit id="VSTestDeprecationMessage">
<source>The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</source>
<target state="new">The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/vstest.console/Resources/xlf/Resources.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,11 @@ Format : TestRunParameters.Parameter(name="&lt;name&gt;", value="&lt;value&gt;")
<target state="new">Blame argument '{0}' is not valid.</target>
<note></note>
</trans-unit>
<trans-unit id="VSTestDeprecationMessage">
<source>The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</source>
<target state="new">The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</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 @@ -1234,6 +1234,11 @@
<target state="translated">AeDebugger 参数“{0}”无效。</target>
<note></note>
</trans-unit>
<trans-unit id="VSTestDeprecationMessage">
<source>The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</source>
<target state="new">The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</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 @@ -1234,6 +1234,11 @@
<target state="translated">AeDebugger 引數 '{0}' 無效。</target>
<note></note>
</trans-unit>
<trans-unit id="VSTestDeprecationMessage">
<source>The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</source>
<target state="new">The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
19 changes: 19 additions & 0 deletions test/vstest.console.UnitTests/ExecutorUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,25 @@ public void ExecutorShouldPrintRunnerArchitecture()
Assert.IsFalse(mockOutput.Messages.Any(message => message.Message!.Contains("vstest.console.exe is running in emulated mode")));
}

[TestMethod]
[DataRow("--ShowDeprecateDotnetVSTestMessage")]
Evangelink marked this conversation as resolved.
Show resolved Hide resolved
[DataRow("--showdeprecateDotnetvTestMessage")]
MarcoRossignoli marked this conversation as resolved.
Show resolved Hide resolved
public void ExecutorShouldPrintDotnetVSTestDeprecationMessage(string commandLine)
{
var mockOutput = new MockOutput();
Mock<IProcessHelper> processHelper = new();
processHelper.Setup(x => x.GetCurrentProcessArchitecture()).Returns(PlatformArchitecture.X64);
processHelper.Setup(x => x.GetCurrentProcessId()).Returns(0);
Mock<IEnvironment> environment = new();
environment.Setup(x => x.Architecture).Returns(PlatformArchitecture.X64);

new Executor(mockOutput, _mockTestPlatformEventSource.Object, processHelper.Object, environment.Object).Execute(commandLine);

Assert.AreEqual(6, mockOutput.Messages.Count);
Assert.AreEqual(OutputLevel.Warning, mockOutput.Messages[3].Level);
Assert.AreEqual("The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.", mockOutput.Messages[3].Message);
}

private class MockOutput : IOutput
{
public List<OutputMessage> Messages { get; set; } = new List<OutputMessage>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// 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.TestPlatform.CommandLine.Processors;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace vstest.console.UnitTests.Processors;

[TestClass]
[TestCategory("Windows-Review")]
public class ShowDeprecateDotnetVStestMessageArgumentProcessorTests
{
[TestMethod]
public void ShowDeprecateDotnetVStestMessageProcessorCommandName()
{
Assert.AreEqual("/ShowDeprecateDotnetVSTestMessage", ShowDeprecateDotnetVStestMessageArgumentProcessor.CommandName);
}

[TestMethod]
public void ShowDeprecateDotnetVStestMessageProcessorCapabilities()
{
ShowDeprecateDotnetVStestMessageProcessorCapabilities showDeprecateDotnetVStestMessageProcessorCapabilities = new();
Assert.IsNull(showDeprecateDotnetVStestMessageProcessorCapabilities.HelpContentResourceName);
Assert.IsFalse(showDeprecateDotnetVStestMessageProcessorCapabilities.IsAction);
Assert.IsFalse(showDeprecateDotnetVStestMessageProcessorCapabilities.AllowMultiple);
Assert.AreEqual(ArgumentProcessorPriority.CliRunSettings, showDeprecateDotnetVStestMessageProcessorCapabilities.Priority);
Assert.AreEqual(HelpContentPriority.None, showDeprecateDotnetVStestMessageProcessorCapabilities.HelpPriority);
}

[TestMethod]
public void ShowDeprecateDotnetVStestMessageArgumentProcessorReturnsCorrectTypes()
{
ShowDeprecateDotnetVStestMessageArgumentProcessor showDeprecateDotnetVStestMessageArgumentProcessor = new();
Assert.IsInstanceOfType(showDeprecateDotnetVStestMessageArgumentProcessor.Executor!.Value, typeof(ShowDeprecateDotnetVStestMessageProcessorExecutor));
Assert.IsInstanceOfType(showDeprecateDotnetVStestMessageArgumentProcessor.Metadata!.Value, typeof(ShowDeprecateDotnetVStestMessageProcessorCapabilities));
}


[TestMethod]
public void ShowDeprecateDotnetVStestMessageProcessorExecutor_Succeded()
{
ShowDeprecateDotnetVStestMessageProcessorExecutor showDeprecateDotnetVStestMessageProcessorExecutor = new();
showDeprecateDotnetVStestMessageProcessorExecutor.Initialize("we will ignore the param");
Assert.AreEqual(ArgumentProcessorResult.Success, showDeprecateDotnetVStestMessageProcessorExecutor.Execute());
}
}