diff --git a/src/dotnet/CommonOptions.cs b/src/dotnet/CommonOptions.cs index 30c88663e..ed00f490b 100644 --- a/src/dotnet/CommonOptions.cs +++ b/src/dotnet/CommonOptions.cs @@ -37,9 +37,9 @@ namespace Microsoft.DotNet.Cli .With(name: CommonLocalizableStrings.FrameworkArgumentName) .ForwardAsSingle(o => $"-property:TargetFramework={o.Arguments.Single()}")); - public static Option RuntimeOption(string description) => + public static Option RuntimeOption(string description, bool withShortOption = true) => Create.Option( - "-r|--runtime", + withShortOption ? "-r|--runtime" : "--runtime", description, Accept.ExactlyOneArgument() .WithSuggestionsFrom(_ => Suggest.RunTimesFromProjectFile()) diff --git a/src/dotnet/commands/dotnet-test/LocalizableStrings.resx b/src/dotnet/commands/dotnet-test/LocalizableStrings.resx index adb3d2065..88e7762ef 100644 --- a/src/dotnet/commands/dotnet-test/LocalizableStrings.resx +++ b/src/dotnet/commands/dotnet-test/LocalizableStrings.resx @@ -205,6 +205,9 @@ Outputs a 'Sequence.xml' file in the current directory that captures the order o The target framework to run tests for. The target framework must also be specified in the project file. + + The target runtime to test for. + The configuration to use for running tests. The default for most projects is 'Debug'. diff --git a/src/dotnet/commands/dotnet-test/TestCommandParser.cs b/src/dotnet/commands/dotnet-test/TestCommandParser.cs index 5cdd9336d..765a52072 100644 --- a/src/dotnet/commands/dotnet-test/TestCommandParser.cs +++ b/src/dotnet/commands/dotnet-test/TestCommandParser.cs @@ -56,6 +56,7 @@ namespace Microsoft.DotNet.Cli })), CommonOptions.ConfigurationOption(LocalizableStrings.ConfigurationOptionDescription), CommonOptions.FrameworkOption(LocalizableStrings.FrameworkOptionDescription), + CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription, withShortOption: false), Create.Option( "-o|--output", LocalizableStrings.CmdOutputDescription, diff --git a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.cs.xlf b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.cs.xlf index 5d7dd27c6..d3884a1dd 100644 --- a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.cs.xlf +++ b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.cs.xlf @@ -160,6 +160,11 @@ Výstupem je soubor Sequence.xml v aktuálním adresáři, do kterého se zaznam Konfigurace, která se má použít pro spuštění testů. Výchozí možností pro většinu projektů je Debug. + + The target runtime to test for. + The target runtime to test for. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.de.xlf b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.de.xlf index 7f23d7a05..c8a9f530b 100644 --- a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.de.xlf +++ b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.de.xlf @@ -160,6 +160,11 @@ Im aktuellen Verzeichnis wird eine Datei namens "Sequence.xml" ausgegeben, in de Die für die Testausführung zu verwendende Konfiguration. Standard für die meisten Projekte ist "Debug". + + The target runtime to test for. + The target runtime to test for. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.es.xlf b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.es.xlf index a2037a3e0..0bf4076ca 100644 --- a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.es.xlf +++ b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.es.xlf @@ -160,6 +160,11 @@ Crea un archivo de salida en el directorio actual como "Sequence.xml" que captur La configuración que se usará para ejecutar pruebas. El valor predeterminado para la mayoría de los proyectos es "Debug". + + The target runtime to test for. + The target runtime to test for. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.fr.xlf b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.fr.xlf index 8a124600e..42ea001ff 100644 --- a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.fr.xlf +++ b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.fr.xlf @@ -160,6 +160,11 @@ Elle génère dans le répertoire actif un fichier de sortie nommé 'Sequence.xm Configuration à utiliser pour l'exécution des tests. La valeur par défaut pour la plupart des projets est 'Debug'. + + The target runtime to test for. + The target runtime to test for. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.it.xlf b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.it.xlf index 925d4a42f..6a6e3817c 100644 --- a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.it.xlf +++ b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.it.xlf @@ -160,6 +160,11 @@ Crea nella directory corrente un file di output denominato "Sequence.xml", in cu Configurazione da usare per eseguire i test. L'impostazione predefinita per la maggior parte dei progetti è 'Debug'. + + The target runtime to test for. + The target runtime to test for. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.ja.xlf b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.ja.xlf index 1963ac99c..d83264770 100644 --- a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.ja.xlf +++ b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.ja.xlf @@ -160,6 +160,11 @@ Outputs a 'Sequence.xml' file in the current directory that captures the order o テストの実行に使用する構成。ほとんどのプロジェクトで、既定値は 'Debug' です。 + + The target runtime to test for. + The target runtime to test for. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.ko.xlf b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.ko.xlf index c44490c6b..2fb343328 100644 --- a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.ko.xlf +++ b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.ko.xlf @@ -160,6 +160,11 @@ Outputs a 'Sequence.xml' file in the current directory that captures the order o 테스트 실행에 사용할 구성입니다. 대부분의 프로젝트에서 기본값은 'Debug'입니다. + + The target runtime to test for. + The target runtime to test for. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.pl.xlf b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.pl.xlf index a35d0dfbd..4eba23180 100644 --- a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.pl.xlf +++ b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.pl.xlf @@ -160,6 +160,11 @@ Tworzy w bieżącym katalogu plik wyjściowy „Sequence.xml”, który przechwy Konfiguracja do użycia na potrzeby uruchamiania testów. W przypadku większości projektów ustawienie domyślne to „Debugowanie”. + + The target runtime to test for. + The target runtime to test for. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.pt-BR.xlf b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.pt-BR.xlf index ede1f8f7b..08ecb5e53 100644 --- a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.pt-BR.xlf @@ -160,6 +160,11 @@ Emite um arquivo 'Sequence.xml' no diretório atual que captura a ordem de execu A configuração a ser usada para executar testes. O padrão para a maioria dos projetos é 'Debug'. + + The target runtime to test for. + The target runtime to test for. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.ru.xlf b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.ru.xlf index 59e8f5aac..b8d3132bf 100644 --- a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.ru.xlf +++ b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.ru.xlf @@ -160,6 +160,11 @@ Outputs a 'Sequence.xml' file in the current directory that captures the order o Конфигурация для выполнения тестов. По умолчанию для большинства проектов используется "Debug". + + The target runtime to test for. + The target runtime to test for. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.tr.xlf b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.tr.xlf index 989cc60d4..f930e6eb5 100644 --- a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.tr.xlf +++ b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.tr.xlf @@ -160,6 +160,11 @@ Geçerli dizinde testin kilitlenmeden önceki test yürütme sırasını yakalay Testleri çalıştırmak için kullanılacak yapılandırma. Çoğu proje için varsayılan, ‘Hata Ayıklama’ seçeneğidir. + + The target runtime to test for. + The target runtime to test for. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.zh-Hans.xlf b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.zh-Hans.xlf index 6b1fcb73e..e327294fa 100644 --- a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.zh-Hans.xlf @@ -160,6 +160,11 @@ Outputs a 'Sequence.xml' file in the current directory that captures the order o 用于运行测试的配置。大多数项目的默认值是 "Debug"。 + + The target runtime to test for. + The target runtime to test for. + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.zh-Hant.xlf b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.zh-Hant.xlf index 83639c88b..0059fbc5e 100644 --- a/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/dotnet/commands/dotnet-test/xlf/LocalizableStrings.zh-Hant.xlf @@ -160,6 +160,11 @@ Outputs a 'Sequence.xml' file in the current directory that captures the order o 要用於執行測試的組態。大部分的專案預設為「偵錯」。 + + The target runtime to test for. + The target runtime to test for. + + \ No newline at end of file diff --git a/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs b/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs index 10fada845..5cf235b0a 100644 --- a/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs +++ b/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs @@ -312,6 +312,46 @@ namespace Microsoft.DotNet.Cli.Test.Tests result.ExitCode.Should().Be(1); } + [Fact] + public void ItTestsWithTheSpecifiedRuntimeOption() + { + var testInstance = TestAssets.Get("XunitCore") + .CreateInstance() + .WithSourceFiles(); + + var rootPath = testInstance.Root.FullName; + var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(); + + new BuildCommand() + .WithWorkingDirectory(rootPath) + .ExecuteWithCapturedOutput($"--runtime {rid}") + .Should() + .Pass() + .And.NotHaveStdErr(); + + var result = new DotnetTestCommand() + .WithWorkingDirectory(rootPath) + .ExecuteWithCapturedOutput($"{TestBase.ConsoleLoggerOutputNormal} --no-build --runtime {rid}"); + + result + .Should() + .NotHaveStdErrContaining("MSB1001") + .And + .HaveStdOutContaining(rid); + + if (!DotnetUnderTest.IsLocalized()) + { + result + .Should() + .HaveStdOutContaining("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.") + .And + .HaveStdOutContaining("Passed TestNamespace.VSTestXunitTests.VSTestXunitPassTest") + .And + .HaveStdOutContaining("Failed TestNamespace.VSTestXunitTests.VSTestXunitFailTest"); + } + + result.ExitCode.Should().Be(1); + } [WindowsOnlyFact] public void ItCreatesCoverageFileWhenCodeCoverageEnabledByRunsettings()