From 6f859cb14c5a30be0f6973f8d12f3b5cb0c1c67b Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Wed, 15 Feb 2023 16:21:27 +0100 Subject: [PATCH] Add `dotnet vstest` deprecation message (#4297) --- src/vstest.console/CommandLine/Executor.cs | 16 ++++++- ...ateDotnetVStestMessageArgumentProcessor.cs | 47 +++++++++++++++++++ .../Utilities/ArgumentProcessorFactory.cs | 1 + .../Resources/Resources.Designer.cs | 11 ++++- src/vstest.console/Resources/Resources.resx | 5 +- .../Resources/xlf/Resources.cs.xlf | 5 ++ .../Resources/xlf/Resources.de.xlf | 5 ++ .../Resources/xlf/Resources.es.xlf | 5 ++ .../Resources/xlf/Resources.fr.xlf | 5 ++ .../Resources/xlf/Resources.it.xlf | 5 ++ .../Resources/xlf/Resources.ja.xlf | 5 ++ .../Resources/xlf/Resources.ko.xlf | 5 ++ .../Resources/xlf/Resources.pl.xlf | 5 ++ .../Resources/xlf/Resources.pt-BR.xlf | 5 ++ .../Resources/xlf/Resources.ru.xlf | 5 ++ .../Resources/xlf/Resources.tr.xlf | 5 ++ .../Resources/xlf/Resources.xlf | 5 ++ .../Resources/xlf/Resources.zh-Hans.xlf | 5 ++ .../Resources/xlf/Resources.zh-Hant.xlf | 5 ++ .../ExecutorUnitTests.cs | 19 ++++++++ ...tnetVStestMessageArgumentProcessorTests.cs | 46 ++++++++++++++++++ 21 files changed, 211 insertions(+), 4 deletions(-) create mode 100644 src/vstest.console/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessor.cs create mode 100644 test/vstest.console.UnitTests/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessorTests.cs diff --git a/src/vstest.console/CommandLine/Executor.cs b/src/vstest.console/CommandLine/Executor.cs index 954d15fe5a..dd547de8c8 100644 --- a/src/vstest.console/CommandLine/Executor.cs +++ b/src/vstest.console/CommandLine/Executor.cs @@ -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); } } @@ -434,7 +434,7 @@ private bool ExecuteArgumentProcessor(IArgumentProcessor processor, ref int exit /// /// Displays the Company and Copyright splash title info immediately after launch /// - private void PrintSplashScreen(bool isDiag) + private void PrintSplashScreen(bool isDiag, string[]? args) { string? assemblyVersion = Product.Version; if (!isDiag) @@ -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); } + /// + /// Display a warning if we're executed through `dotnet vstest` + /// + private void PrintWarningIfInvokedThroughDotnetVSTest(string[]? args) + { + if (ShowDeprecateDotnetVStestMessageArgumentProcessor.ContainsShowDeprecateDotnetVSTestMessageCommand(args)) + { + Output.Warning(false, CommandLineResources.VSTestDeprecationMessage); + } + } + /// /// Display a warning if we're running the runner on ARM64 but with a different current process architecture. /// diff --git a/src/vstest.console/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessor.cs b/src/vstest.console/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessor.cs new file mode 100644 index 0000000000..71db32aa9e --- /dev/null +++ b/src/vstest.console/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessor.cs @@ -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? _metadata; + private Lazy? _executor; + + public Lazy? Executor + { + get => _executor ??= new Lazy(() => + new ShowDeprecateDotnetVStestMessageProcessorExecutor()); + + set => _executor = value; + } + + public Lazy Metadata + => _metadata ??= new Lazy(() => 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) { } +} diff --git a/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs b/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs index f42c8170d8..d014395236 100644 --- a/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs +++ b/src/vstest.console/Processors/Utilities/ArgumentProcessorFactory.cs @@ -226,6 +226,7 @@ public IEnumerable GetArgumentProcessorsToAlwaysExecute() new ListSettingsProvidersArgumentProcessor(), new ListFullyQualifiedTestsArgumentProcessor(), new ListTestsTargetPathArgumentProcessor(), + new ShowDeprecateDotnetVStestMessageArgumentProcessor(), new EnvironmentArgumentProcessor() }; diff --git a/src/vstest.console/Resources/Resources.Designer.cs b/src/vstest.console/Resources/Resources.Designer.cs index 61cecdd3c2..06a734d6be 100644 --- a/src/vstest.console/Resources/Resources.Designer.cs +++ b/src/vstest.console/Resources/Resources.Designer.cs @@ -859,7 +859,7 @@ internal static string InvalidProcDumpDirectoryPath { } /// - /// Looks up a localized string similar to The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH). + /// Looks up a localized string similar to The directory specified for the procdump executable is not valid and the tool was not found inside environment variables (PROCDUMP_PATH, PATH). /// internal static string InvalidProcDumpToolDirectoryPath { get { @@ -1898,6 +1898,15 @@ internal static string UseVsixExtensionsValueRequired { } } + /// + /// Looks up a localized string similar to The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test.. + /// + internal static string VSTestDeprecationMessage { + get { + return ResourceManager.GetString("VSTestDeprecationMessage", resourceCulture); + } + } + /// /// Looks up a localized string similar to Logging Vstest Diagnostics in file: {0}. /// diff --git a/src/vstest.console/Resources/Resources.resx b/src/vstest.console/Resources/Resources.resx index bf730bc653..60d401156a 100644 --- a/src/vstest.console/Resources/Resources.resx +++ b/src/vstest.console/Resources/Resources.resx @@ -843,4 +843,7 @@ Error hosting communication channel. - + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.cs.xlf b/src/vstest.console/Resources/xlf/Resources.cs.xlf index ab923b4a13..579863c6cf 100644 --- a/src/vstest.console/Resources/xlf/Resources.cs.xlf +++ b/src/vstest.console/Resources/xlf/Resources.cs.xlf @@ -1234,6 +1234,11 @@ Argument AeDebugger {0} není platný. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.de.xlf b/src/vstest.console/Resources/xlf/Resources.de.xlf index dce6530f0f..227225523a 100644 --- a/src/vstest.console/Resources/xlf/Resources.de.xlf +++ b/src/vstest.console/Resources/xlf/Resources.de.xlf @@ -1234,6 +1234,11 @@ Das AeDebugger-Argument "{0}" ist ungültig. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.es.xlf b/src/vstest.console/Resources/xlf/Resources.es.xlf index 1fb2463652..c3e380a67b 100644 --- a/src/vstest.console/Resources/xlf/Resources.es.xlf +++ b/src/vstest.console/Resources/xlf/Resources.es.xlf @@ -1237,6 +1237,11 @@ El argumento AeDebugger '{0}' no es válido. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.fr.xlf b/src/vstest.console/Resources/xlf/Resources.fr.xlf index 9babf1f2ca..007a6dad0f 100644 --- a/src/vstest.console/Resources/xlf/Resources.fr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.fr.xlf @@ -1234,6 +1234,11 @@ Comportements actuellement pris en charge : L’argument AeDebugger '{0}' n’est pas valide. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.it.xlf b/src/vstest.console/Resources/xlf/Resources.it.xlf index 6921e02811..a82393f7e5 100644 --- a/src/vstest.console/Resources/xlf/Resources.it.xlf +++ b/src/vstest.console/Resources/xlf/Resources.it.xlf @@ -1234,6 +1234,11 @@ L'argomento '{0}' di AeDebugger non è valido. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ja.xlf b/src/vstest.console/Resources/xlf/Resources.ja.xlf index bf653b3f16..e850a282f9 100644 --- a/src/vstest.console/Resources/xlf/Resources.ja.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ja.xlf @@ -1234,6 +1234,11 @@ AeDebugger 引数 '{0}' は無効です。 + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ko.xlf b/src/vstest.console/Resources/xlf/Resources.ko.xlf index 44a97c0350..4a852da58e 100644 --- a/src/vstest.console/Resources/xlf/Resources.ko.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ko.xlf @@ -1234,6 +1234,11 @@ AeDebugger 인수 '{0}'이(가) 유효하지 않습니다. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.pl.xlf b/src/vstest.console/Resources/xlf/Resources.pl.xlf index eb837f02ad..c74e2e7f69 100644 --- a/src/vstest.console/Resources/xlf/Resources.pl.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pl.xlf @@ -1234,6 +1234,11 @@ Argument AeDebugger „{0}” jest nieprawidłowy. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf index 2cdc659caa..f78e26b275 100644 --- a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf @@ -1234,6 +1234,11 @@ Altere o prefixo de nível de diagnóstico do agente de console, como mostrado a O argumento do AeDebugger '{0}' não é válido. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.ru.xlf b/src/vstest.console/Resources/xlf/Resources.ru.xlf index dd752548ca..0e82c7691a 100644 --- a/src/vstest.console/Resources/xlf/Resources.ru.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ru.xlf @@ -1234,6 +1234,11 @@ Аргумент AeDebugger "{0}" недопустим. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.tr.xlf b/src/vstest.console/Resources/xlf/Resources.tr.xlf index be70a709ad..4046a8ee91 100644 --- a/src/vstest.console/Resources/xlf/Resources.tr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.tr.xlf @@ -1234,6 +1234,11 @@ Günlükler için izleme düzeyini aşağıda gösterildiği gibi değiştirin '{0}' AeDebugger bağımsız değişkeni geçerli değil. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.xlf b/src/vstest.console/Resources/xlf/Resources.xlf index 7ac5e87920..ea709d6b8d 100644 --- a/src/vstest.console/Resources/xlf/Resources.xlf +++ b/src/vstest.console/Resources/xlf/Resources.xlf @@ -1028,6 +1028,11 @@ Format : TestRunParameters.Parameter(name="<name>", value="<value>") Blame argument '{0}' is not valid. + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf index cfebb41783..f3a0b8aa55 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf @@ -1234,6 +1234,11 @@ AeDebugger 参数“{0}”无效。 + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf index 951b5ae0df..ea2ef7cc2a 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf @@ -1234,6 +1234,11 @@ AeDebugger 引數 '{0}' 無效。 + + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See https://aka.ms/dotnet-test. + + \ No newline at end of file diff --git a/test/vstest.console.UnitTests/ExecutorUnitTests.cs b/test/vstest.console.UnitTests/ExecutorUnitTests.cs index 12d253e25d..ef3aa7cbde 100644 --- a/test/vstest.console.UnitTests/ExecutorUnitTests.cs +++ b/test/vstest.console.UnitTests/ExecutorUnitTests.cs @@ -185,6 +185,25 @@ public void ExecuteShouldExitWithErrorOnResponseFileException() Assert.AreEqual(1, exitCode, "Response File Exception execution should exit with error."); } + [TestMethod] + [DataRow("--ShowDeprecateDotnetVSTestMessage")] + [DataRow("--showdeprecateDotnetvsTestMessage")] + public void ExecutorShouldPrintDotnetVSTestDeprecationMessage(string commandLine) + { + var mockOutput = new MockOutput(); + Mock processHelper = new(); + processHelper.Setup(x => x.GetCurrentProcessArchitecture()).Returns(PlatformArchitecture.X64); + processHelper.Setup(x => x.GetCurrentProcessId()).Returns(0); + Mock environment = new(); + environment.Setup(x => x.Architecture).Returns(PlatformArchitecture.X64); + + new Executor(mockOutput, _mockTestPlatformEventSource.Object, processHelper.Object, environment.Object).Execute(commandLine); + + Assert.AreEqual(5, mockOutput.Messages.Count); + Assert.AreEqual(OutputLevel.Warning, mockOutput.Messages[2].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[2].Message); + } + [TestMethod] public void ExecuteShouldNotThrowSettingsExceptionButLogOutput() { diff --git a/test/vstest.console.UnitTests/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessorTests.cs new file mode 100644 index 0000000000..742b1bde6b --- /dev/null +++ b/test/vstest.console.UnitTests/Processors/ShowDeprecateDotnetVStestMessageArgumentProcessorTests.cs @@ -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()); + } +}