From f60b214a6758ed88df415441aa51a48ce7ea615e Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Tue, 9 Oct 2018 11:17:14 +0530 Subject: [PATCH 01/19] ExceptionWhenTargetingDiffFramworksPlat --- .../InferRunSettingsHelper.cs | 42 ++++- src/vstest.console/CommandLine/InferHelper.cs | 22 ++- .../Resources/Resources.Designer.cs | 11 ++ src/vstest.console/Resources/Resources.resx | 3 + .../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 + .../TestPlatformHelpers/TestRequestManager.cs | 18 ++- .../FrameworkTests.cs | 9 +- .../InferRunSettingsHelperTests.cs | 12 +- .../CommandLine/InferHelperTests.cs | 48 +++--- .../TestRequestManagerTests.cs | 152 ++++++++++++++++-- 23 files changed, 327 insertions(+), 60 deletions(-) diff --git a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs index 882ad87a88..f563dd5c1b 100644 --- a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs +++ b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs @@ -612,18 +612,21 @@ public static bool TryGetFrameworkXml(XPathNavigator runSettingsNavigator, out s /// Returns the sources matching the specified platform and framework settings. /// For incompatible sources, warning is added to incompatibleSettingWarning. /// - public static IEnumerable FilterCompatibleSources(Architecture chosenPlatform, Framework chosenFramework, IDictionary sourcePlatforms, IDictionary sourceFrameworks, out String incompatibleSettingWarning) + public static IEnumerable FilterCompatibleSources(Architecture chosenPlatform, Framework chosenFramework, IDictionary sourcePlatforms, IDictionary sourceFrameworks, out String incompatibleSettingWarning, out bool incompatibilityErrorFound) { incompatibleSettingWarning = string.Empty; + bool incompatibilityFound = false; + incompatibilityErrorFound = false; List compatibleSources = new List(); StringBuilder warnings = new StringBuilder(); warnings.AppendLine(); - bool incompatiblityFound = false; + foreach (var source in sourcePlatforms.Keys) { Architecture actualPlatform = sourcePlatforms[source]; Framework actualFramework = sourceFrameworks[source]; bool isSettingIncompatible = IsSettingIncompatible(actualPlatform, chosenPlatform, actualFramework, chosenFramework); + incompatibilityErrorFound = IsFrameworkRuntimeIncompatible(actualFramework, chosenFramework) || IsPlatformArchitectureIncompatible(actualPlatform, chosenPlatform); if (isSettingIncompatible) { string incompatiblityMessage; @@ -632,15 +635,14 @@ public static IEnumerable FilterCompatibleSources(Architecture chosenPla incompatiblityMessage = string.Format(CultureInfo.CurrentCulture, OMResources.SourceIncompatible, onlyFileName, actualFramework.Version, actualPlatform); warnings.AppendLine(incompatiblityMessage); - incompatiblityFound = true; + incompatibilityFound = true; } else { compatibleSources.Add(source); } } - - if (incompatiblityFound) + if (incompatibilityFound || incompatibilityErrorFound) { incompatibleSettingWarning = string.Format(CultureInfo.CurrentCulture, OMResources.DisplayChosenSettings, chosenFramework, chosenPlatform, warnings.ToString(), multiTargettingForwardLink); } @@ -685,5 +687,35 @@ private static bool IsFrameworkIncompatible(Framework sourceFramework, Framework } return !sourceFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase); } + + /// + /// Returns true if source platform is incompatible with target platform. + /// + private static bool IsPlatformArchitectureIncompatible(Architecture sourcePlatform, Architecture targetPlatform) + { + if (sourcePlatform == Architecture.X86 && targetPlatform == Architecture.X64 || + sourcePlatform == Architecture.X64 && targetPlatform == Architecture.X86) + { + return true; + } + + return false; + } + + /// + /// Returns true if source Framework Runtime is incompatible with target Framework. + /// + private static bool IsFrameworkRuntimeIncompatible(Framework sourceFramework, Framework targetFramework) + { + string sourceFrameworkName = sourceFramework.Name.Split(',')[0]; + string targetFrameworkName = targetFramework.Name.Split(',')[0]; + + if(sourceFrameworkName.Equals(".NETFramework",StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(".NETCoreApp", StringComparison.OrdinalIgnoreCase) || + sourceFrameworkName.Equals(".NETCoreApp", StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(".NETFramework", StringComparison.OrdinalIgnoreCase)) + { + return true; + } + return false; + } } } diff --git a/src/vstest.console/CommandLine/InferHelper.cs b/src/vstest.console/CommandLine/InferHelper.cs index f9dda8b734..05246e75e1 100644 --- a/src/vstest.console/CommandLine/InferHelper.cs +++ b/src/vstest.console/CommandLine/InferHelper.cs @@ -27,9 +27,10 @@ internal InferHelper(IAssemblyMetadataProvider assemblyMetadataProvider) /// /// Determines Architecture from sources. /// - public Architecture AutoDetectArchitecture(List sources, IDictionary sourcePlatforms) + public Architecture AutoDetectArchitecture(List sources, IDictionary sourcePlatforms, out bool isArchitectureIncompatible) { Architecture architecture = Constants.DefaultPlatform; + isArchitectureIncompatible = false; try { if (sources != null && sources.Count > 0) @@ -66,6 +67,7 @@ public Architecture AutoDetectArchitecture(List sources, IDictionary sources, IDictionary /// Determines Framework from sources. /// - public Framework AutoDetectFramework(List sources, IDictionary sourceFrameworkVersions) + public Framework AutoDetectFramework(List sources, IDictionary sourceFrameworkVersions, out bool isFrameworkIncompatible) { Framework framework = Framework.DefaultFramework; + isFrameworkIncompatible = false; try { if (sources != null && sources.Count > 0) { var finalFx = DetermineFrameworkName(sources, sourceFrameworkVersions, out var conflictInFxIdentifier); framework = Framework.FromString(finalFx.FullName); - if (conflictInFxIdentifier && EqtTrace.IsInfoEnabled) + + if (conflictInFxIdentifier) { - // TODO Log to console and client. - EqtTrace.Info( - "conflicts in Framework indentifier of provided sources(test assemblies), using default framework:{0}", - framework); + isFrameworkIncompatible = true; + if (EqtTrace.IsInfoEnabled) + { + // TODO Log to console and client. + EqtTrace.Info( + "conflicts in Framework indentifier of provided sources(test assemblies), using default framework:{0}", + framework); + } } } } diff --git a/src/vstest.console/Resources/Resources.Designer.cs b/src/vstest.console/Resources/Resources.Designer.cs index 77784baf82..f6083df49b 100644 --- a/src/vstest.console/Resources/Resources.Designer.cs +++ b/src/vstest.console/Resources/Resources.Designer.cs @@ -1967,5 +1967,16 @@ public static string DataCollectorFriendlyNameInvalid return ResourceManager.GetString("DataCollectorFriendlyNameInvalid", resourceCulture); } } + + /// + /// ConflictInFrameworkPlatform + /// + public static string ConflictInFrameworkPlatform + { + get + { + return ResourceManager.GetString("ConflictInFrameworkPlatform", resourceCulture); + } + } } } diff --git a/src/vstest.console/Resources/Resources.resx b/src/vstest.console/Resources/Resources.resx index a84f2781a5..47d1dcfe17 100644 --- a/src/vstest.console/Resources/Resources.resx +++ b/src/vstest.console/Resources/Resources.resx @@ -718,4 +718,7 @@ Logger argument '{0}' is not valid. + + Conflicts in framework/platform identifier of provided sources. + \ 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 1763ea111e..264ae068b9 100644 --- a/src/vstest.console/Resources/xlf/Resources.cs.xlf +++ b/src/vstest.console/Resources/xlf/Resources.cs.xlf @@ -1637,6 +1637,11 @@ Zadání Framework35 není podporováno. U projektů mířících na .Net Framework 3.5 prosím použijte Framework40, aby testy v CLR 4.0 běžely v režimu kompatibility. + + Conflicts in framework/platform identifier of provided sources. + Conflicts in framework/platform identifier of provided sources. + + \ 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 12c8ab24ce..84a020c163 100644 --- a/src/vstest.console/Resources/xlf/Resources.de.xlf +++ b/src/vstest.console/Resources/xlf/Resources.de.xlf @@ -1637,6 +1637,11 @@ Framework35 wird nicht unterstützt. Verwenden Sie für Projekte, die auf .Net Framework 3.5 ausgerichtet sind, Framework40 zum Ausführen von Tests im "Kompatibilitätsmodus" von CLR 4.0. + + Conflicts in framework/platform identifier of provided sources. + Conflicts in framework/platform identifier of provided sources. + + \ 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 0a6a9e954b..8212a7329a 100644 --- a/src/vstest.console/Resources/xlf/Resources.es.xlf +++ b/src/vstest.console/Resources/xlf/Resources.es.xlf @@ -1642,6 +1642,11 @@ No se admite Framework35. Para proyectos con destino .Net Framework 3.5, use Framework40 para ejecutar las pruebas en "modo de compatibilidad" de CLR 4.0. + + Conflicts in framework/platform identifier of provided sources. + Conflicts in framework/platform identifier of provided sources. + + \ 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 d6c15855dc..46bc719637 100644 --- a/src/vstest.console/Resources/xlf/Resources.fr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.fr.xlf @@ -1637,6 +1637,11 @@ Framework35 n'est pas pris en charge. Pour les projets ciblant .Net Framework 3.5, utilisez Framework40 pour exécuter les tests dans CLR 4.0 en "mode compatibilité". + + Conflicts in framework/platform identifier of provided sources. + Conflicts in framework/platform identifier of provided sources. + + \ 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 b47fea32a4..414824411c 100644 --- a/src/vstest.console/Resources/xlf/Resources.it.xlf +++ b/src/vstest.console/Resources/xlf/Resources.it.xlf @@ -1637,6 +1637,11 @@ Framework35 non è supportato. Per i progetti destinati a .NET Framework 3.5, usare Framework40 per eseguire i test nella modalità di compatibilità di CLR 4.0. + + Conflicts in framework/platform identifier of provided sources. + Conflicts in framework/platform identifier of provided sources. + + \ 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 a2beac5a71..e39ee5f980 100644 --- a/src/vstest.console/Resources/xlf/Resources.ja.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ja.xlf @@ -1637,6 +1637,11 @@ Framework35 はサポートされていません。.Net Framework 3.5 を対象とするプロジェクトでは、Framework40 を使用して CLR 4.0 の "互換モード" でテストを実行してください。 + + Conflicts in framework/platform identifier of provided sources. + Conflicts in framework/platform identifier of provided sources. + + \ 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 563a694a08..5de00cdc3b 100644 --- a/src/vstest.console/Resources/xlf/Resources.ko.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ko.xlf @@ -1637,6 +1637,11 @@ Framework35는 지원되지 않습니다. .NET Framework 3.5를 대상으로 하는 프로젝트의 경우 Framework40을 사용하여 CLR 4.0 "호환 모드"에서 테스트를 실행하세요. + + Conflicts in framework/platform identifier of provided sources. + Conflicts in framework/platform identifier of provided sources. + + \ 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 84bcdabc26..324922ea30 100644 --- a/src/vstest.console/Resources/xlf/Resources.pl.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pl.xlf @@ -1635,6 +1635,11 @@ Wersja Framework35 nie jest obsługiwana. W przypadku projektów przeznaczonych dla programu .Net Framework 3.5 użyj wersji Framework40 do uruchamiania testów w „trybie zgodności” CLR 4.0. + + Conflicts in framework/platform identifier of provided sources. + Conflicts in framework/platform identifier of provided sources. + + \ 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 d9bbe2d342..ec6ee2a71d 100644 --- a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf @@ -1635,6 +1635,11 @@ Não há suporte para Framework35. Para projetos com .Net Framework 3.5 de destino, use o Framework40 para executar testes em “modo de compatibilidade” CLR 4.0. + + Conflicts in framework/platform identifier of provided sources. + Conflicts in framework/platform identifier of provided sources. + + \ 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 f6de314c33..6a535753c5 100644 --- a/src/vstest.console/Resources/xlf/Resources.ru.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ru.xlf @@ -1637,6 +1637,11 @@ Framework35 не поддерживается. В проектах для .Net Framework 3.5 запускайте тесты в режиме совместимости CLR 4.0 с использованием Framework40. + + Conflicts in framework/platform identifier of provided sources. + Conflicts in framework/platform identifier of provided sources. + + \ 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 16bf48729b..3de8decaa0 100644 --- a/src/vstest.console/Resources/xlf/Resources.tr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.tr.xlf @@ -1637,6 +1637,11 @@ Framework35 desteklenmiyor. .NET Framework 3.5’i hedefleyen projeler için lütfen Framework40 kullanarak testleri CLR 4.0’ın “uyumluluk modunda” çalıştırın. + + Conflicts in framework/platform identifier of provided sources. + Conflicts in framework/platform identifier of provided sources. + + \ 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 c89c7b3ee5..66a99b65c2 100644 --- a/src/vstest.console/Resources/xlf/Resources.xlf +++ b/src/vstest.console/Resources/xlf/Resources.xlf @@ -819,6 +819,11 @@ Framework35 not supported. Use Framework40 or above to run tests in CLR 4.0 "compatibly mode". + + Conflicts in framework/platform identifier of provided sources. + Conflicts in framework/platform identifier of provided sources. + + \ 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 2775c59a2d..cdc84091b0 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf @@ -1637,6 +1637,11 @@ Framework35 不受支持。对于面向 .Net Framework 3.5 的项目,请使用 Framework40 在 CLR 4.0“兼容性模式”下运行测试。 + + Conflicts in framework/platform identifier of provided sources. + Conflicts in framework/platform identifier of provided sources. + + \ 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 6e9b8563bc..2969fbd4a2 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf @@ -1637,6 +1637,11 @@ 不支援 Framework35。若為以 .Net Framework 3.5 為目標的專案,請使用 Framework40 在 CLR 4.0「相容模式」中執行測試。 + + Conflicts in framework/platform identifier of provided sources. + Conflicts in framework/platform identifier of provided sources. + + \ No newline at end of file diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index 8ac9548de3..71a09180af 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -363,12 +363,18 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List sou var navigator = document.CreateNavigator(); - var inferedFramework = inferHelper.AutoDetectFramework(sources, sourceFrameworks); + var inferedFramework = inferHelper.AutoDetectFramework(sources, sourceFrameworks, out var isFrameworkIncompatible); Framework chosenFramework; - var inferedPlatform = inferHelper.AutoDetectArchitecture(sources, sourcePlatforms); + var inferedPlatform = inferHelper.AutoDetectArchitecture(sources, sourcePlatforms, out var isPlatformIncompatible); Architecture chosenPlatform; - // Update frmaework and platform if required. For commandline scenario update happens in ArgumentProcessor. + if (isFrameworkIncompatible || isPlatformIncompatible) + { + throw new TestPlatformException(Resources.ConflictInFrameworkPlatform); + // throw new TestPlatformException("Conflicts in framework/platform identifier of provided sources."); + } + + // Update framework and platform if required. For commandline scenario update happens in ArgumentProcessor. bool updateFramework = IsAutoFrameworkDetectRequired(navigator, out chosenFramework); bool updatePlatform = IsAutoPlatformDetectRequired(navigator, out chosenPlatform); @@ -386,11 +392,15 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List sou settingsUpdated = true; } - var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(chosenPlatform, chosenFramework, sourcePlatforms, sourceFrameworks, out var incompatibleSettingWarning); + var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(chosenPlatform, chosenFramework, sourcePlatforms, sourceFrameworks, out var incompatibleSettingWarning, out var incompatibiltyErrorFound); if (!string.IsNullOrEmpty(incompatibleSettingWarning)) { EqtTrace.Info(incompatibleSettingWarning); + if(incompatibiltyErrorFound) + { + throw new TestPlatformException(incompatibleSettingWarning); + } ConsoleLogger.RaiseTestRunWarning(incompatibleSettingWarning); } diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs index fd7dbb729a..ef7343f77b 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs @@ -41,14 +41,7 @@ public void OnWrongFrameworkPassedTestRunShouldNotRun(RunnerInfo runnerInfo) } this.InvokeVsTest(arguments); - if (runnerInfo.TargetFramework.Contains("netcore")) - { - this.StdOutputContains("No test is available"); - } - else - { - this.StdErrorContains("Test Run Aborted."); - } + this.StdErrorContains("Following DLL(s) do not match framework/platform settings."); } } } \ No newline at end of file diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs index d3baeacbb5..713e3a91fe 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs @@ -412,7 +412,8 @@ public void FilterCompatibleSourcesShouldIdentifyIncomaptiableSourcesAndConstruc #endregion string warningMessage = string.Empty; - var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, frameworkNet47, sourceArchitectures, sourceFrameworks, out warningMessage); + bool incompatibilityFound; + var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, frameworkNet47, sourceArchitectures, sourceFrameworks, out warningMessage, out incompatibilityFound); // None of the DLLs passed are compatible to the chosen settings Assert.AreEqual(0, compatibleSources.Count()); @@ -435,7 +436,8 @@ public void FilterCompatibleSourcesShouldIdentifyCompatibleSources() var expected = string.Format(CultureInfo.CurrentCulture, OMResources.DisplayChosenSettings, frameworkNet45, Constants.DefaultPlatform, sb.ToString(), @"http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409"); string warningMessage = string.Empty; - var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, frameworkNet45, sourceArchitectures, sourceFrameworks, out warningMessage); + bool incompatibilityFound; + var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, frameworkNet45, sourceArchitectures, sourceFrameworks, out warningMessage, out incompatibilityFound); // only "x86net45.dll" is the compatible source Assert.AreEqual(1, compatibleSources.Count()); @@ -449,7 +451,8 @@ public void FilterCompatibleSourcesShouldNotComposeWarningIfSettingsAreCorrect() sourceFrameworks["x86net45.dll"] = frameworkNet45; string warningMessage = string.Empty; - var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, frameworkNet45, sourceArchitectures, sourceFrameworks, out warningMessage); + bool incompatibilityFound; + var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, frameworkNet45, sourceArchitectures, sourceFrameworks, out warningMessage, out incompatibilityFound); // only "x86net45.dll" is the compatible source Assert.AreEqual(1, compatibleSources.Count()); @@ -463,7 +466,8 @@ public void FilterCompatibleSourcesShouldRetrunWarningMessageIfNoConflict() sourceFrameworks["x64net45.exe"] = frameworkNet45; string warningMessage = string.Empty; - var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Architecture.X64, frameworkNet45, sourceArchitectures, sourceFrameworks, out warningMessage); + bool incompatibilityFound; + var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Architecture.X64, frameworkNet45, sourceArchitectures, sourceFrameworks, out warningMessage, out incompatibilityFound); Assert.IsTrue(string.IsNullOrEmpty(warningMessage)); } diff --git a/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs b/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs index 4c35efddd4..a073efc4bf 100644 --- a/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs +++ b/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs @@ -26,6 +26,8 @@ public class InferHelperTests private readonly Framework frameworkCore11 = Framework.FromString(".NETCoreApp,Version=1.1"); private IDictionary sourceFrameworks; private IDictionary sourceArchitectures; + bool isArchitectureIncompatible; + bool isFrameworkIncompatible; public InferHelperTests() { @@ -33,51 +35,53 @@ public InferHelperTests() inferHelper = new InferHelper(this.mockAssemblyHelper.Object); sourceFrameworks = new Dictionary(); sourceArchitectures = new Dictionary(); + this.isArchitectureIncompatible = false; + this.isFrameworkIncompatible = false; } [TestMethod] public void AutoDetectArchitectureShouldReturnDefaultArchitectureOnNullSources() { - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(null, sourceArchitectures)); + Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(null, sourceArchitectures, out this.isArchitectureIncompatible)); } [TestMethod] public void AutoDetectArchitectureShouldReturnDefaultArchitectureOnEmptySources() { - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List(0), sourceArchitectures)); + Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List(0), sourceArchitectures, out this.isArchitectureIncompatible)); } [TestMethod] public void AutoDetectArchitectureShouldReturnDefaultArchitectureOnNullItemInSources() { - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List(){null}, sourceArchitectures)); + Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List(){null}, sourceArchitectures, out this.isArchitectureIncompatible)); } [TestMethod] public void AutoDetectArchitectureShouldReturnDefaultArchitectureOnWhiteSpaceItemInSources() { - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { " "}, sourceArchitectures)); + Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { " "}, sourceArchitectures, out this.isArchitectureIncompatible)); } [TestMethod] public void AutoDetectArchitectureShouldReturnCorrectArchForOneSource() { this.mockAssemblyHelper.Setup(ah => ah.GetArchitecture(It.IsAny())).Returns(Architecture.X86); - Assert.AreEqual(Architecture.X86, inferHelper.AutoDetectArchitecture(new List(){"1.dll"}, sourceArchitectures)); + Assert.AreEqual(Architecture.X86, inferHelper.AutoDetectArchitecture(new List(){"1.dll"}, sourceArchitectures, out this.isArchitectureIncompatible)); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny())); } [TestMethod] public void AutoDetectArchitectureShouldReturnCorrectDefaultArchForNotDotNetAssembly() { - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { "NotDotNetAssebly.appx" }, sourceArchitectures)); + Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { "NotDotNetAssebly.appx" }, sourceArchitectures, out this.isArchitectureIncompatible)); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Never); } [TestMethod] public void AutoDetectArchitectureShouldSetAnyCpuArchForNotDotNetAssembly() { - inferHelper.AutoDetectArchitecture(new List() { "NotDotNetAssebly.appx" }, sourceArchitectures); + inferHelper.AutoDetectArchitecture(new List() { "NotDotNetAssebly.appx" }, sourceArchitectures, out this.isArchitectureIncompatible); Assert.AreEqual(Architecture.AnyCPU, sourceArchitectures["NotDotNetAssebly.appx"]); } @@ -86,7 +90,7 @@ public void AutoDetectArchitectureShouldReturnDefaultArchForAllAnyCpuAssemblies( { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU); - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "AnyCPU2.exe", "AnyCPU3.dll" }, sourceArchitectures)); + Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "AnyCPU2.exe", "AnyCPU3.dll" }, sourceArchitectures, out this.isArchitectureIncompatible)); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); } @@ -95,7 +99,7 @@ public void AutoDetectArchitectureShouldReturnX86ArchIfOneX86AssemblyAndRestAnyC { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.X86); - Assert.AreEqual(Architecture.X86, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "AnyCPU2.exe", "x86.dll" }, sourceArchitectures)); + Assert.AreEqual(Architecture.X86, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "AnyCPU2.exe", "x86.dll" }, sourceArchitectures, out this.isArchitectureIncompatible)); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); } @@ -104,7 +108,7 @@ public void AutoDetectArchitectureShouldReturnARMArchIfOneARMAssemblyAndRestAnyC { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.ARM).Returns(Architecture.ARM).Returns(Architecture.ARM); - Assert.AreEqual(Architecture.ARM, inferHelper.AutoDetectArchitecture(new List() { "ARM1.dll", "ARM2.dll", "ARM3.dll" }, sourceArchitectures)); + Assert.AreEqual(Architecture.ARM, inferHelper.AutoDetectArchitecture(new List() { "ARM1.dll", "ARM2.dll", "ARM3.dll" }, sourceArchitectures, out this.isArchitectureIncompatible)); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); } @@ -113,7 +117,7 @@ public void AutoDetectArchitectureShouldReturnX64ArchIfOneX64AssemblyAndRestAnyC { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.X64); - Assert.AreEqual(Architecture.X64, inferHelper.AutoDetectArchitecture(new List() { "x64.dll", "AnyCPU2.exe", "x64.dll" }, sourceArchitectures)); + Assert.AreEqual(Architecture.X64, inferHelper.AutoDetectArchitecture(new List() { "x64.dll", "AnyCPU2.exe", "x64.dll" }, sourceArchitectures, out this.isArchitectureIncompatible)); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); } @@ -122,7 +126,7 @@ public void AutoDetectArchitectureShouldReturnDefaultArchOnConflictArches() { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.X64).Returns(Architecture.X86); - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "x64.exe", "x86.dll" }, sourceArchitectures)); + Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "x64.exe", "x86.dll" }, sourceArchitectures, out this.isArchitectureIncompatible)); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); } @@ -132,7 +136,7 @@ public void AutoDetectArchitectureShouldPoulateSourceArchitectureDictionary() this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.X64).Returns(Architecture.X86); - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "x64.exe", "x86.dll" }, sourceArchitectures)); + Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "x64.exe", "x86.dll" }, sourceArchitectures, out this.isArchitectureIncompatible)); Assert.AreEqual(3, sourceArchitectures.Count); Assert.AreEqual(Architecture.AnyCPU, sourceArchitectures["AnyCPU1.dll"]); Assert.AreEqual(Architecture.X64, sourceArchitectures["x64.exe"]); @@ -146,32 +150,32 @@ public void AutoDetectArchitectureShouldReturnDefaultArchIfthereIsNotDotNetAssem { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU); - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "NotDotNetAssebly.appx" }, sourceArchitectures)); + Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "NotDotNetAssebly.appx" }, sourceArchitectures, out this.isArchitectureIncompatible)); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(1)); } [TestMethod] public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnNullSources() { - Assert.AreEqual(defaultFramework, inferHelper.AutoDetectFramework(null, sourceFrameworks)); + Assert.AreEqual(defaultFramework, inferHelper.AutoDetectFramework(null, sourceFrameworks, out this.isFrameworkIncompatible)); } [TestMethod] public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnEmptySources() { - Assert.AreEqual(defaultFramework, inferHelper.AutoDetectFramework(new List(0), sourceFrameworks)); + Assert.AreEqual(defaultFramework, inferHelper.AutoDetectFramework(new List(0), sourceFrameworks, out this.isFrameworkIncompatible)); } [TestMethod] public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnNullItemInSources() { - Assert.AreEqual(defaultFramework, inferHelper.AutoDetectFramework(new List(){null}, sourceFrameworks)); + Assert.AreEqual(defaultFramework, inferHelper.AutoDetectFramework(new List(){null}, sourceFrameworks, out this.isFrameworkIncompatible)); } [TestMethod] public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnEmptyItemInSources() { - Assert.AreEqual(defaultFramework.Name, inferHelper.AutoDetectFramework(new List() { string.Empty }, sourceFrameworks).Name); + Assert.AreEqual(defaultFramework.Name, inferHelper.AutoDetectFramework(new List() { string.Empty }, sourceFrameworks, out this.isFrameworkIncompatible).Name); } [TestMethod] @@ -221,7 +225,7 @@ public void AutoDetectFrameworkShouldReturnHighestVersionFxOnSameFxName() .Returns(new FrameworkName(frameworkNet46.Name)) .Returns(new FrameworkName(frameworkNet47.Name)) .Returns(new FrameworkName(frameworkNet45.Name)); - Assert.AreEqual(frameworkNet47.Name, inferHelper.AutoDetectFramework(new List() { "net46.dll", "net47.exe", "net45.dll" }, sourceFrameworks).Name); + Assert.AreEqual(frameworkNet47.Name, inferHelper.AutoDetectFramework(new List() { "net46.dll", "net47.exe", "net45.dll" }, sourceFrameworks, out this.isFrameworkIncompatible).Name); this.mockAssemblyHelper.Verify(ah => ah.GetFrameWork(It.IsAny()),Times.Exactly(3)); } @@ -233,7 +237,7 @@ public void AutoDetectFrameworkShouldPopulatetheDictionaryForAllTheSources() .Returns(new FrameworkName(frameworkNet47.Name)) .Returns(new FrameworkName(frameworkNet45.Name)); - Assert.AreEqual(frameworkNet47.Name, inferHelper.AutoDetectFramework(new List() { "net46.dll", "net47.exe", "net45.dll" }, sourceFrameworks).Name); + Assert.AreEqual(frameworkNet47.Name, inferHelper.AutoDetectFramework(new List() { "net46.dll", "net47.exe", "net45.dll" }, sourceFrameworks, out this.isFrameworkIncompatible).Name); Assert.AreEqual(3, sourceFrameworks.Count); Assert.AreEqual(frameworkNet46.Name, sourceFrameworks["net46.dll"].Name); @@ -249,7 +253,7 @@ public void AutoDetectFrameworkShouldReturnHighestVersionFxOnEvenManyLowerVersio .Returns(new FrameworkName(frameworkCore10.Name)) .Returns(new FrameworkName(frameworkCore11.Name)) .Returns(new FrameworkName(frameworkCore10.Name)); - Assert.AreEqual(frameworkCore11.Name, inferHelper.AutoDetectFramework(new List() { "netcore10_1.dll", "netcore11.dll", "netcore10_2.dll" }, sourceFrameworks).Name); + Assert.AreEqual(frameworkCore11.Name, inferHelper.AutoDetectFramework(new List() { "netcore10_1.dll", "netcore11.dll", "netcore10_2.dll" }, sourceFrameworks, out this.isFrameworkIncompatible).Name); this.mockAssemblyHelper.Verify(ah => ah.GetFrameWork(It.IsAny()), Times.Exactly(3)); } @@ -257,7 +261,7 @@ private void SetupAndValidateForSingleAssembly(string assemblyName, Framework fx { this.mockAssemblyHelper.Setup(sh => sh.GetFrameWork(assemblyName)) .Returns(new FrameworkName(fx.Name)); - Assert.AreEqual(fx.Name, inferHelper.AutoDetectFramework(new List() { assemblyName }, sourceFrameworks).Name); + Assert.AreEqual(fx.Name, inferHelper.AutoDetectFramework(new List() { assemblyName }, sourceFrameworks, out this.isFrameworkIncompatible).Name); if (verify) { this.mockAssemblyHelper.Verify(ah => ah.GetFrameWork(assemblyName)); diff --git a/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs b/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs index 8cac6457e6..69db75076a 100644 --- a/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs +++ b/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs @@ -671,7 +671,7 @@ public void DiscoverTestsShouldNotUpdateFrameworkAndPlatformIfSpecifiedInDesignM $@" - {Constants.DotNetFramework46} + {new FrameworkName(Framework.DefaultFramework.Name)} {Architecture.ARM.ToString()} " @@ -680,7 +680,7 @@ public void DiscoverTestsShouldNotUpdateFrameworkAndPlatformIfSpecifiedInDesignM this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) .Returns(Architecture.X86); this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(Constants.DotNetFramework451)); + .Returns(new FrameworkName(Framework.DefaultFramework.Name)); DiscoveryCriteria actualDiscoveryCriteria = null; var mockDiscoveryRequest = new Mock(); this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( @@ -694,7 +694,7 @@ public void DiscoverTestsShouldNotUpdateFrameworkAndPlatformIfSpecifiedInDesignM this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny()), Times.Never); this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny()), Times.Never); - Assert.IsTrue(actualDiscoveryCriteria.RunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsTrue(actualDiscoveryCriteria.RunSettings.Contains(Framework.DefaultFramework.Name)); Assert.IsTrue(actualDiscoveryCriteria.RunSettings.Contains(Architecture.ARM.ToString())); } @@ -751,7 +751,8 @@ public void DiscoverTestsShouldNotUpdateFrameworkAndPlatformInCommandLineScenari this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) .Returns(Architecture.ARM); this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(Constants.DotNetFramework46)); + .Returns(new FrameworkName(Framework.DefaultFramework.Name)); + DiscoveryCriteria actualDiscoveryCriteria = null; var mockDiscoveryRequest = new Mock(); this.mockTestPlatform @@ -767,10 +768,82 @@ public void DiscoverTestsShouldNotUpdateFrameworkAndPlatformInCommandLineScenari this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny()), Times.Once); this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny()), Times.Once); - Assert.IsFalse(actualDiscoveryCriteria.RunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsFalse(actualDiscoveryCriteria.RunSettings.Contains("Framework")); Assert.IsFalse(actualDiscoveryCriteria.RunSettings.Contains(Architecture.ARM.ToString())); } + [TestMethod] + public void DiscoverTestsShouldThrowTestPlatformExceptionIfSourceAndTargetFrameworkRuntimesAreIncompatible() + { + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + + " + }; + this.commandLineOptions.TargetFrameworkVersion = Framework.FromString(Constants.DotNetFramework45); + this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) + .Returns(Architecture.X86); + + this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) + .Returns(new FrameworkName(Constants.DotNetFrameworkCore10)); + + DiscoveryCriteria actualDiscoveryCriteria = null; + var mockDiscoveryRequest = new Mock(); + this.mockTestPlatform + .Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) + .Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => + { + actualDiscoveryCriteria = discoveryCriteria; + }).Returns(mockDiscoveryRequest.Object); + + var actualErrorMessage = Assert.ThrowsException(() => this.testRequestManager.DiscoverTests(payload, + new Mock().Object, this.protocolConfig)).Message; + + Assert.IsTrue(actualErrorMessage.Contains("Following DLL(s) do not match framework/platform settings")); + } + + [TestMethod] + public void DiscoverTestsShouldThrowTestPlatformExceptionIfSourceAndTargetPlatformsAreIncompatible() + { + var payload = new DiscoveryRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + + " + }; + this.commandLineOptions.TargetArchitecture = Architecture.X64; + this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) + .Returns(Architecture.X86); + + this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) + .Returns(new FrameworkName(Framework.DefaultFramework.Name)); + + DiscoveryCriteria actualDiscoveryCriteria = null; + var mockDiscoveryRequest = new Mock(); + this.mockTestPlatform + .Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) + .Callback( + (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => + { + actualDiscoveryCriteria = discoveryCriteria; + }).Returns(mockDiscoveryRequest.Object); + + var actualErrorMessage = Assert.ThrowsException(() => this.testRequestManager.DiscoverTests(payload, + new Mock().Object, this.protocolConfig)).Message; + + Assert.IsTrue(actualErrorMessage.Contains("Following DLL(s) do not match framework/platform settings")); + } + [TestMethod] public void DiscoverTestsShouldPublishMetrics() { @@ -875,6 +948,64 @@ public void RunTestsShouldThrowForFramework35() Assert.AreEqual("Framework35 is not supported. For projects targeting .Net Framework 3.5, please use Framework40 to run tests in CLR 4.0 \"compatibility mode\".", actualErrorMessage); } + [TestMethod] + public void RunTestsShouldThrowTestPlatformExceptionIfSourceAndTargetFrameworksAreIncompatible() + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + Framework35 + + " + }; + + this.commandLineOptions.TargetFrameworkVersion = Framework.FromString(Constants.DotNetFramework45); + TestRunCriteria actualTestRunCriteria = null; + var mockDiscoveryRequest = new Mock(); + this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => + { + actualTestRunCriteria = runCriteria; + }).Returns(mockDiscoveryRequest.Object); + this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())).Returns(new FrameworkName(Constants.DotNetFrameworkCore10)); + var actualErrorMessage = Assert.ThrowsException(() => this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig)).Message; + + Assert.IsTrue(actualErrorMessage.Contains("Following DLL(s) do not match framework/platform settings")); + } + + [TestMethod] + public void RunTestsShouldThrowTestPlatformExceptionIfSourceAndTargetArchitecturesAreIncompatible() + { + var payload = new TestRunRequestPayload() + { + Sources = new List() { "a.dll" }, + RunSettings = + @" + + + Framework35 + + " + }; + + this.commandLineOptions.TargetArchitecture = Architecture.X86; + TestRunCriteria actualTestRunCriteria = null; + var mockDiscoveryRequest = new Mock(); + this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( + (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => + { + actualTestRunCriteria = runCriteria; + }).Returns(mockDiscoveryRequest.Object); + this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())).Returns(Architecture.X64); + var actualErrorMessage = Assert.ThrowsException(() => this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig)).Message; + + Assert.IsTrue(actualErrorMessage.Contains("Following DLL(s) do not match framework/platform settings")); + } + [TestMethod] public void RunTestsShouldPassSameProtocolConfigInRequestData() { @@ -1417,7 +1548,7 @@ public void RunTestsShouldNotUpdateFrameworkAndPlatformIfSpecifiedInDesignModeBu $@" - {Constants.DotNetFramework46} + {Framework.DefaultFramework.Name} {Architecture.ARM.ToString()} " @@ -1427,7 +1558,8 @@ public void RunTestsShouldNotUpdateFrameworkAndPlatformIfSpecifiedInDesignModeBu this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) .Returns(Architecture.X86); this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(Constants.DotNetFramework451)); + .Returns(new FrameworkName(Framework.DefaultFramework.Name)); + TestRunCriteria actualTestRunCriteria = null; var mockTestRunRequest = new Mock(); this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( @@ -1441,7 +1573,7 @@ public void RunTestsShouldNotUpdateFrameworkAndPlatformIfSpecifiedInDesignModeBu this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny()), Times.Once); this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny()), Times.Once); - Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(Framework.DefaultFramework.Name)); Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(Architecture.ARM.ToString())); } @@ -1541,7 +1673,7 @@ public void RunTestsShouldNotpdateFrameworkAndPlatformInCommandLineScenariosIfSp this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) .Returns(Architecture.ARM); this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(Constants.DotNetFramework46)); + .Returns(new FrameworkName(Framework.DefaultFramework.Name)); TestRunCriteria actualTestRunCriteria = null; var mockTestRunRequest = new Mock(); this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( @@ -1555,7 +1687,7 @@ public void RunTestsShouldNotpdateFrameworkAndPlatformInCommandLineScenariosIfSp this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny()), Times.Once); this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny()), Times.Once); - Assert.IsFalse(actualTestRunCriteria.TestRunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsFalse(actualTestRunCriteria.TestRunSettings.Contains("Framework")); Assert.IsFalse(actualTestRunCriteria.TestRunSettings.Contains(Architecture.ARM.ToString())); } From 0a8e968bf5bf35ced57ca1cec025fc543beca15c Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Tue, 23 Oct 2018 16:16:52 +0530 Subject: [PATCH 02/19] Acceptance tests updated --- .../TestPlatformHelpers/TestRequestManager.cs | 1 - .../ExecutionTests.cs | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index 71a09180af..16766791e2 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -371,7 +371,6 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List sou if (isFrameworkIncompatible || isPlatformIncompatible) { throw new TestPlatformException(Resources.ConflictInFrameworkPlatform); - // throw new TestPlatformException("Conflicts in framework/platform identifier of provided sources."); } // Update framework and platform if required. For commandline scenario update happens in ArgumentProcessor. diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs index 3707a3339e..7faab689ab 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs @@ -217,7 +217,7 @@ public void UnhandleExceptionExceptionShouldBeLoggedToDiagLogFile(RunnerInfo run public void IncompatibleSourcesWarningShouldBeDisplayedInTheConsole(RunnerInfo runnerInfo) { AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - var expectedWarningContains = @"Following DLL(s) do not match framework/platform settings. SimpleTestProject3.dll is built for Framework 4.5.1 and Platform X64"; + var expectedErrorContains = @"Conflicts in framework/platform identifier of provided sources."; var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject3.dll", "SimpleTestProjectx86.dll").Trim('\"'); var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue); @@ -225,11 +225,10 @@ public void IncompatibleSourcesWarningShouldBeDisplayedInTheConsole(RunnerInfo r this.InvokeVsTest(arguments); - this.ValidateSummaryStatus(1, 0, 0); - this.ExitCodeEquals(0); + this.ValidateSummaryStatus(0, 0, 0); - // When both x64 & x86 DLL is passed x64 dll will be ignored. - this.StdOutputContains(expectedWarningContains); + // When both x64 & x86 DLL is passed the run should abort with error message. + this.StdErrorContains(expectedErrorContains); } [TestMethod] From 37fa21977c0329c547f4459358ff493c3f19de32 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Mon, 29 Oct 2018 16:09:22 +0530 Subject: [PATCH 03/19] Message change in conflict dlls --- src/vstest.console/Resources/Resources.resx | 2 +- src/vstest.console/Resources/xlf/Resources.cs.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.de.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.es.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.fr.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.it.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.ja.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.ko.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.pl.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.pt-BR.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.ru.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.tr.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf | 2 +- test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/vstest.console/Resources/Resources.resx b/src/vstest.console/Resources/Resources.resx index 47d1dcfe17..5bf5e29d39 100644 --- a/src/vstest.console/Resources/Resources.resx +++ b/src/vstest.console/Resources/Resources.resx @@ -719,6 +719,6 @@ Logger argument '{0}' is not valid. - Conflicts in framework/platform identifier of provided sources. + The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. \ 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 264ae068b9..74fcff092b 100644 --- a/src/vstest.console/Resources/xlf/Resources.cs.xlf +++ b/src/vstest.console/Resources/xlf/Resources.cs.xlf @@ -1638,7 +1638,7 @@ - Conflicts in framework/platform identifier of provided sources. + The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.de.xlf b/src/vstest.console/Resources/xlf/Resources.de.xlf index 84a020c163..cf4855934d 100644 --- a/src/vstest.console/Resources/xlf/Resources.de.xlf +++ b/src/vstest.console/Resources/xlf/Resources.de.xlf @@ -1638,7 +1638,7 @@ - Conflicts in framework/platform identifier of provided sources. + The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.es.xlf b/src/vstest.console/Resources/xlf/Resources.es.xlf index 8212a7329a..bb75424ef6 100644 --- a/src/vstest.console/Resources/xlf/Resources.es.xlf +++ b/src/vstest.console/Resources/xlf/Resources.es.xlf @@ -1643,7 +1643,7 @@ - Conflicts in framework/platform identifier of provided sources. + The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.fr.xlf b/src/vstest.console/Resources/xlf/Resources.fr.xlf index 46bc719637..f22fc00813 100644 --- a/src/vstest.console/Resources/xlf/Resources.fr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.fr.xlf @@ -1638,7 +1638,7 @@ - Conflicts in framework/platform identifier of provided sources. + The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.it.xlf b/src/vstest.console/Resources/xlf/Resources.it.xlf index 414824411c..149822ba6c 100644 --- a/src/vstest.console/Resources/xlf/Resources.it.xlf +++ b/src/vstest.console/Resources/xlf/Resources.it.xlf @@ -1638,7 +1638,7 @@ - Conflicts in framework/platform identifier of provided sources. + The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.ja.xlf b/src/vstest.console/Resources/xlf/Resources.ja.xlf index e39ee5f980..011d57612d 100644 --- a/src/vstest.console/Resources/xlf/Resources.ja.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ja.xlf @@ -1638,7 +1638,7 @@ - Conflicts in framework/platform identifier of provided sources. + The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.ko.xlf b/src/vstest.console/Resources/xlf/Resources.ko.xlf index 5de00cdc3b..ca840c3947 100644 --- a/src/vstest.console/Resources/xlf/Resources.ko.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ko.xlf @@ -1638,7 +1638,7 @@ - Conflicts in framework/platform identifier of provided sources. + The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.pl.xlf b/src/vstest.console/Resources/xlf/Resources.pl.xlf index 324922ea30..93da1e4797 100644 --- a/src/vstest.console/Resources/xlf/Resources.pl.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pl.xlf @@ -1636,7 +1636,7 @@ - Conflicts in framework/platform identifier of provided sources. + The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf index ec6ee2a71d..fc6f549d62 100644 --- a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf @@ -1636,7 +1636,7 @@ - Conflicts in framework/platform identifier of provided sources. + The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.ru.xlf b/src/vstest.console/Resources/xlf/Resources.ru.xlf index 6a535753c5..f19f778f5f 100644 --- a/src/vstest.console/Resources/xlf/Resources.ru.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ru.xlf @@ -1638,7 +1638,7 @@ - Conflicts in framework/platform identifier of provided sources. + The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.tr.xlf b/src/vstest.console/Resources/xlf/Resources.tr.xlf index 3de8decaa0..7e63afa9a5 100644 --- a/src/vstest.console/Resources/xlf/Resources.tr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.tr.xlf @@ -1638,7 +1638,7 @@ - Conflicts in framework/platform identifier of provided sources. + The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.xlf b/src/vstest.console/Resources/xlf/Resources.xlf index 66a99b65c2..17ea08b1aa 100644 --- a/src/vstest.console/Resources/xlf/Resources.xlf +++ b/src/vstest.console/Resources/xlf/Resources.xlf @@ -820,7 +820,7 @@ - Conflicts in framework/platform identifier of provided sources. + The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf index cdc84091b0..ff7eb8e11c 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf @@ -1638,7 +1638,7 @@ - Conflicts in framework/platform identifier of provided sources. + The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf index 2969fbd4a2..2847bd69dc 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf @@ -1638,7 +1638,7 @@ - Conflicts in framework/platform identifier of provided sources. + The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs index 7faab689ab..00da56d436 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs @@ -217,7 +217,7 @@ public void UnhandleExceptionExceptionShouldBeLoggedToDiagLogFile(RunnerInfo run public void IncompatibleSourcesWarningShouldBeDisplayedInTheConsole(RunnerInfo runnerInfo) { AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); - var expectedErrorContains = @"Conflicts in framework/platform identifier of provided sources."; + var expectedErrorContains = @"The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform."; var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject3.dll", "SimpleTestProjectx86.dll").Trim('\"'); var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue, runnerInfo.InIsolationValue); From 75e2164c705a4747d852b1dcb39ab0699a2a15d2 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Sat, 1 Dec 2018 14:46:14 +0530 Subject: [PATCH 04/19] Changes in methods --- .../Resources/CommonResources.resx | 2 +- .../Resources/xlf/CommonResources.cs.xlf | 6 +- .../Resources/xlf/CommonResources.de.xlf | 6 +- .../Resources/xlf/CommonResources.es.xlf | 6 +- .../Resources/xlf/CommonResources.fr.xlf | 6 +- .../Resources/xlf/CommonResources.it.xlf | 6 +- .../Resources/xlf/CommonResources.ja.xlf | 6 +- .../Resources/xlf/CommonResources.ko.xlf | 6 +- .../Resources/xlf/CommonResources.pl.xlf | 6 +- .../Resources/xlf/CommonResources.pt-BR.xlf | 6 +- .../Resources/xlf/CommonResources.ru.xlf | 6 +- .../Resources/xlf/CommonResources.tr.xlf | 6 +- .../Resources/xlf/CommonResources.xlf | 2 +- .../Resources/xlf/CommonResources.zh-Hans.xlf | 6 +- .../Resources/xlf/CommonResources.zh-Hant.xlf | 6 +- .../InferRunSettingsHelper.cs | 42 ++--- src/vstest.console/CommandLine/InferHelper.cs | 35 ++--- src/vstest.console/Resources/Resources.resx | 3 +- .../Resources/xlf/Resources.cs.xlf | 3 +- .../Resources/xlf/Resources.de.xlf | 3 +- .../Resources/xlf/Resources.es.xlf | 3 +- .../Resources/xlf/Resources.fr.xlf | 3 +- .../Resources/xlf/Resources.it.xlf | 3 +- .../Resources/xlf/Resources.ja.xlf | 3 +- .../Resources/xlf/Resources.ko.xlf | 3 +- .../Resources/xlf/Resources.pl.xlf | 3 +- .../Resources/xlf/Resources.pt-BR.xlf | 3 +- .../Resources/xlf/Resources.ru.xlf | 3 +- .../Resources/xlf/Resources.tr.xlf | 3 +- .../Resources/xlf/Resources.xlf | 3 +- .../Resources/xlf/Resources.zh-Hans.xlf | 3 +- .../Resources/xlf/Resources.zh-Hant.xlf | 3 +- .../TestPlatformHelpers/TestRequestManager.cs | 18 +-- .../InferRunSettingsHelperTests.cs | 14 +- .../CommandLine/InferHelperTests.cs | 145 ++++++++++++------ .../TestRequestManagerTests.cs | 65 -------- 36 files changed, 217 insertions(+), 229 deletions(-) diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.resx b/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.resx index 870ef40055..15106a4081 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.resx +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.resx @@ -121,7 +121,7 @@ The parameter cannot be null or empty. - Test run will use DLL(s) built for framework {0} and platform {1}. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.cs.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.cs.xlf index 6cbcd9aec0..681a9364d0 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.cs.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.cs.xlf @@ -30,11 +30,11 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - Test run will use DLL(s) built for framework {0} and platform {1}. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. - Testovací běh použije knihovny DLL sestavené pro rozhraní {0} a platformu {1}. Tyto knihovny DLL nebudou součástí běhu: {2}Další podrobnosti o správě těchto nastavení najdete na adrese {3}. + Testovací běh použije knihovny DLL sestavené pro rozhraní {0} a platformu {1}. Tyto knihovny DLL nebudou součástí běhu: {2}Další podrobnosti o správě těchto nastavení najdete na adrese {3}. - + Spuštění testu použije DLL(s) vybudované framework {0} a platformu {1}. Po DLL(s) nebudou součástí run: {2} {3} podrobnosti přejít na správu těchto nastavení. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.de.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.de.xlf index ba40291dc4..205cbaf891 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.de.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.de.xlf @@ -30,11 +30,11 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - Test run will use DLL(s) built for framework {0} and platform {1}. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. - Der Testlauf verwendet DLLs, die für das Framework {0} und die Plattform {1} erstellt wurden. Die folgenden DLLs sind nicht Teil der Ausführung: {2}.Navigieren Sie zu {3}, um weitere Details zum Verwalten dieser Einstellungen zu erhalten. + Der Testlauf verwendet DLLs, die für das Framework {0} und die Plattform {1} erstellt wurden. Die folgenden DLLs sind nicht Teil der Ausführung: {2}.Navigieren Sie zu {3}, um weitere Details zum Verwalten dieser Einstellungen zu erhalten. - + Testlauf verwendet DLLs für Framework {0} und {1}-Plattform integriert. Folgende DLLs nicht Teil ausführen: {2} zur {3} Einzelheiten auf diese Einstellungen. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.es.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.es.xlf index b0cb7caed0..7c1eea7062 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.es.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.es.xlf @@ -30,11 +30,11 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - Test run will use DLL(s) built for framework {0} and platform {1}. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. - La serie de pruebas usará archivos DLL compilados para el marco {0} y la plataforma {1}. Los siguientes archivos DLL no formarán parte de la ejecución: {2}Vaya a {3} para obtener más información sobre cómo administrar esta configuración. + La serie de pruebas usará archivos DLL compilados para el marco {0} y la plataforma {1}. Los siguientes archivos DLL no formarán parte de la ejecución: {2}Vaya a {3} para obtener más información sobre cómo administrar esta configuración. - + Ejecución de prueba utilizará archivos DLL construido para framework {0} y plataforma {1}. Siguiendo los archivos DLL no formarán parte de la ejecución: {2} vaya a {3} para obtener más información acerca de cómo administrar esta configuración. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.fr.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.fr.xlf index e0b422ac29..a252303d8e 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.fr.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.fr.xlf @@ -30,11 +30,11 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - Test run will use DLL(s) built for framework {0} and platform {1}. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. - La série de tests utilise des DLL générées pour le framework {0} et la plateforme {1}. Les DLL suivantes ne font pas partie de la série de tests : {2}Accédez à {3} pour plus de détails sur la gestion de ces paramètres. + La série de tests utilise des DLL générées pour le framework {0} et la plateforme {1}. Les DLL suivantes ne font pas partie de la série de tests : {2}Accédez à {3} pour plus de détails sur la gestion de ces paramètres. - + Série de tests utilise DLL conçu pour {0} de l’infrastructure et de plateforme {1}. Suivant les DLL ne fera pas partie de l’exécution : {2} atteindre {3} pour plus de détails sur la gestion de ces paramètres. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.it.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.it.xlf index 8696f0b6f2..104a8fad47 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.it.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.it.xlf @@ -30,11 +30,11 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - Test run will use DLL(s) built for framework {0} and platform {1}. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. - Per l'esecuzione dei test verranno usate DLL compilate per il framework {0} e la piattaforma {1}. Le DLL seguenti non saranno incluse nell'esecuzione: {2}.Per maggiori dettagli sulla gestione di queste impostazioni, passare a {3}. + Per l'esecuzione dei test verranno usate DLL compilate per il framework {0} e la piattaforma {1}. Le DLL seguenti non saranno incluse nell'esecuzione: {2}.Per maggiori dettagli sulla gestione di queste impostazioni, passare a {3}. - + Esecuzione dei test utilizzerà dll compilato per framework {0} e {1} piattaforma. DLL di seguito non saranno parte dell'esecuzione: {2} Vai a {3} per ulteriori informazioni sulla gestione di queste impostazioni. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ja.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ja.xlf index d5d5b37389..ea18faf8b9 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ja.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ja.xlf @@ -30,11 +30,11 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - Test run will use DLL(s) built for framework {0} and platform {1}. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. - テスト実行ではフレームワーク {0} およびプラットフォーム {1} 用にビルドされた DLL を使用します。次の DLL は実行には含まれません: {2}これらの設定の管理方法の詳細については、{3} にアクセスしてください。 + テスト実行ではフレームワーク {0} およびプラットフォーム {1} 用にビルドされた DLL を使用します。次の DLL は実行には含まれません: {2}これらの設定の管理方法の詳細については、{3} にアクセスしてください。 - + テストの実行では、framework {0} と {1} のプラットフォーム用に構築された DLL(s) を使用します。次の DLL(s) は含まれませんの実行: {2} には、詳細については {3} にこれらの設定を管理します。 diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ko.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ko.xlf index ae391abfd5..6102fdb6de 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ko.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ko.xlf @@ -30,11 +30,11 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - Test run will use DLL(s) built for framework {0} and platform {1}. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. - 테스트 실행에서는 프레임워크 {0} 및 플랫폼 {1}용으로 작성된 DLL을 사용합니다. 다음 DLL은 실행에서 사용할 수 없습니다. {2}.이러한 설정의 관리에 대한 자세한 내용은 {3}을(를) 참조하세요. + 테스트 실행에서는 프레임워크 {0} 및 플랫폼 {1}용으로 작성된 DLL을 사용합니다. 다음 DLL은 실행에서 사용할 수 없습니다. {2}.이러한 설정의 관리에 대한 자세한 내용은 {3}을(를) 참조하세요. - + 테스트 실행 프레임 워크 {0}에서 {1} 플랫폼에 대 한 빌드 DLL(s)를 사용 합니다. DLL(s) 다음 부분에서는 실행 되지 것입니다: 이러한 설정을 관리에 대 한 자세한 내용은 {3} {2} 이동 합니다. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pl.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pl.xlf index 69ccc57bba..f8e5ef7d34 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pl.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pl.xlf @@ -30,11 +30,11 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - Test run will use DLL(s) built for framework {0} and platform {1}. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. - Przebieg testu użyje plików DLL przeznaczonych dla struktury {0} i platformy {1}. Następujące pliki DLL nie pasują do ustawień struktury/platformy.{2}.Aby uzyskać więcej informacji na temat zarządzania tymi ustawieniami, przejdź do strony {3}. + Przebieg testu użyje plików DLL przeznaczonych dla struktury {0} i platformy {1}. Następujące pliki DLL nie pasują do ustawień struktury/platformy.{2}.Aby uzyskać więcej informacji na temat zarządzania tymi ustawieniami, przejdź do strony {3}. - + Uruchom test użyje dll (s), zbudowane dla framework {0} i platformy {1}. Po dll (s) nie będzie częścią run: {2} Przejdź do {3} szczegółowe informacje dotyczące zarządzania tych ustawień. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pt-BR.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pt-BR.xlf index b8d76c6881..666f246168 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pt-BR.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pt-BR.xlf @@ -30,11 +30,11 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - Test run will use DLL(s) built for framework {0} and platform {1}. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. - A execução de teste usará DLLs criadas para a estrutura {0} e a plataforma {1}. As seguintes DLLs não farão parte da execução: {2}Acesse {3} para obter mais detalhes sobre como gerenciar essas configurações. + A execução de teste usará DLLs criadas para a estrutura {0} e a plataforma {1}. As seguintes DLLs não farão parte da execução: {2}Acesse {3} para obter mais detalhes sobre como gerenciar essas configurações. - + Execução do teste usará DLL(s) criado para o framework {0} e plataforma {1}. DLL(s) a seguir não farão parte da execução: {2} vá para {3} para obter mais detalhes sobre como gerenciar essas configurações. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ru.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ru.xlf index 3ccb65d854..766eb0a3c2 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ru.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ru.xlf @@ -30,11 +30,11 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - Test run will use DLL(s) built for framework {0} and platform {1}. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. - При запуске тестов будут использоваться библиотеки DLL, собранные для платформ {0} и {1}. Следующие библиотеки DLL не будут участвовать в запуске: {2}.Дополнительные сведения об управлении этими параметрами см. в разделе {3}. + При запуске тестов будут использоваться библиотеки DLL, собранные для платформ {0} и {1}. Следующие библиотеки DLL не будут участвовать в запуске: {2}.Дополнительные сведения об управлении этими параметрами см. в разделе {3}. - + Тестовый запуск будет использовать DLL(s) для framework {0} и платформы {1}. После DLL(s) не будет частью выполнения: {2} перейти {3} для получения дополнительных сведений об управлении эти параметры. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.tr.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.tr.xlf index bbfe507a1a..e2abb91ffb 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.tr.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.tr.xlf @@ -30,11 +30,11 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - Test run will use DLL(s) built for framework {0} and platform {1}. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. - Test çalıştırmasında, {0} çerçevesi ve {1} platformu için oluşturulan DLL’ler kullanılacak. Şu DLL’ler çalıştırmaya dahil edilmeyecek: {2}Bu ayarları yönetmeye ilişkin ayrıntılar için {3} sayfasına gidin. + Test çalıştırmasında, {0} çerçevesi ve {1} platformu için oluşturulan DLL’ler kullanılacak. Şu DLL’ler çalıştırmaya dahil edilmeyecek: {2}Bu ayarları yönetmeye ilişkin ayrıntılar için {3} sayfasına gidin. - + Test çalışması DLL(s) framework {0} ve {1} platform için yerleşik kullanır. DLL(s) aşağıdaki çalışma parçası olmayacak: {2} Git {3} daha fazla ayrıntı için bu ayarları yönetme hakkında. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.xlf index a053d2ffff..3dd48783c9 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.xlf @@ -7,7 +7,7 @@ - Test run will use DLL(s) built for framework {0} and platform {1}. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hans.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hans.xlf index dc1fcf651a..86e37749a3 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hans.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hans.xlf @@ -30,11 +30,11 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - Test run will use DLL(s) built for framework {0} and platform {1}. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. - 测试运行将使用为框架 {0} 和平台 {1} 生成的 DLL。以下 DLL 将不是运行的一部分: {2}转到 {3} 了解有关管理这些设置的详细信息。 + 测试运行将使用为框架 {0} 和平台 {1} 生成的 DLL。以下 DLL 将不是运行的一部分: {2}转到 {3} 了解有关管理这些设置的详细信息。 - + 测试运行将使用 DLL(s) 框架 {0} 和 {1} 的平台的构建。按照 DLL(s) 将不能运行的过程︰ {2} 转到详细 {3} 上管理这些设置。 diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hant.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hant.xlf index 632c7cc4e7..6faaa5b01a 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hant.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hant.xlf @@ -30,11 +30,11 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - Test run will use DLL(s) built for framework {0} and platform {1}. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. - 測試回合將使用替架構 {0} 與平台 {1} 所建置的 DLL。下列 DLL 將不包含在測試回合中: {2}如需如何管理這些設定的詳細資料,請前往 {3}。 + 測試回合將使用替架構 {0} 與平台 {1} 所建置的 DLL。下列 DLL 將不包含在測試回合中: {2}如需如何管理這些設定的詳細資料,請前往 {3}。 - + 测试运行将使用 DLL(s) 框架 {0} 和 {1} 的平台的构建。按照 DLL(s) 将不能运行的过程︰ {2} 转到详细 {3} 上管理这些设置。 diff --git a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs index f563dd5c1b..3016bbe503 100644 --- a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs +++ b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs @@ -612,11 +612,10 @@ public static bool TryGetFrameworkXml(XPathNavigator runSettingsNavigator, out s /// Returns the sources matching the specified platform and framework settings. /// For incompatible sources, warning is added to incompatibleSettingWarning. /// - public static IEnumerable FilterCompatibleSources(Architecture chosenPlatform, Framework chosenFramework, IDictionary sourcePlatforms, IDictionary sourceFrameworks, out String incompatibleSettingWarning, out bool incompatibilityErrorFound) + public static IEnumerable FilterCompatibleSources(Architecture chosenPlatform, Framework chosenFramework, IDictionary sourcePlatforms, IDictionary sourceFrameworks, out String incompatibleSettingWarning) { incompatibleSettingWarning = string.Empty; bool incompatibilityFound = false; - incompatibilityErrorFound = false; List compatibleSources = new List(); StringBuilder warnings = new StringBuilder(); warnings.AppendLine(); @@ -625,8 +624,7 @@ public static IEnumerable FilterCompatibleSources(Architecture chosenPla { Architecture actualPlatform = sourcePlatforms[source]; Framework actualFramework = sourceFrameworks[source]; - bool isSettingIncompatible = IsSettingIncompatible(actualPlatform, chosenPlatform, actualFramework, chosenFramework); - incompatibilityErrorFound = IsFrameworkRuntimeIncompatible(actualFramework, chosenFramework) || IsPlatformArchitectureIncompatible(actualPlatform, chosenPlatform); + bool isSettingIncompatible = IsSettingIncompatible(actualPlatform, chosenPlatform, actualFramework, chosenFramework) || IsFrameworkRuntimeIncompatible(actualFramework, chosenFramework); if (isSettingIncompatible) { string incompatiblityMessage; @@ -642,7 +640,7 @@ public static IEnumerable FilterCompatibleSources(Architecture chosenPla compatibleSources.Add(source); } } - if (incompatibilityFound || incompatibilityErrorFound) + if (incompatibilityFound) { incompatibleSettingWarning = string.Format(CultureInfo.CurrentCulture, OMResources.DisplayChosenSettings, chosenFramework, chosenPlatform, warnings.ToString(), multiTargettingForwardLink); } @@ -651,9 +649,25 @@ public static IEnumerable FilterCompatibleSources(Architecture chosenPla } /// - /// Returns true if source settings are incomaptible with target settings. + /// Returns true if framework runtime of target framework is incompatible with any source framework /// - private static bool IsSettingIncompatible(Architecture sourcePlatform, + public static bool TryGetSettingIncompatibility(Architecture chosenPlatform, Framework chosenFramework, IDictionary sourcePlatforms, IDictionary sourceFrameworks) + { + bool isSettingIncompatible = false; + foreach (var source in sourcePlatforms.Keys) + { + Architecture actualPlatform = sourcePlatforms[source]; + Framework actualFramework = sourceFrameworks[source]; + isSettingIncompatible = IsFrameworkRuntimeIncompatible(actualFramework, chosenFramework); + } + + return isSettingIncompatible; + } + + /// + /// Returns true if source settings are incompatible with target settings. + /// + private static bool IsSettingIncompatible(Architecture sourcePlatform, Architecture targetPlatform, Framework sourceFramework, Framework targetFramework) @@ -688,20 +702,6 @@ private static bool IsFrameworkIncompatible(Framework sourceFramework, Framework return !sourceFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase); } - /// - /// Returns true if source platform is incompatible with target platform. - /// - private static bool IsPlatformArchitectureIncompatible(Architecture sourcePlatform, Architecture targetPlatform) - { - if (sourcePlatform == Architecture.X86 && targetPlatform == Architecture.X64 || - sourcePlatform == Architecture.X64 && targetPlatform == Architecture.X86) - { - return true; - } - - return false; - } - /// /// Returns true if source Framework Runtime is incompatible with target Framework. /// diff --git a/src/vstest.console/CommandLine/InferHelper.cs b/src/vstest.console/CommandLine/InferHelper.cs index 05246e75e1..31bff65845 100644 --- a/src/vstest.console/CommandLine/InferHelper.cs +++ b/src/vstest.console/CommandLine/InferHelper.cs @@ -25,12 +25,12 @@ internal InferHelper(IAssemblyMetadataProvider assemblyMetadataProvider) } /// - /// Determines Architecture from sources. + /// Determines Architecture from sources and returns true if source architectures are incompatible /// - public Architecture AutoDetectArchitecture(List sources, IDictionary sourcePlatforms, out bool isArchitectureIncompatible) + public bool TryGetCompatibleArchitecture(List sources, IDictionary sourcePlatforms, out Architecture inferredArchitecture) { - Architecture architecture = Constants.DefaultPlatform; - isArchitectureIncompatible = false; + inferredArchitecture = Constants.DefaultPlatform; + bool isArchitectureIncompatible = false; try { if (sources != null && sources.Count > 0) @@ -73,61 +73,60 @@ public Architecture AutoDetectArchitecture(List sources, IDictionary - /// Determines Framework from sources. + /// Determines Framework from sources and returns true if source frameworks are incompatible /// - public Framework AutoDetectFramework(List sources, IDictionary sourceFrameworkVersions, out bool isFrameworkIncompatible) + public bool TryGetCompatibleFramework(List sources, IDictionary sourceFrameworkVersions, out Framework inferredFramework) { - Framework framework = Framework.DefaultFramework; - isFrameworkIncompatible = false; + inferredFramework = Framework.DefaultFramework; + bool isFrameworkIncompatible = false; try { if (sources != null && sources.Count > 0) { var finalFx = DetermineFrameworkName(sources, sourceFrameworkVersions, out var conflictInFxIdentifier); - framework = Framework.FromString(finalFx.FullName); + inferredFramework = Framework.FromString(finalFx.FullName); if (conflictInFxIdentifier) { isFrameworkIncompatible = true; if (EqtTrace.IsInfoEnabled) { - // TODO Log to console and client. EqtTrace.Info( "conflicts in Framework indentifier of provided sources(test assemblies), using default framework:{0}", - framework); + inferredFramework); } } } } catch (Exception ex) { - EqtTrace.Error("Failed to determine framework:{0}, using defaulf: {1}", ex, framework); + EqtTrace.Error("Failed to determine framework:{0}, using defaulf: {1}", ex, inferredFramework); } if (EqtTrace.IsInfoEnabled) { - EqtTrace.Info("Determined framework for all sources: {0}", framework); + EqtTrace.Info("Determined framework for all sources: {0}", inferredFramework); } - return framework; + return isFrameworkIncompatible; } private FrameworkName DetermineFrameworkName(IEnumerable sources, IDictionary sourceFrameworkVersions, out bool conflictInFxIdentifier) diff --git a/src/vstest.console/Resources/Resources.resx b/src/vstest.console/Resources/Resources.resx index 5bf5e29d39..ceb1e89f85 100644 --- a/src/vstest.console/Resources/Resources.resx +++ b/src/vstest.console/Resources/Resources.resx @@ -719,6 +719,7 @@ Logger argument '{0}' is not valid. - The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. + +The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. \ 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 74fcff092b..ef01f8ec69 100644 --- a/src/vstest.console/Resources/xlf/Resources.cs.xlf +++ b/src/vstest.console/Resources/xlf/Resources.cs.xlf @@ -1638,7 +1638,8 @@ - The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. + +The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.de.xlf b/src/vstest.console/Resources/xlf/Resources.de.xlf index cf4855934d..2054f38fb3 100644 --- a/src/vstest.console/Resources/xlf/Resources.de.xlf +++ b/src/vstest.console/Resources/xlf/Resources.de.xlf @@ -1638,7 +1638,8 @@ - The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. + +The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.es.xlf b/src/vstest.console/Resources/xlf/Resources.es.xlf index bb75424ef6..186dbd02bb 100644 --- a/src/vstest.console/Resources/xlf/Resources.es.xlf +++ b/src/vstest.console/Resources/xlf/Resources.es.xlf @@ -1643,7 +1643,8 @@ - The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. + +The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.fr.xlf b/src/vstest.console/Resources/xlf/Resources.fr.xlf index f22fc00813..29fb1091fe 100644 --- a/src/vstest.console/Resources/xlf/Resources.fr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.fr.xlf @@ -1638,7 +1638,8 @@ - The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. + +The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.it.xlf b/src/vstest.console/Resources/xlf/Resources.it.xlf index 149822ba6c..2f78479ff0 100644 --- a/src/vstest.console/Resources/xlf/Resources.it.xlf +++ b/src/vstest.console/Resources/xlf/Resources.it.xlf @@ -1638,7 +1638,8 @@ - The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. + +The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.ja.xlf b/src/vstest.console/Resources/xlf/Resources.ja.xlf index 011d57612d..9bce0bf1ee 100644 --- a/src/vstest.console/Resources/xlf/Resources.ja.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ja.xlf @@ -1638,7 +1638,8 @@ - The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. + +The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.ko.xlf b/src/vstest.console/Resources/xlf/Resources.ko.xlf index ca840c3947..0004a305ce 100644 --- a/src/vstest.console/Resources/xlf/Resources.ko.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ko.xlf @@ -1638,7 +1638,8 @@ - The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. + +The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.pl.xlf b/src/vstest.console/Resources/xlf/Resources.pl.xlf index 93da1e4797..fa84359e25 100644 --- a/src/vstest.console/Resources/xlf/Resources.pl.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pl.xlf @@ -1636,7 +1636,8 @@ - The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. + +The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf index fc6f549d62..6964ccf51c 100644 --- a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf @@ -1636,7 +1636,8 @@ - The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. + +The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.ru.xlf b/src/vstest.console/Resources/xlf/Resources.ru.xlf index f19f778f5f..2aa80b9a9a 100644 --- a/src/vstest.console/Resources/xlf/Resources.ru.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ru.xlf @@ -1638,7 +1638,8 @@ - The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. + +The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.tr.xlf b/src/vstest.console/Resources/xlf/Resources.tr.xlf index 7e63afa9a5..cc35d11ec2 100644 --- a/src/vstest.console/Resources/xlf/Resources.tr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.tr.xlf @@ -1638,7 +1638,8 @@ - The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. + +The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.xlf b/src/vstest.console/Resources/xlf/Resources.xlf index 17ea08b1aa..ea755e3882 100644 --- a/src/vstest.console/Resources/xlf/Resources.xlf +++ b/src/vstest.console/Resources/xlf/Resources.xlf @@ -820,7 +820,8 @@ - The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. + +The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf index ff7eb8e11c..9b3fab04ae 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf @@ -1638,7 +1638,8 @@ - The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. + +The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf index 2847bd69dc..d48ba3e51d 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf @@ -1638,7 +1638,8 @@ - The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. + +The given test sources target multiple frameworks/platforms that are incompatible. Please make sure the sources target the same framework and platform. Conflicts in framework/platform identifier of provided sources. diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index 16766791e2..2ef0213c1f 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -363,40 +363,40 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List sou var navigator = document.CreateNavigator(); - var inferedFramework = inferHelper.AutoDetectFramework(sources, sourceFrameworks, out var isFrameworkIncompatible); + var isFrameworkIncompatible = inferHelper.TryGetCompatibleFramework(sources, sourceFrameworks, out var inferredFramework); Framework chosenFramework; - var inferedPlatform = inferHelper.AutoDetectArchitecture(sources, sourcePlatforms, out var isPlatformIncompatible); + var isPlatformIncompatible = inferHelper.TryGetCompatibleArchitecture(sources, sourcePlatforms, out var inferredPlatform); Architecture chosenPlatform; if (isFrameworkIncompatible || isPlatformIncompatible) { throw new TestPlatformException(Resources.ConflictInFrameworkPlatform); } - // Update framework and platform if required. For commandline scenario update happens in ArgumentProcessor. bool updateFramework = IsAutoFrameworkDetectRequired(navigator, out chosenFramework); bool updatePlatform = IsAutoPlatformDetectRequired(navigator, out chosenPlatform); if (updateFramework) { - InferRunSettingsHelper.UpdateTargetFramework(document, inferedFramework?.ToString(), overwrite: true); - chosenFramework = inferedFramework; + InferRunSettingsHelper.UpdateTargetFramework(document, inferredFramework?.ToString(), overwrite: true); + chosenFramework = inferredFramework; settingsUpdated = true; } if (updatePlatform) { - InferRunSettingsHelper.UpdateTargetPlatform(document, inferedPlatform.ToString(), overwrite: true); - chosenPlatform = inferedPlatform; + InferRunSettingsHelper.UpdateTargetPlatform(document, inferredPlatform.ToString(), overwrite: true); + chosenPlatform = inferredPlatform; settingsUpdated = true; } - var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(chosenPlatform, chosenFramework, sourcePlatforms, sourceFrameworks, out var incompatibleSettingWarning, out var incompatibiltyErrorFound); + var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(chosenPlatform, chosenFramework, sourcePlatforms, sourceFrameworks, out var incompatibleSettingWarning); + var isSettingIncompatible = InferRunSettingsHelper.TryGetSettingIncompatibility(chosenPlatform, chosenFramework, sourcePlatforms, sourceFrameworks); if (!string.IsNullOrEmpty(incompatibleSettingWarning)) { EqtTrace.Info(incompatibleSettingWarning); - if(incompatibiltyErrorFound) + if(isSettingIncompatible) { throw new TestPlatformException(incompatibleSettingWarning); } diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs index 713e3a91fe..288685f5b2 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs @@ -391,7 +391,7 @@ public void UpdateTargetFrameworkShouldAddFrameworkXmlNodeIfNotPresent() } [TestMethod] - public void FilterCompatibleSourcesShouldIdentifyIncomaptiableSourcesAndConstructWarningMessage() + public void FilterCompatibleSourcesShouldIdentifyIncompatibleSourcesAndConstructWarningMessage() { #region Arrange sourceArchitectures["AnyCPU1net46.dll"] = Architecture.AnyCPU; @@ -412,8 +412,7 @@ public void FilterCompatibleSourcesShouldIdentifyIncomaptiableSourcesAndConstruc #endregion string warningMessage = string.Empty; - bool incompatibilityFound; - var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, frameworkNet47, sourceArchitectures, sourceFrameworks, out warningMessage, out incompatibilityFound); + var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, frameworkNet47, sourceArchitectures, sourceFrameworks, out warningMessage); // None of the DLLs passed are compatible to the chosen settings Assert.AreEqual(0, compatibleSources.Count()); @@ -436,8 +435,7 @@ public void FilterCompatibleSourcesShouldIdentifyCompatibleSources() var expected = string.Format(CultureInfo.CurrentCulture, OMResources.DisplayChosenSettings, frameworkNet45, Constants.DefaultPlatform, sb.ToString(), @"http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409"); string warningMessage = string.Empty; - bool incompatibilityFound; - var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, frameworkNet45, sourceArchitectures, sourceFrameworks, out warningMessage, out incompatibilityFound); + var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, frameworkNet45, sourceArchitectures, sourceFrameworks, out warningMessage); // only "x86net45.dll" is the compatible source Assert.AreEqual(1, compatibleSources.Count()); @@ -451,8 +449,7 @@ public void FilterCompatibleSourcesShouldNotComposeWarningIfSettingsAreCorrect() sourceFrameworks["x86net45.dll"] = frameworkNet45; string warningMessage = string.Empty; - bool incompatibilityFound; - var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, frameworkNet45, sourceArchitectures, sourceFrameworks, out warningMessage, out incompatibilityFound); + var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Constants.DefaultPlatform, frameworkNet45, sourceArchitectures, sourceFrameworks, out warningMessage); // only "x86net45.dll" is the compatible source Assert.AreEqual(1, compatibleSources.Count()); @@ -466,8 +463,7 @@ public void FilterCompatibleSourcesShouldRetrunWarningMessageIfNoConflict() sourceFrameworks["x64net45.exe"] = frameworkNet45; string warningMessage = string.Empty; - bool incompatibilityFound; - var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Architecture.X64, frameworkNet45, sourceArchitectures, sourceFrameworks, out warningMessage, out incompatibilityFound); + var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(Architecture.X64, frameworkNet45, sourceArchitectures, sourceFrameworks, out warningMessage); Assert.IsTrue(string.IsNullOrEmpty(warningMessage)); } diff --git a/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs b/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs index a073efc4bf..875cf1ceee 100644 --- a/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs +++ b/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs @@ -26,8 +26,6 @@ public class InferHelperTests private readonly Framework frameworkCore11 = Framework.FromString(".NETCoreApp,Version=1.1"); private IDictionary sourceFrameworks; private IDictionary sourceArchitectures; - bool isArchitectureIncompatible; - bool isFrameworkIncompatible; public InferHelperTests() { @@ -35,108 +33,142 @@ public InferHelperTests() inferHelper = new InferHelper(this.mockAssemblyHelper.Object); sourceFrameworks = new Dictionary(); sourceArchitectures = new Dictionary(); - this.isArchitectureIncompatible = false; - this.isFrameworkIncompatible = false; } [TestMethod] - public void AutoDetectArchitectureShouldReturnDefaultArchitectureOnNullSources() + public void TryGetArchitectureShouldReturnDefaultArchitectureOnNullSources() { - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(null, sourceArchitectures, out this.isArchitectureIncompatible)); + bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(null, sourceArchitectures, out var inferredArchitecture); + + Assert.AreEqual(false, isArchitectureIncompatible); + Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); } [TestMethod] - public void AutoDetectArchitectureShouldReturnDefaultArchitectureOnEmptySources() + public void TryGetArchitectureShouldReturnDefaultArchitectureOnEmptySources() { - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List(0), sourceArchitectures, out this.isArchitectureIncompatible)); + bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List(0), sourceArchitectures, out var inferredArchitecture); + + Assert.AreEqual(false, isArchitectureIncompatible); + Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); } [TestMethod] - public void AutoDetectArchitectureShouldReturnDefaultArchitectureOnNullItemInSources() + public void TryGetArchitectureShouldReturnDefaultArchitectureOnNullItemInSources() { - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List(){null}, sourceArchitectures, out this.isArchitectureIncompatible)); + bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { null }, sourceArchitectures, out var inferredArchitecture); + + Assert.AreEqual(false, isArchitectureIncompatible); + Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); } [TestMethod] - public void AutoDetectArchitectureShouldReturnDefaultArchitectureOnWhiteSpaceItemInSources() + public void TryGetArchitectureShouldReturnDefaultArchitectureOnWhiteSpaceItemInSources() { - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { " "}, sourceArchitectures, out this.isArchitectureIncompatible)); + bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { " " }, sourceArchitectures, out var inferredArchitecture); + + Assert.AreEqual(false, isArchitectureIncompatible); + Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); } [TestMethod] - public void AutoDetectArchitectureShouldReturnCorrectArchForOneSource() + public void TryGetArchitectureShouldReturnCorrectArchForOneSource() { this.mockAssemblyHelper.Setup(ah => ah.GetArchitecture(It.IsAny())).Returns(Architecture.X86); - Assert.AreEqual(Architecture.X86, inferHelper.AutoDetectArchitecture(new List(){"1.dll"}, sourceArchitectures, out this.isArchitectureIncompatible)); + + bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { "1.dll" }, sourceArchitectures, out var inferredArchitecture); + + Assert.AreEqual(false, isArchitectureIncompatible); + Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny())); } [TestMethod] - public void AutoDetectArchitectureShouldReturnCorrectDefaultArchForNotDotNetAssembly() + public void TryGetArchitectureShouldReturnCorrectDefaultArchForNotDotNetAssembly() { - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { "NotDotNetAssebly.appx" }, sourceArchitectures, out this.isArchitectureIncompatible)); + bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { "NotDotNetAssebly.appx" }, sourceArchitectures, out var inferredArchitecture); + + Assert.AreEqual(false, isArchitectureIncompatible); + Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Never); } [TestMethod] - public void AutoDetectArchitectureShouldSetAnyCpuArchForNotDotNetAssembly() + public void TryGetArchitectureShouldSetAnyCpuArchForNotDotNetAssembly() { - inferHelper.AutoDetectArchitecture(new List() { "NotDotNetAssebly.appx" }, sourceArchitectures, out this.isArchitectureIncompatible); + bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { "NotDotNetAssebly.appx" }, sourceArchitectures, out var inferredArchitecture); + + Assert.AreEqual(false, isArchitectureIncompatible); Assert.AreEqual(Architecture.AnyCPU, sourceArchitectures["NotDotNetAssebly.appx"]); } [TestMethod] - public void AutoDetectArchitectureShouldReturnDefaultArchForAllAnyCpuAssemblies() + public void TryArchitectureShouldReturnDefaultArchForAllAnyCpuAssemblies() { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU); - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "AnyCPU2.exe", "AnyCPU3.dll" }, sourceArchitectures, out this.isArchitectureIncompatible)); + + bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { "AnyCPU1.dll", "AnyCPU2.exe", "AnyCPU3.dll" }, sourceArchitectures, out var inferredArchitecture); + Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); + Assert.AreEqual(false, isArchitectureIncompatible); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); } [TestMethod] - public void AutoDetectArchitectureShouldReturnX86ArchIfOneX86AssemblyAndRestAnyCPU() + public void TryGetArchitectureShouldReturnX86ArchIfOneX86AssemblyAndRestAnyCPU() { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.X86); - Assert.AreEqual(Architecture.X86, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "AnyCPU2.exe", "x86.dll" }, sourceArchitectures, out this.isArchitectureIncompatible)); + bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { "AnyCPU1.dll", "AnyCPU2.exe", "x86.dll" }, sourceArchitectures, out var inferredArchitecture); + Assert.AreEqual(false, isArchitectureIncompatible); + Assert.AreEqual(Architecture.X86, inferredArchitecture); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); } [TestMethod] - public void AutoDetectArchitectureShouldReturnARMArchIfOneARMAssemblyAndRestAnyCPU() + public void TryGetArchitectureShouldReturnARMArchIfOneARMAssemblyAndRestAnyCPU() { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.ARM).Returns(Architecture.ARM).Returns(Architecture.ARM); - Assert.AreEqual(Architecture.ARM, inferHelper.AutoDetectArchitecture(new List() { "ARM1.dll", "ARM2.dll", "ARM3.dll" }, sourceArchitectures, out this.isArchitectureIncompatible)); + + bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { "ARM1.dll", "ARM2.dll", "ARM3.dll" }, sourceArchitectures, out var inferredArchitecture); + Assert.AreEqual(false, isArchitectureIncompatible); + Assert.AreEqual(Architecture.ARM, inferredArchitecture); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); } [TestMethod] - public void AutoDetectArchitectureShouldReturnX64ArchIfOneX64AssemblyAndRestAnyCPU() + public void TryGetArchitectureShouldReturnX64ArchIfOneX64AssemblyAndRestAnyCPU() { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.X64); - Assert.AreEqual(Architecture.X64, inferHelper.AutoDetectArchitecture(new List() { "x64.dll", "AnyCPU2.exe", "x64.dll" }, sourceArchitectures, out this.isArchitectureIncompatible)); + + bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { "x64.dll", "AnyCPU2.exe", "x64.dll" }, sourceArchitectures, out var inferredArchitecture); + Assert.AreEqual(false, isArchitectureIncompatible); + Assert.AreEqual(Architecture.X64, inferredArchitecture); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); } [TestMethod] - public void AutoDetectArchitectureShouldReturnDefaultArchOnConflictArches() + public void TryGetArchitectureShouldReturnDefaultArchOnConflictArches() { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.X64).Returns(Architecture.X86); - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "x64.exe", "x86.dll" }, sourceArchitectures, out this.isArchitectureIncompatible)); + + bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { "AnyCPU1.dll", "x64.exe", "x86.dll" }, sourceArchitectures, out var inferredArchitecture); + Assert.AreEqual(true, isArchitectureIncompatible); + Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); } [TestMethod] - public void AutoDetectArchitectureShouldPoulateSourceArchitectureDictionary() + public void TryGetArchitectureShouldPoulateSourceArchitectureDictionary() { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.X64).Returns(Architecture.X86); - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "x64.exe", "x86.dll" }, sourceArchitectures, out this.isArchitectureIncompatible)); + inferHelper.TryGetCompatibleArchitecture(new List() { "AnyCPU1.dll", "x64.exe", "x86.dll" }, sourceArchitectures, out var inferredArchitecture); + Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); Assert.AreEqual(3, sourceArchitectures.Count); Assert.AreEqual(Architecture.AnyCPU, sourceArchitectures["AnyCPU1.dll"]); Assert.AreEqual(Architecture.X64, sourceArchitectures["x64.exe"]); @@ -146,40 +178,46 @@ public void AutoDetectArchitectureShouldPoulateSourceArchitectureDictionary() } [TestMethod] - public void AutoDetectArchitectureShouldReturnDefaultArchIfthereIsNotDotNetAssemblyInSources() + public void TryGetArchitectureShouldReturnDefaultArchIfthereIsNotDotNetAssemblyInSources() { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU); - Assert.AreEqual(Constants.DefaultPlatform, inferHelper.AutoDetectArchitecture(new List() { "AnyCPU1.dll", "NotDotNetAssebly.appx" }, sourceArchitectures, out this.isArchitectureIncompatible)); + + inferHelper.TryGetCompatibleArchitecture(new List() { "AnyCPU1.dll", "NotDotNetAssebly.appx" }, sourceArchitectures, out var inferredArchitecture); + Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(1)); } [TestMethod] - public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnNullSources() + public void TryGetFrameworkShouldReturnDefaultFrameworkOnNullSources() { - Assert.AreEqual(defaultFramework, inferHelper.AutoDetectFramework(null, sourceFrameworks, out this.isFrameworkIncompatible)); + inferHelper.TryGetCompatibleFramework(null, sourceFrameworks, out var inferredFramework); + Assert.AreEqual(defaultFramework, inferredFramework); } [TestMethod] - public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnEmptySources() + public void TryGetFrameworkShouldReturnDefaultFrameworkOnEmptySources() { - Assert.AreEqual(defaultFramework, inferHelper.AutoDetectFramework(new List(0), sourceFrameworks, out this.isFrameworkIncompatible)); + inferHelper.TryGetCompatibleFramework(new List(0), sourceFrameworks, out var inferredFramework); + Assert.AreEqual(defaultFramework, inferredFramework); } [TestMethod] - public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnNullItemInSources() + public void TryGetFrameworkShouldReturnDefaultFrameworkOnNullItemInSources() { - Assert.AreEqual(defaultFramework, inferHelper.AutoDetectFramework(new List(){null}, sourceFrameworks, out this.isFrameworkIncompatible)); + inferHelper.TryGetCompatibleFramework(new List() { null }, sourceFrameworks, out var inferredFramework); + Assert.AreEqual(defaultFramework, inferredFramework); } [TestMethod] public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnEmptyItemInSources() { - Assert.AreEqual(defaultFramework.Name, inferHelper.AutoDetectFramework(new List() { string.Empty }, sourceFrameworks, out this.isFrameworkIncompatible).Name); + inferHelper.TryGetCompatibleFramework(new List() { string.Empty }, sourceFrameworks, out var inferredFramework); + Assert.AreEqual(defaultFramework.Name, inferredFramework.Name); } [TestMethod] - public void AutoDetectFrameworkShouldReturnFrameworkCore10OnCore10Sources() + public void TryGetFrameworkShouldReturnFrameworkCore10OnCore10Sources() { var fx = frameworkCore10; var assemblyName = "netcoreapp.dll"; @@ -187,7 +225,7 @@ public void AutoDetectFrameworkShouldReturnFrameworkCore10OnCore10Sources() } [TestMethod] - public void AutoDetectFrameworkShouldReturnFramework46On46Sources() + public void TryGetFrameworkShouldReturnFramework46On46Sources() { var fx = frameworkNet46; var assemblyName = "net46.dll"; @@ -195,7 +233,7 @@ public void AutoDetectFrameworkShouldReturnFramework46On46Sources() } [TestMethod] - public void AutoDetectFrameworkShouldReturnFrameworkUap10ForAppxFiles() + public void TryGetFrameworkShouldReturnFrameworkUap10ForAppxFiles() { var fx = Framework.FromString(Constants.DotNetFrameworkUap10); var assemblyName = "uwp10.appx"; @@ -203,7 +241,7 @@ public void AutoDetectFrameworkShouldReturnFrameworkUap10ForAppxFiles() } [TestMethod] - public void AutoDetectFrameworkShouldReturnFrameworkUap10ForAppxrecipeFiles() + public void TryGetFrameworkShouldReturnFrameworkUap10ForAppxrecipeFiles() { var fx = Framework.FromString(Constants.DotNetFrameworkUap10); var assemblyName = "uwp10.appxrecipe"; @@ -211,7 +249,7 @@ public void AutoDetectFrameworkShouldReturnFrameworkUap10ForAppxrecipeFiles() } [TestMethod] - public void AutoDetectFrameworkShouldReturnDefaultFullFrameworkForJsFiles() + public void TryGetFrameworkShouldReturnDefaultFullFrameworkForJsFiles() { var fx = Framework.FromString(Constants.DotNetFramework40); var assemblyName = "vstests.js"; @@ -219,25 +257,28 @@ public void AutoDetectFrameworkShouldReturnDefaultFullFrameworkForJsFiles() } [TestMethod] - public void AutoDetectFrameworkShouldReturnHighestVersionFxOnSameFxName() + public void TryGetFrameworkShouldReturnHighestVersionFxOnSameFxName() { this.mockAssemblyHelper.SetupSequence(sh => sh.GetFrameWork(It.IsAny())) .Returns(new FrameworkName(frameworkNet46.Name)) .Returns(new FrameworkName(frameworkNet47.Name)) .Returns(new FrameworkName(frameworkNet45.Name)); - Assert.AreEqual(frameworkNet47.Name, inferHelper.AutoDetectFramework(new List() { "net46.dll", "net47.exe", "net45.dll" }, sourceFrameworks, out this.isFrameworkIncompatible).Name); + + inferHelper.TryGetCompatibleFramework(new List() { "net46.dll", "net47.exe", "net45.dll" }, sourceFrameworks, out var inferredFramework); + Assert.AreEqual(frameworkNet47.Name, inferredFramework.Name); this.mockAssemblyHelper.Verify(ah => ah.GetFrameWork(It.IsAny()),Times.Exactly(3)); } [TestMethod] - public void AutoDetectFrameworkShouldPopulatetheDictionaryForAllTheSources() + public void TryGetFrameworkShouldPopulatetheDictionaryForAllTheSources() { this.mockAssemblyHelper.SetupSequence(sh => sh.GetFrameWork(It.IsAny())) .Returns(new FrameworkName(frameworkNet46.Name)) .Returns(new FrameworkName(frameworkNet47.Name)) .Returns(new FrameworkName(frameworkNet45.Name)); - Assert.AreEqual(frameworkNet47.Name, inferHelper.AutoDetectFramework(new List() { "net46.dll", "net47.exe", "net45.dll" }, sourceFrameworks, out this.isFrameworkIncompatible).Name); + inferHelper.TryGetCompatibleFramework(new List() { "net46.dll", "net47.exe", "net45.dll" }, sourceFrameworks, out var inferredFramework); + Assert.AreEqual(frameworkNet47.Name, inferredFramework.Name); Assert.AreEqual(3, sourceFrameworks.Count); Assert.AreEqual(frameworkNet46.Name, sourceFrameworks["net46.dll"].Name); @@ -247,13 +288,14 @@ public void AutoDetectFrameworkShouldPopulatetheDictionaryForAllTheSources() } [TestMethod] - public void AutoDetectFrameworkShouldReturnHighestVersionFxOnEvenManyLowerVersionFxNameExists() + public void TryGetFrameworkShouldReturnHighestVersionFxOnEvenManyLowerVersionFxNameExists() { this.mockAssemblyHelper.SetupSequence(sh => sh.GetFrameWork(It.IsAny())) .Returns(new FrameworkName(frameworkCore10.Name)) .Returns(new FrameworkName(frameworkCore11.Name)) .Returns(new FrameworkName(frameworkCore10.Name)); - Assert.AreEqual(frameworkCore11.Name, inferHelper.AutoDetectFramework(new List() { "netcore10_1.dll", "netcore11.dll", "netcore10_2.dll" }, sourceFrameworks, out this.isFrameworkIncompatible).Name); + inferHelper.TryGetCompatibleFramework(new List() { "netcore10_1.dll", "netcore11.dll", "netcore10_2.dll" }, sourceFrameworks, out var inferredFramework); + Assert.AreEqual(frameworkCore11.Name, inferredFramework.Name); this.mockAssemblyHelper.Verify(ah => ah.GetFrameWork(It.IsAny()), Times.Exactly(3)); } @@ -261,7 +303,8 @@ private void SetupAndValidateForSingleAssembly(string assemblyName, Framework fx { this.mockAssemblyHelper.Setup(sh => sh.GetFrameWork(assemblyName)) .Returns(new FrameworkName(fx.Name)); - Assert.AreEqual(fx.Name, inferHelper.AutoDetectFramework(new List() { assemblyName }, sourceFrameworks, out this.isFrameworkIncompatible).Name); + inferHelper.TryGetCompatibleFramework(new List() { assemblyName }, sourceFrameworks, out var inferredFramework); + Assert.AreEqual(fx.Name, inferredFramework.Name); if (verify) { this.mockAssemblyHelper.Verify(ah => ah.GetFrameWork(assemblyName)); diff --git a/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs b/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs index 69db75076a..7b76f5f4ea 100644 --- a/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs +++ b/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs @@ -808,42 +808,6 @@ public void DiscoverTestsShouldThrowTestPlatformExceptionIfSourceAndTargetFramew Assert.IsTrue(actualErrorMessage.Contains("Following DLL(s) do not match framework/platform settings")); } - [TestMethod] - public void DiscoverTestsShouldThrowTestPlatformExceptionIfSourceAndTargetPlatformsAreIncompatible() - { - var payload = new DiscoveryRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - - " - }; - this.commandLineOptions.TargetArchitecture = Architecture.X64; - this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())) - .Returns(Architecture.X86); - - this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())) - .Returns(new FrameworkName(Framework.DefaultFramework.Name)); - - DiscoveryCriteria actualDiscoveryCriteria = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform - .Setup(mt => mt.CreateDiscoveryRequest(It.IsAny(), It.IsAny(), It.IsAny())) - .Callback( - (IRequestData requestData, DiscoveryCriteria discoveryCriteria, TestPlatformOptions options) => - { - actualDiscoveryCriteria = discoveryCriteria; - }).Returns(mockDiscoveryRequest.Object); - - var actualErrorMessage = Assert.ThrowsException(() => this.testRequestManager.DiscoverTests(payload, - new Mock().Object, this.protocolConfig)).Message; - - Assert.IsTrue(actualErrorMessage.Contains("Following DLL(s) do not match framework/platform settings")); - } - [TestMethod] public void DiscoverTestsShouldPublishMetrics() { @@ -977,35 +941,6 @@ public void RunTestsShouldThrowTestPlatformExceptionIfSourceAndTargetFrameworksA Assert.IsTrue(actualErrorMessage.Contains("Following DLL(s) do not match framework/platform settings")); } - [TestMethod] - public void RunTestsShouldThrowTestPlatformExceptionIfSourceAndTargetArchitecturesAreIncompatible() - { - var payload = new TestRunRequestPayload() - { - Sources = new List() { "a.dll" }, - RunSettings = - @" - - - Framework35 - - " - }; - - this.commandLineOptions.TargetArchitecture = Architecture.X86; - TestRunCriteria actualTestRunCriteria = null; - var mockDiscoveryRequest = new Mock(); - this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny(), It.IsAny(), It.IsAny())).Callback( - (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options) => - { - actualTestRunCriteria = runCriteria; - }).Returns(mockDiscoveryRequest.Object); - this.mockAssemblyMetadataProvider.Setup(a => a.GetArchitecture(It.IsAny())).Returns(Architecture.X64); - var actualErrorMessage = Assert.ThrowsException(() => this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig)).Message; - - Assert.IsTrue(actualErrorMessage.Contains("Following DLL(s) do not match framework/platform settings")); - } - [TestMethod] public void RunTestsShouldPassSameProtocolConfigInRequestData() { From 99436366fd89bb23975a3f9c2b15b9171692e66d Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Sat, 1 Dec 2018 15:54:52 +0530 Subject: [PATCH 05/19] minor fix in test --- .../TestPlatformHelpers/TestRequestManagerTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs b/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs index 7b76f5f4ea..d849cf3408 100644 --- a/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs +++ b/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs @@ -1622,7 +1622,7 @@ public void RunTestsShouldNotpdateFrameworkAndPlatformInCommandLineScenariosIfSp this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny()), Times.Once); this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny()), Times.Once); - Assert.IsFalse(actualTestRunCriteria.TestRunSettings.Contains("Framework")); + Assert.IsFalse(actualTestRunCriteria.TestRunSettings.Contains("")); Assert.IsFalse(actualTestRunCriteria.TestRunSettings.Contains(Architecture.ARM.ToString())); } From 30ebd1439eb0b47447c513b745da1cc07f384556 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Thu, 6 Dec 2018 17:37:49 +0530 Subject: [PATCH 06/19] fix in test --- .../TestPlatformHelpers/TestRequestManagerTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs b/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs index d849cf3408..031ffb6026 100644 --- a/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs +++ b/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs @@ -768,7 +768,7 @@ public void DiscoverTestsShouldNotUpdateFrameworkAndPlatformInCommandLineScenari this.mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny()), Times.Once); this.mockAssemblyMetadataProvider.Verify(a => a.GetFrameWork(It.IsAny()), Times.Once); - Assert.IsFalse(actualDiscoveryCriteria.RunSettings.Contains("Framework")); + Assert.IsFalse(actualDiscoveryCriteria.RunSettings.Contains("")); Assert.IsFalse(actualDiscoveryCriteria.RunSettings.Contains(Architecture.ARM.ToString())); } From e6230ba2bfe95e1dd767ac70adcef0cf4f530206 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Fri, 21 Dec 2018 13:35:41 +0530 Subject: [PATCH 07/19] improved error message --- .../Resources/CommonResources.resx | 2 +- .../Resources/xlf/CommonResources.cs.xlf | 2 +- .../Resources/xlf/CommonResources.de.xlf | 2 +- .../Resources/xlf/CommonResources.es.xlf | 2 +- .../Resources/xlf/CommonResources.fr.xlf | 2 +- .../Resources/xlf/CommonResources.it.xlf | 2 +- .../Resources/xlf/CommonResources.ja.xlf | 2 +- .../Resources/xlf/CommonResources.ko.xlf | 2 +- .../Resources/xlf/CommonResources.pl.xlf | 2 +- .../Resources/xlf/CommonResources.pt-BR.xlf | 2 +- .../Resources/xlf/CommonResources.ru.xlf | 2 +- .../Resources/xlf/CommonResources.tr.xlf | 2 +- .../Resources/xlf/CommonResources.xlf | 2 +- .../Resources/xlf/CommonResources.zh-Hans.xlf | 2 +- .../Resources/xlf/CommonResources.zh-Hant.xlf | 2 +- src/vstest.console/Resources/Resources.resx | 2 +- src/vstest.console/Resources/xlf/Resources.cs.xlf | 6 +++--- src/vstest.console/Resources/xlf/Resources.de.xlf | 6 +++--- src/vstest.console/Resources/xlf/Resources.es.xlf | 6 +++--- src/vstest.console/Resources/xlf/Resources.fr.xlf | 6 +++--- src/vstest.console/Resources/xlf/Resources.it.xlf | 6 +++--- src/vstest.console/Resources/xlf/Resources.ja.xlf | 6 +++--- src/vstest.console/Resources/xlf/Resources.ko.xlf | 6 +++--- src/vstest.console/Resources/xlf/Resources.pl.xlf | 6 +++--- src/vstest.console/Resources/xlf/Resources.pt-BR.xlf | 6 +++--- src/vstest.console/Resources/xlf/Resources.ru.xlf | 6 +++--- src/vstest.console/Resources/xlf/Resources.tr.xlf | 6 +++--- src/vstest.console/Resources/xlf/Resources.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf | 6 +++--- src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf | 6 +++--- .../TestPlatformHelpers/TestRequestManager.cs | 3 ++- 31 files changed, 58 insertions(+), 57 deletions(-) diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.resx b/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.resx index 15106a4081..bc965abc8b 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.resx +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.resx @@ -121,7 +121,7 @@ The parameter cannot be null or empty. - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.cs.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.cs.xlf index 681a9364d0..d36c7c2511 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.cs.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.cs.xlf @@ -30,7 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. Testovací běh použije knihovny DLL sestavené pro rozhraní {0} a platformu {1}. Tyto knihovny DLL nebudou součástí běhu: {2}Další podrobnosti o správě těchto nastavení najdete na adrese {3}. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.de.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.de.xlf index 205cbaf891..be406e0eeb 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.de.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.de.xlf @@ -30,7 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. Der Testlauf verwendet DLLs, die für das Framework {0} und die Plattform {1} erstellt wurden. Die folgenden DLLs sind nicht Teil der Ausführung: {2}.Navigieren Sie zu {3}, um weitere Details zum Verwalten dieser Einstellungen zu erhalten. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.es.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.es.xlf index 7c1eea7062..c5e97b4882 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.es.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.es.xlf @@ -30,7 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. La serie de pruebas usará archivos DLL compilados para el marco {0} y la plataforma {1}. Los siguientes archivos DLL no formarán parte de la ejecución: {2}Vaya a {3} para obtener más información sobre cómo administrar esta configuración. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.fr.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.fr.xlf index a252303d8e..9702a5ec3b 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.fr.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.fr.xlf @@ -30,7 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. La série de tests utilise des DLL générées pour le framework {0} et la plateforme {1}. Les DLL suivantes ne font pas partie de la série de tests : {2}Accédez à {3} pour plus de détails sur la gestion de ces paramètres. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.it.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.it.xlf index 104a8fad47..d429c8f284 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.it.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.it.xlf @@ -30,7 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. Per l'esecuzione dei test verranno usate DLL compilate per il framework {0} e la piattaforma {1}. Le DLL seguenti non saranno incluse nell'esecuzione: {2}.Per maggiori dettagli sulla gestione di queste impostazioni, passare a {3}. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ja.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ja.xlf index ea18faf8b9..de7bcbddde 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ja.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ja.xlf @@ -30,7 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. テスト実行ではフレームワーク {0} およびプラットフォーム {1} 用にビルドされた DLL を使用します。次の DLL は実行には含まれません: {2}これらの設定の管理方法の詳細については、{3} にアクセスしてください。 diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ko.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ko.xlf index 6102fdb6de..6b4bba4c69 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ko.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ko.xlf @@ -30,7 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. 테스트 실행에서는 프레임워크 {0} 및 플랫폼 {1}용으로 작성된 DLL을 사용합니다. 다음 DLL은 실행에서 사용할 수 없습니다. {2}.이러한 설정의 관리에 대한 자세한 내용은 {3}을(를) 참조하세요. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pl.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pl.xlf index f8e5ef7d34..f3ad46f163 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pl.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pl.xlf @@ -30,7 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. Przebieg testu użyje plików DLL przeznaczonych dla struktury {0} i platformy {1}. Następujące pliki DLL nie pasują do ustawień struktury/platformy.{2}.Aby uzyskać więcej informacji na temat zarządzania tymi ustawieniami, przejdź do strony {3}. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pt-BR.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pt-BR.xlf index 666f246168..b9f3595269 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pt-BR.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pt-BR.xlf @@ -30,7 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. A execução de teste usará DLLs criadas para a estrutura {0} e a plataforma {1}. As seguintes DLLs não farão parte da execução: {2}Acesse {3} para obter mais detalhes sobre como gerenciar essas configurações. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ru.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ru.xlf index 766eb0a3c2..08b0e178e9 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ru.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ru.xlf @@ -30,7 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. При запуске тестов будут использоваться библиотеки DLL, собранные для платформ {0} и {1}. Следующие библиотеки DLL не будут участвовать в запуске: {2}.Дополнительные сведения об управлении этими параметрами см. в разделе {3}. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.tr.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.tr.xlf index e2abb91ffb..51f425e03c 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.tr.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.tr.xlf @@ -30,7 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. Test çalıştırmasında, {0} çerçevesi ve {1} platformu için oluşturulan DLL’ler kullanılacak. Şu DLL’ler çalıştırmaya dahil edilmeyecek: {2}Bu ayarları yönetmeye ilişkin ayrıntılar için {3} sayfasına gidin. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.xlf index 3dd48783c9..9f1102a1e0 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.xlf @@ -7,7 +7,7 @@ - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hans.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hans.xlf index 86e37749a3..5cf5efefcf 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hans.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hans.xlf @@ -30,7 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. 测试运行将使用为框架 {0} 和平台 {1} 生成的 DLL。以下 DLL 将不是运行的一部分: {2}转到 {3} 了解有关管理这些设置的详细信息。 diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hant.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hant.xlf index 6faaa5b01a..68d6c786ae 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hant.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hant.xlf @@ -30,7 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Go to {3} for more details on managing these settings. + The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. 測試回合將使用替架構 {0} 與平台 {1} 所建置的 DLL。下列 DLL 將不包含在測試回合中: {2}如需如何管理這些設定的詳細資料,請前往 {3}。 diff --git a/src/vstest.console/Resources/Resources.resx b/src/vstest.console/Resources/Resources.resx index ceb1e89f85..458ca59251 100644 --- a/src/vstest.console/Resources/Resources.resx +++ b/src/vstest.console/Resources/Resources.resx @@ -668,7 +668,7 @@ /Blame:CollectDump;CollectAlways=true;DumpType=full - Test Run Aborted. + Test Run Aborted. {0} Test Run Canceled. diff --git a/src/vstest.console/Resources/xlf/Resources.cs.xlf b/src/vstest.console/Resources/xlf/Resources.cs.xlf index ef01f8ec69..595fd4811c 100644 --- a/src/vstest.console/Resources/xlf/Resources.cs.xlf +++ b/src/vstest.console/Resources/xlf/Resources.cs.xlf @@ -1517,9 +1517,9 @@ - Test Run Aborted. - Testovací běh se přerušil. - + Test Run Aborted. {0} + Testovací běh se přerušil. + Test Run Canceled. diff --git a/src/vstest.console/Resources/xlf/Resources.de.xlf b/src/vstest.console/Resources/xlf/Resources.de.xlf index 2054f38fb3..e9b8b3f7f7 100644 --- a/src/vstest.console/Resources/xlf/Resources.de.xlf +++ b/src/vstest.console/Resources/xlf/Resources.de.xlf @@ -1517,9 +1517,9 @@ - Test Run Aborted. - Testlauf abgebrochen. - + Test Run Aborted. {0} + Testlauf abgebrochen. + Test Run Canceled. diff --git a/src/vstest.console/Resources/xlf/Resources.es.xlf b/src/vstest.console/Resources/xlf/Resources.es.xlf index 186dbd02bb..495d7208f1 100644 --- a/src/vstest.console/Resources/xlf/Resources.es.xlf +++ b/src/vstest.console/Resources/xlf/Resources.es.xlf @@ -1522,9 +1522,9 @@ - Test Run Aborted. - Serie de pruebas anulada. - + Test Run Aborted. {0} + Serie de pruebas anulada. + Test Run Canceled. diff --git a/src/vstest.console/Resources/xlf/Resources.fr.xlf b/src/vstest.console/Resources/xlf/Resources.fr.xlf index 29fb1091fe..954711d818 100644 --- a/src/vstest.console/Resources/xlf/Resources.fr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.fr.xlf @@ -1517,9 +1517,9 @@ - Test Run Aborted. - Série de tests abandonnée. - + Test Run Aborted. {0} + Série de tests abandonnée. + Test Run Canceled. diff --git a/src/vstest.console/Resources/xlf/Resources.it.xlf b/src/vstest.console/Resources/xlf/Resources.it.xlf index 2f78479ff0..8480a75299 100644 --- a/src/vstest.console/Resources/xlf/Resources.it.xlf +++ b/src/vstest.console/Resources/xlf/Resources.it.xlf @@ -1517,9 +1517,9 @@ - Test Run Aborted. - Esecuzione dei test interrotta. - + Test Run Aborted. {0} + Esecuzione dei test interrotta. + Test Run Canceled. diff --git a/src/vstest.console/Resources/xlf/Resources.ja.xlf b/src/vstest.console/Resources/xlf/Resources.ja.xlf index 9bce0bf1ee..a00860f28e 100644 --- a/src/vstest.console/Resources/xlf/Resources.ja.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ja.xlf @@ -1517,9 +1517,9 @@ - Test Run Aborted. - テスト実行が中止されました。 - + Test Run Aborted. {0} + テスト実行が中止されました。 + Test Run Canceled. diff --git a/src/vstest.console/Resources/xlf/Resources.ko.xlf b/src/vstest.console/Resources/xlf/Resources.ko.xlf index 0004a305ce..b5e3161ae6 100644 --- a/src/vstest.console/Resources/xlf/Resources.ko.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ko.xlf @@ -1517,9 +1517,9 @@ - Test Run Aborted. - 테스트 실행이 중단되었습니다. - + Test Run Aborted. {0} + 테스트 실행이 중단되었습니다. + Test Run Canceled. diff --git a/src/vstest.console/Resources/xlf/Resources.pl.xlf b/src/vstest.console/Resources/xlf/Resources.pl.xlf index fa84359e25..32e5e217a9 100644 --- a/src/vstest.console/Resources/xlf/Resources.pl.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pl.xlf @@ -1516,9 +1516,9 @@ - Test Run Aborted. - Przebieg testu został przerwany. - + Test Run Aborted. {0} + Przebieg testu został przerwany. + Test Run Canceled. diff --git a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf index 6964ccf51c..06a6faeca2 100644 --- a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf @@ -1516,9 +1516,9 @@ - Test Run Aborted. - Execução de Teste Anulada. - + Test Run Aborted. {0} + Execução de Teste Anulada. + Test Run Canceled. diff --git a/src/vstest.console/Resources/xlf/Resources.ru.xlf b/src/vstest.console/Resources/xlf/Resources.ru.xlf index 2aa80b9a9a..e229bab1bf 100644 --- a/src/vstest.console/Resources/xlf/Resources.ru.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ru.xlf @@ -1517,9 +1517,9 @@ - Test Run Aborted. - Тестовый запуск прерван. - + Test Run Aborted. {0} + Тестовый запуск прерван. + Test Run Canceled. diff --git a/src/vstest.console/Resources/xlf/Resources.tr.xlf b/src/vstest.console/Resources/xlf/Resources.tr.xlf index cc35d11ec2..1379dbcc89 100644 --- a/src/vstest.console/Resources/xlf/Resources.tr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.tr.xlf @@ -1517,9 +1517,9 @@ - Test Run Aborted. - Test Çalıştırması Durduruldu. - + Test Run Aborted. {0} + Test Çalıştırması Durduruldu. + Test Run Canceled. diff --git a/src/vstest.console/Resources/xlf/Resources.xlf b/src/vstest.console/Resources/xlf/Resources.xlf index ea755e3882..db44e92b3c 100644 --- a/src/vstest.console/Resources/xlf/Resources.xlf +++ b/src/vstest.console/Resources/xlf/Resources.xlf @@ -690,7 +690,7 @@ - Test Run Aborted. + Test Run Aborted. {0} Test Run Aborted. diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf index 9b3fab04ae..3bab9fcc47 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf @@ -1517,9 +1517,9 @@ - Test Run Aborted. - 测试运行已中止。 - + Test Run Aborted. {0} + 测试运行已中止。 + Test Run Canceled. diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf index d48ba3e51d..8c01df5fd2 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf @@ -1517,9 +1517,9 @@ - Test Run Aborted. - 測試回合已中止。 - + Test Run Aborted. {0} + 測試回合已中止。 + Test Run Canceled. diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index 2ef0213c1f..9c8b4a8710 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -5,6 +5,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers { using System; using System.Collections.Generic; + using System.Globalization; using System.IO; using System.Linq; using System.Reflection; @@ -398,7 +399,7 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List sou EqtTrace.Info(incompatibleSettingWarning); if(isSettingIncompatible) { - throw new TestPlatformException(incompatibleSettingWarning); + throw new TestPlatformException(string.Format(CultureInfo.CurrentCulture, Resources.TestRunAborted, incompatibleSettingWarning)); } ConsoleLogger.RaiseTestRunWarning(incompatibleSettingWarning); } From 3fa02c1837af3810c1ed52d88d370fd4703e395b Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Mon, 31 Dec 2018 12:39:13 +0530 Subject: [PATCH 08/19] PR comments --- .../Resources/CommonResources.resx | 3 +- .../Resources/xlf/CommonResources.cs.xlf | 3 +- .../Resources/xlf/CommonResources.de.xlf | 3 +- .../Resources/xlf/CommonResources.es.xlf | 3 +- .../Resources/xlf/CommonResources.fr.xlf | 3 +- .../Resources/xlf/CommonResources.it.xlf | 3 +- .../Resources/xlf/CommonResources.ja.xlf | 3 +- .../Resources/xlf/CommonResources.ko.xlf | 3 +- .../Resources/xlf/CommonResources.pl.xlf | 3 +- .../Resources/xlf/CommonResources.pt-BR.xlf | 3 +- .../Resources/xlf/CommonResources.ru.xlf | 3 +- .../Resources/xlf/CommonResources.tr.xlf | 3 +- .../Resources/xlf/CommonResources.xlf | 3 +- .../Resources/xlf/CommonResources.zh-Hans.xlf | 3 +- .../Resources/xlf/CommonResources.zh-Hant.xlf | 3 +- .../InferRunSettingsHelper.cs | 59 +++++++++---------- .../TestPlatformHelpers/TestRequestManager.cs | 2 +- .../FrameworkTests.cs | 2 +- .../TestRequestManagerTests.cs | 4 +- 19 files changed, 48 insertions(+), 64 deletions(-) diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.resx b/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.resx index bc965abc8b..5ca295f037 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.resx +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.resx @@ -121,8 +121,7 @@ The parameter cannot be null or empty. - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. - + The following DLL(s) do not match the specified framework {0} and platform {1} settings.{2}Ensure that the test assemblies target the specified framework/platform settings. Go to {3} for more details on managing these settings. Settings file provided does not conform to required format. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.cs.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.cs.xlf index d36c7c2511..41a4f22174 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.cs.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.cs.xlf @@ -30,8 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. - + The following DLL(s) do not match the specified framework {0} and platform {1} settings.{2}Ensure that the test assemblies target the specified framework/platform settings. Go to {3} for more details on managing these settings. Testovací běh použije knihovny DLL sestavené pro rozhraní {0} a platformu {1}. Tyto knihovny DLL nebudou součástí běhu: {2}Další podrobnosti o správě těchto nastavení najdete na adrese {3}. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.de.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.de.xlf index be406e0eeb..6b4cf68d3b 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.de.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.de.xlf @@ -30,8 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. - + The following DLL(s) do not match the specified framework {0} and platform {1} settings.{2}Ensure that the test assemblies target the specified framework/platform settings. Go to {3} for more details on managing these settings. Der Testlauf verwendet DLLs, die für das Framework {0} und die Plattform {1} erstellt wurden. Die folgenden DLLs sind nicht Teil der Ausführung: {2}.Navigieren Sie zu {3}, um weitere Details zum Verwalten dieser Einstellungen zu erhalten. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.es.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.es.xlf index c5e97b4882..50f7f02136 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.es.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.es.xlf @@ -30,8 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. - + The following DLL(s) do not match the specified framework {0} and platform {1} settings.{2}Ensure that the test assemblies target the specified framework/platform settings. Go to {3} for more details on managing these settings. La serie de pruebas usará archivos DLL compilados para el marco {0} y la plataforma {1}. Los siguientes archivos DLL no formarán parte de la ejecución: {2}Vaya a {3} para obtener más información sobre cómo administrar esta configuración. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.fr.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.fr.xlf index 9702a5ec3b..cde50de7d1 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.fr.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.fr.xlf @@ -30,8 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. - + The following DLL(s) do not match the specified framework {0} and platform {1} settings.{2}Ensure that the test assemblies target the specified framework/platform settings. Go to {3} for more details on managing these settings. La série de tests utilise des DLL générées pour le framework {0} et la plateforme {1}. Les DLL suivantes ne font pas partie de la série de tests : {2}Accédez à {3} pour plus de détails sur la gestion de ces paramètres. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.it.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.it.xlf index d429c8f284..397d990497 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.it.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.it.xlf @@ -30,8 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. - + The following DLL(s) do not match the specified framework {0} and platform {1} settings.{2}Ensure that the test assemblies target the specified framework/platform settings. Go to {3} for more details on managing these settings. Per l'esecuzione dei test verranno usate DLL compilate per il framework {0} e la piattaforma {1}. Le DLL seguenti non saranno incluse nell'esecuzione: {2}.Per maggiori dettagli sulla gestione di queste impostazioni, passare a {3}. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ja.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ja.xlf index de7bcbddde..6e9724b8ec 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ja.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ja.xlf @@ -30,8 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. - + The following DLL(s) do not match the specified framework {0} and platform {1} settings.{2}Ensure that the test assemblies target the specified framework/platform settings. Go to {3} for more details on managing these settings. テスト実行ではフレームワーク {0} およびプラットフォーム {1} 用にビルドされた DLL を使用します。次の DLL は実行には含まれません: {2}これらの設定の管理方法の詳細については、{3} にアクセスしてください。 diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ko.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ko.xlf index 6b4bba4c69..3ec0948089 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ko.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ko.xlf @@ -30,8 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. - + The following DLL(s) do not match the specified framework {0} and platform {1} settings.{2}Ensure that the test assemblies target the specified framework/platform settings. Go to {3} for more details on managing these settings. 테스트 실행에서는 프레임워크 {0} 및 플랫폼 {1}용으로 작성된 DLL을 사용합니다. 다음 DLL은 실행에서 사용할 수 없습니다. {2}.이러한 설정의 관리에 대한 자세한 내용은 {3}을(를) 참조하세요. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pl.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pl.xlf index f3ad46f163..c52dc9e994 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pl.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pl.xlf @@ -30,8 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. - + The following DLL(s) do not match the specified framework {0} and platform {1} settings.{2}Ensure that the test assemblies target the specified framework/platform settings. Go to {3} for more details on managing these settings. Przebieg testu użyje plików DLL przeznaczonych dla struktury {0} i platformy {1}. Następujące pliki DLL nie pasują do ustawień struktury/platformy.{2}.Aby uzyskać więcej informacji na temat zarządzania tymi ustawieniami, przejdź do strony {3}. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pt-BR.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pt-BR.xlf index b9f3595269..66206d0e83 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pt-BR.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.pt-BR.xlf @@ -30,8 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. - + The following DLL(s) do not match the specified framework {0} and platform {1} settings.{2}Ensure that the test assemblies target the specified framework/platform settings. Go to {3} for more details on managing these settings. A execução de teste usará DLLs criadas para a estrutura {0} e a plataforma {1}. As seguintes DLLs não farão parte da execução: {2}Acesse {3} para obter mais detalhes sobre como gerenciar essas configurações. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ru.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ru.xlf index 08b0e178e9..2d39b2f233 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ru.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.ru.xlf @@ -30,8 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. - + The following DLL(s) do not match the specified framework {0} and platform {1} settings.{2}Ensure that the test assemblies target the specified framework/platform settings. Go to {3} for more details on managing these settings. При запуске тестов будут использоваться библиотеки DLL, собранные для платформ {0} и {1}. Следующие библиотеки DLL не будут участвовать в запуске: {2}.Дополнительные сведения об управлении этими параметрами см. в разделе {3}. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.tr.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.tr.xlf index 51f425e03c..ed438a5e49 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.tr.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.tr.xlf @@ -30,8 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. - + The following DLL(s) do not match the specified framework {0} and platform {1} settings.{2}Ensure that the test assemblies target the specified framework/platform settings. Go to {3} for more details on managing these settings. Test çalıştırmasında, {0} çerçevesi ve {1} platformu için oluşturulan DLL’ler kullanılacak. Şu DLL’ler çalıştırmaya dahil edilmeyecek: {2}Bu ayarları yönetmeye ilişkin ayrıntılar için {3} sayfasına gidin. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.xlf index 9f1102a1e0..2393867f14 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.xlf @@ -7,8 +7,7 @@ - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. - + The following DLL(s) do not match the specified framework {0} and platform {1} settings.{2}Ensure that the test assemblies target the specified framework/platform settings. Go to {3} for more details on managing these settings. diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hans.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hans.xlf index 5cf5efefcf..1457d46ac3 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hans.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hans.xlf @@ -30,8 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. - + The following DLL(s) do not match the specified framework {0} and platform {1} settings.{2}Ensure that the test assemblies target the specified framework/platform settings. Go to {3} for more details on managing these settings. 测试运行将使用为框架 {0} 和平台 {1} 生成的 DLL。以下 DLL 将不是运行的一部分: {2}转到 {3} 了解有关管理这些设置的详细信息。 diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hant.xlf b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hant.xlf index 68d6c786ae..d125400484 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hant.xlf +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/xlf/CommonResources.zh-Hant.xlf @@ -30,8 +30,7 @@ fuzzyMatch="15" wordcount="7" adjWordcount="5.95" curWordcount="5.95" - The specified framework {0} and platform {1} is incompatible with the target framework/platform of test assemblies. Following DLL(s) do not match framework/platform settings.{2}Ensure that the target framework and platform of the test assemblies match the specified value. Go to {3} for more details on managing these settings. - + The following DLL(s) do not match the specified framework {0} and platform {1} settings.{2}Ensure that the test assemblies target the specified framework/platform settings. Go to {3} for more details on managing these settings. 測試回合將使用替架構 {0} 與平台 {1} 所建置的 DLL。下列 DLL 將不包含在測試回合中: {2}如需如何管理這些設定的詳細資料,請前往 {3}。 diff --git a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs index 3016bbe503..368346feaa 100644 --- a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs +++ b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs @@ -624,7 +624,7 @@ public static IEnumerable FilterCompatibleSources(Architecture chosenPla { Architecture actualPlatform = sourcePlatforms[source]; Framework actualFramework = sourceFrameworks[source]; - bool isSettingIncompatible = IsSettingIncompatible(actualPlatform, chosenPlatform, actualFramework, chosenFramework) || IsFrameworkRuntimeIncompatible(actualFramework, chosenFramework); + bool isSettingIncompatible = IsSettingIncompatible(actualPlatform, chosenPlatform, actualFramework, chosenFramework); if (isSettingIncompatible) { string incompatiblityMessage; @@ -649,30 +649,37 @@ public static IEnumerable FilterCompatibleSources(Architecture chosenPla } /// - /// Returns true if framework runtime of target framework is incompatible with any source framework + /// Returns true if target framework is incompatible with any source framework, that is run needs to be aborted /// - public static bool TryGetSettingIncompatibility(Architecture chosenPlatform, Framework chosenFramework, IDictionary sourcePlatforms, IDictionary sourceFrameworks) + public static bool IsFrameworkIncompatible(Framework chosenFramework, IDictionary sourceFrameworks) { bool isSettingIncompatible = false; - foreach (var source in sourcePlatforms.Keys) + foreach (var source in sourceFrameworks.Keys) { - Architecture actualPlatform = sourcePlatforms[source]; Framework actualFramework = sourceFrameworks[source]; - isSettingIncompatible = IsFrameworkRuntimeIncompatible(actualFramework, chosenFramework); + string sourceFrameworkName = actualFramework.Name.Split(',')[0]; + string targetFrameworkName = chosenFramework.Name.Split(',')[0]; + + if (sourceFrameworkName.Equals(".NETFramework", StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(".NETCoreApp", StringComparison.OrdinalIgnoreCase) || + sourceFrameworkName.Equals(".NETCoreApp", StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(".NETFramework", StringComparison.OrdinalIgnoreCase)) + { + isSettingIncompatible = true; + } } return isSettingIncompatible; } - /// - /// Returns true if source settings are incompatible with target settings. - /// - private static bool IsSettingIncompatible(Architecture sourcePlatform, - Architecture targetPlatform, - Framework sourceFramework, - Framework targetFramework) + /// + /// Returns true if source settings are incompatible with target settings. + /// + private static bool IsSettingIncompatible(Architecture sourcePlatform, + Architecture targetPlatform, + Framework sourceFramework, + Framework targetFramework) { - return IsPlatformIncompatible(sourcePlatform, targetPlatform) || IsFrameworkIncompatible(sourceFramework, targetFramework); + var res = IsPlatformIncompatible(sourcePlatform, targetPlatform) || IsFrameworkIncompatible(sourceFramework, targetFramework); + return res; } @@ -694,28 +701,20 @@ private static bool IsPlatformIncompatible(Architecture sourcePlatform, Architec /// Returns true if source FrameworkVersion is incompatible with target FrameworkVersion. /// private static bool IsFrameworkIncompatible(Framework sourceFramework, Framework targetFramework) - { - if (sourceFramework.Name.Equals(Framework.DefaultFramework.Name, StringComparison.OrdinalIgnoreCase)) - { - return false; - } - return !sourceFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase); - } - - /// - /// Returns true if source Framework Runtime is incompatible with target Framework. - /// - private static bool IsFrameworkRuntimeIncompatible(Framework sourceFramework, Framework targetFramework) { string sourceFrameworkName = sourceFramework.Name.Split(',')[0]; string targetFrameworkName = targetFramework.Name.Split(',')[0]; - if(sourceFrameworkName.Equals(".NETFramework",StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(".NETCoreApp", StringComparison.OrdinalIgnoreCase) || - sourceFrameworkName.Equals(".NETCoreApp", StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(".NETFramework", StringComparison.OrdinalIgnoreCase)) + bool isFrameworkIncompatible = false; + + if (sourceFrameworkName.Equals(".NETFramework", StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(".NETCoreApp", StringComparison.OrdinalIgnoreCase) || + sourceFrameworkName.Equals(".NETCoreApp", StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(".NETFramework", StringComparison.OrdinalIgnoreCase)) { - return true; + isFrameworkIncompatible = true; } - return false; + + var isFrameworkVersionIncompatible = !sourceFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase); + return isFrameworkIncompatible || isFrameworkVersionIncompatible; } } } diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index 9c8b4a8710..e4aff05f26 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -392,7 +392,7 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List sou } var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(chosenPlatform, chosenFramework, sourcePlatforms, sourceFrameworks, out var incompatibleSettingWarning); - var isSettingIncompatible = InferRunSettingsHelper.TryGetSettingIncompatibility(chosenPlatform, chosenFramework, sourcePlatforms, sourceFrameworks); + var isSettingIncompatible = InferRunSettingsHelper.IsFrameworkIncompatible(chosenFramework, sourceFrameworks); if (!string.IsNullOrEmpty(incompatibleSettingWarning)) { diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs index ef7343f77b..93c4904e62 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs @@ -41,7 +41,7 @@ public void OnWrongFrameworkPassedTestRunShouldNotRun(RunnerInfo runnerInfo) } this.InvokeVsTest(arguments); - this.StdErrorContains("Following DLL(s) do not match framework/platform settings."); + this.StdErrorContains("The following DLL(s) do not match framework"); } } } \ No newline at end of file diff --git a/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs b/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs index 031ffb6026..0f4cfc061c 100644 --- a/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs +++ b/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs @@ -805,7 +805,7 @@ public void DiscoverTestsShouldThrowTestPlatformExceptionIfSourceAndTargetFramew var actualErrorMessage = Assert.ThrowsException(() => this.testRequestManager.DiscoverTests(payload, new Mock().Object, this.protocolConfig)).Message; - Assert.IsTrue(actualErrorMessage.Contains("Following DLL(s) do not match framework/platform settings")); + Assert.IsTrue(actualErrorMessage.Contains("Test Run Aborted.")); } [TestMethod] @@ -938,7 +938,7 @@ public void RunTestsShouldThrowTestPlatformExceptionIfSourceAndTargetFrameworksA this.mockAssemblyMetadataProvider.Setup(a => a.GetFrameWork(It.IsAny())).Returns(new FrameworkName(Constants.DotNetFrameworkCore10)); var actualErrorMessage = Assert.ThrowsException(() => this.testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, this.protocolConfig)).Message; - Assert.IsTrue(actualErrorMessage.Contains("Following DLL(s) do not match framework/platform settings")); + Assert.IsTrue(actualErrorMessage.Contains("Test Run Aborted.")); } [TestMethod] From ce59bb3bd3537f6030f5ca1cd5162da88fa1c417 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Wed, 2 Jan 2019 16:04:54 +0530 Subject: [PATCH 09/19] fix acceptance test --- test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs index 93c4904e62..c9730fe680 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/FrameworkTests.cs @@ -41,7 +41,7 @@ public void OnWrongFrameworkPassedTestRunShouldNotRun(RunnerInfo runnerInfo) } this.InvokeVsTest(arguments); - this.StdErrorContains("The following DLL(s) do not match framework"); + this.StdErrorContains("Test Run Aborted. The following DLL(s) do not match the specified framework"); } } } \ No newline at end of file From 220c95569a7568d7905cb638ab738260729a1fb8 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Mon, 14 Jan 2019 14:14:32 +0530 Subject: [PATCH 10/19] Refactoring InferRunSettingsHelper --- .../InferRunSettingsHelper.cs | 86 ++++++++----------- src/vstest.console/CommandLine/InferHelper.cs | 4 +- .../TestPlatformHelpers/TestRequestManager.cs | 4 +- .../CommandLine/InferHelperTests.cs | 44 +++++----- 4 files changed, 60 insertions(+), 78 deletions(-) diff --git a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs index 368346feaa..c052b40240 100644 --- a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs +++ b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs @@ -49,6 +49,8 @@ public class InferRunSettingsHelper private const string LegacyElementsString = "Elements"; private const string DeploymentAttributesString = "DeploymentAttributes"; private const string ExecutionAttributesString = "ExecutionAttributes"; + private const string DotNetFrameworkString = ".NETFramework"; + private const string DotNetCoreString = ".NETCoreApp"; private static readonly List ExecutionNodesPaths = new List { @"/RunSettings/LegacySettings/Execution/TestTypeSpecific/UnitTestRunConfig/AssemblyResolution", @"/RunSettings/LegacySettings/Execution/Timeouts", @"/RunSettings/LegacySettings/Execution/Hosts" }; /// @@ -608,6 +610,28 @@ public static bool TryGetFrameworkXml(XPathNavigator runSettingsNavigator, out s return XmlUtilities.IsValidNodeXmlValue(frameworkXml, validator); } + /// + /// Returns true if target framework is incompatible with any source framework, that is run needs to be aborted + /// + public static bool IsFrameworkIncompatible(Framework chosenFramework, IDictionary sourceFrameworks) + { + bool isFrameworkIncompatible = false; + foreach (var source in sourceFrameworks.Keys) + { + Framework actualFramework = sourceFrameworks[source]; + string sourceFrameworkName = actualFramework.Name.Split(',')[0]; + string targetFrameworkName = chosenFramework.Name.Split(',')[0]; + + if (sourceFrameworkName.Equals(DotNetFrameworkString, StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(DotNetCoreString, StringComparison.OrdinalIgnoreCase) || + sourceFrameworkName.Equals(DotNetCoreString, StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(DotNetFrameworkString, StringComparison.OrdinalIgnoreCase)) + { + isFrameworkIncompatible = true; + } + } + + return isFrameworkIncompatible; + } + /// /// Returns the sources matching the specified platform and framework settings. /// For incompatible sources, warning is added to incompatibleSettingWarning. @@ -648,73 +672,31 @@ public static IEnumerable FilterCompatibleSources(Architecture chosenPla return compatibleSources; } - /// - /// Returns true if target framework is incompatible with any source framework, that is run needs to be aborted - /// - public static bool IsFrameworkIncompatible(Framework chosenFramework, IDictionary sourceFrameworks) - { - bool isSettingIncompatible = false; - foreach (var source in sourceFrameworks.Keys) - { - Framework actualFramework = sourceFrameworks[source]; - string sourceFrameworkName = actualFramework.Name.Split(',')[0]; - string targetFrameworkName = chosenFramework.Name.Split(',')[0]; - - if (sourceFrameworkName.Equals(".NETFramework", StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(".NETCoreApp", StringComparison.OrdinalIgnoreCase) || - sourceFrameworkName.Equals(".NETCoreApp", StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(".NETFramework", StringComparison.OrdinalIgnoreCase)) - { - isSettingIncompatible = true; - } - } - - return isSettingIncompatible; - } - /// /// Returns true if source settings are incompatible with target settings. + /// Returns true if either source Platform is incompatible with target platform or source FrameworkVersion is incompatible with target FrameworkVersion. /// private static bool IsSettingIncompatible(Architecture sourcePlatform, Architecture targetPlatform, Framework sourceFramework, Framework targetFramework) { - var res = IsPlatformIncompatible(sourcePlatform, targetPlatform) || IsFrameworkIncompatible(sourceFramework, targetFramework); - return res; - } + bool isFrameworkSettingIncompatible = false; + bool isPlatformSettingIncompatible = false; - - /// - /// Returns true if source Platform is incompatible with target platform. - /// - private static bool IsPlatformIncompatible(Architecture sourcePlatform, Architecture targetPlatform) - { if (sourcePlatform == Architecture.Default || - sourcePlatform == Architecture.AnyCPU) + sourcePlatform == Architecture.AnyCPU) { - return false; + isPlatformSettingIncompatible = false; } - - return sourcePlatform != targetPlatform; - } - - /// - /// Returns true if source FrameworkVersion is incompatible with target FrameworkVersion. - /// - private static bool IsFrameworkIncompatible(Framework sourceFramework, Framework targetFramework) - { - string sourceFrameworkName = sourceFramework.Name.Split(',')[0]; - string targetFrameworkName = targetFramework.Name.Split(',')[0]; - - bool isFrameworkIncompatible = false; - - if (sourceFrameworkName.Equals(".NETFramework", StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(".NETCoreApp", StringComparison.OrdinalIgnoreCase) || - sourceFrameworkName.Equals(".NETCoreApp", StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(".NETFramework", StringComparison.OrdinalIgnoreCase)) + else { - isFrameworkIncompatible = true; + isPlatformSettingIncompatible = sourcePlatform != targetPlatform ? true : false; } - var isFrameworkVersionIncompatible = !sourceFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase); - return isFrameworkIncompatible || isFrameworkVersionIncompatible; + isFrameworkSettingIncompatible = !sourceFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase); + + return isPlatformSettingIncompatible || isFrameworkSettingIncompatible; } } } diff --git a/src/vstest.console/CommandLine/InferHelper.cs b/src/vstest.console/CommandLine/InferHelper.cs index 31bff65845..f8ad21b2db 100644 --- a/src/vstest.console/CommandLine/InferHelper.cs +++ b/src/vstest.console/CommandLine/InferHelper.cs @@ -27,7 +27,7 @@ internal InferHelper(IAssemblyMetadataProvider assemblyMetadataProvider) /// /// Determines Architecture from sources and returns true if source architectures are incompatible /// - public bool TryGetCompatibleArchitecture(List sources, IDictionary sourcePlatforms, out Architecture inferredArchitecture) + public bool TryGetAutoDetectCompatibleArchitecture(List sources, IDictionary sourcePlatforms, out Architecture inferredArchitecture) { inferredArchitecture = Constants.DefaultPlatform; bool isArchitectureIncompatible = false; @@ -93,7 +93,7 @@ public bool TryGetCompatibleArchitecture(List sources, IDictionary /// Determines Framework from sources and returns true if source frameworks are incompatible /// - public bool TryGetCompatibleFramework(List sources, IDictionary sourceFrameworkVersions, out Framework inferredFramework) + public bool TryGetAutoDetectCompatibleFramework(List sources, IDictionary sourceFrameworkVersions, out Framework inferredFramework) { inferredFramework = Framework.DefaultFramework; bool isFrameworkIncompatible = false; diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index e4aff05f26..875e592bfa 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -364,9 +364,9 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List sou var navigator = document.CreateNavigator(); - var isFrameworkIncompatible = inferHelper.TryGetCompatibleFramework(sources, sourceFrameworks, out var inferredFramework); + var isFrameworkIncompatible = inferHelper.TryGetAutoDetectCompatibleFramework(sources, sourceFrameworks, out var inferredFramework); Framework chosenFramework; - var isPlatformIncompatible = inferHelper.TryGetCompatibleArchitecture(sources, sourcePlatforms, out var inferredPlatform); + var isPlatformIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(sources, sourcePlatforms, out var inferredPlatform); Architecture chosenPlatform; if (isFrameworkIncompatible || isPlatformIncompatible) diff --git a/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs b/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs index 875cf1ceee..8118123f18 100644 --- a/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs +++ b/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs @@ -38,7 +38,7 @@ public InferHelperTests() [TestMethod] public void TryGetArchitectureShouldReturnDefaultArchitectureOnNullSources() { - bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(null, sourceArchitectures, out var inferredArchitecture); + bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(null, sourceArchitectures, out var inferredArchitecture); Assert.AreEqual(false, isArchitectureIncompatible); Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); @@ -47,7 +47,7 @@ public void TryGetArchitectureShouldReturnDefaultArchitectureOnNullSources() [TestMethod] public void TryGetArchitectureShouldReturnDefaultArchitectureOnEmptySources() { - bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List(0), sourceArchitectures, out var inferredArchitecture); + bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(new List(0), sourceArchitectures, out var inferredArchitecture); Assert.AreEqual(false, isArchitectureIncompatible); Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); @@ -56,7 +56,7 @@ public void TryGetArchitectureShouldReturnDefaultArchitectureOnEmptySources() [TestMethod] public void TryGetArchitectureShouldReturnDefaultArchitectureOnNullItemInSources() { - bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { null }, sourceArchitectures, out var inferredArchitecture); + bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(new List() { null }, sourceArchitectures, out var inferredArchitecture); Assert.AreEqual(false, isArchitectureIncompatible); Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); @@ -65,7 +65,7 @@ public void TryGetArchitectureShouldReturnDefaultArchitectureOnNullItemInSources [TestMethod] public void TryGetArchitectureShouldReturnDefaultArchitectureOnWhiteSpaceItemInSources() { - bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { " " }, sourceArchitectures, out var inferredArchitecture); + bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(new List() { " " }, sourceArchitectures, out var inferredArchitecture); Assert.AreEqual(false, isArchitectureIncompatible); Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); @@ -76,7 +76,7 @@ public void TryGetArchitectureShouldReturnCorrectArchForOneSource() { this.mockAssemblyHelper.Setup(ah => ah.GetArchitecture(It.IsAny())).Returns(Architecture.X86); - bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { "1.dll" }, sourceArchitectures, out var inferredArchitecture); + bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(new List() { "1.dll" }, sourceArchitectures, out var inferredArchitecture); Assert.AreEqual(false, isArchitectureIncompatible); Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); @@ -86,7 +86,7 @@ public void TryGetArchitectureShouldReturnCorrectArchForOneSource() [TestMethod] public void TryGetArchitectureShouldReturnCorrectDefaultArchForNotDotNetAssembly() { - bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { "NotDotNetAssebly.appx" }, sourceArchitectures, out var inferredArchitecture); + bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(new List() { "NotDotNetAssebly.appx" }, sourceArchitectures, out var inferredArchitecture); Assert.AreEqual(false, isArchitectureIncompatible); Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); @@ -96,7 +96,7 @@ public void TryGetArchitectureShouldReturnCorrectDefaultArchForNotDotNetAssembly [TestMethod] public void TryGetArchitectureShouldSetAnyCpuArchForNotDotNetAssembly() { - bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { "NotDotNetAssebly.appx" }, sourceArchitectures, out var inferredArchitecture); + bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(new List() { "NotDotNetAssebly.appx" }, sourceArchitectures, out var inferredArchitecture); Assert.AreEqual(false, isArchitectureIncompatible); Assert.AreEqual(Architecture.AnyCPU, sourceArchitectures["NotDotNetAssebly.appx"]); @@ -108,7 +108,7 @@ public void TryArchitectureShouldReturnDefaultArchForAllAnyCpuAssemblies() this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU); - bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { "AnyCPU1.dll", "AnyCPU2.exe", "AnyCPU3.dll" }, sourceArchitectures, out var inferredArchitecture); + bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(new List() { "AnyCPU1.dll", "AnyCPU2.exe", "AnyCPU3.dll" }, sourceArchitectures, out var inferredArchitecture); Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); Assert.AreEqual(false, isArchitectureIncompatible); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); @@ -119,7 +119,7 @@ public void TryGetArchitectureShouldReturnX86ArchIfOneX86AssemblyAndRestAnyCPU() { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.X86); - bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { "AnyCPU1.dll", "AnyCPU2.exe", "x86.dll" }, sourceArchitectures, out var inferredArchitecture); + bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(new List() { "AnyCPU1.dll", "AnyCPU2.exe", "x86.dll" }, sourceArchitectures, out var inferredArchitecture); Assert.AreEqual(false, isArchitectureIncompatible); Assert.AreEqual(Architecture.X86, inferredArchitecture); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); @@ -131,7 +131,7 @@ public void TryGetArchitectureShouldReturnARMArchIfOneARMAssemblyAndRestAnyCPU() this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.ARM).Returns(Architecture.ARM).Returns(Architecture.ARM); - bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { "ARM1.dll", "ARM2.dll", "ARM3.dll" }, sourceArchitectures, out var inferredArchitecture); + bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(new List() { "ARM1.dll", "ARM2.dll", "ARM3.dll" }, sourceArchitectures, out var inferredArchitecture); Assert.AreEqual(false, isArchitectureIncompatible); Assert.AreEqual(Architecture.ARM, inferredArchitecture); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); @@ -143,7 +143,7 @@ public void TryGetArchitectureShouldReturnX64ArchIfOneX64AssemblyAndRestAnyCPU() this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.X64); - bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { "x64.dll", "AnyCPU2.exe", "x64.dll" }, sourceArchitectures, out var inferredArchitecture); + bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(new List() { "x64.dll", "AnyCPU2.exe", "x64.dll" }, sourceArchitectures, out var inferredArchitecture); Assert.AreEqual(false, isArchitectureIncompatible); Assert.AreEqual(Architecture.X64, inferredArchitecture); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); @@ -155,7 +155,7 @@ public void TryGetArchitectureShouldReturnDefaultArchOnConflictArches() this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.X64).Returns(Architecture.X86); - bool isArchitectureIncompatible = inferHelper.TryGetCompatibleArchitecture(new List() { "AnyCPU1.dll", "x64.exe", "x86.dll" }, sourceArchitectures, out var inferredArchitecture); + bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(new List() { "AnyCPU1.dll", "x64.exe", "x86.dll" }, sourceArchitectures, out var inferredArchitecture); Assert.AreEqual(true, isArchitectureIncompatible); Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(3)); @@ -167,7 +167,7 @@ public void TryGetArchitectureShouldPoulateSourceArchitectureDictionary() this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.X64).Returns(Architecture.X86); - inferHelper.TryGetCompatibleArchitecture(new List() { "AnyCPU1.dll", "x64.exe", "x86.dll" }, sourceArchitectures, out var inferredArchitecture); + inferHelper.TryGetAutoDetectCompatibleArchitecture(new List() { "AnyCPU1.dll", "x64.exe", "x86.dll" }, sourceArchitectures, out var inferredArchitecture); Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); Assert.AreEqual(3, sourceArchitectures.Count); Assert.AreEqual(Architecture.AnyCPU, sourceArchitectures["AnyCPU1.dll"]); @@ -183,7 +183,7 @@ public void TryGetArchitectureShouldReturnDefaultArchIfthereIsNotDotNetAssemblyI this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU); - inferHelper.TryGetCompatibleArchitecture(new List() { "AnyCPU1.dll", "NotDotNetAssebly.appx" }, sourceArchitectures, out var inferredArchitecture); + inferHelper.TryGetAutoDetectCompatibleArchitecture(new List() { "AnyCPU1.dll", "NotDotNetAssebly.appx" }, sourceArchitectures, out var inferredArchitecture); Assert.AreEqual(Constants.DefaultPlatform, inferredArchitecture); this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny()), Times.Exactly(1)); } @@ -191,28 +191,28 @@ public void TryGetArchitectureShouldReturnDefaultArchIfthereIsNotDotNetAssemblyI [TestMethod] public void TryGetFrameworkShouldReturnDefaultFrameworkOnNullSources() { - inferHelper.TryGetCompatibleFramework(null, sourceFrameworks, out var inferredFramework); + inferHelper.TryGetAutoDetectCompatibleFramework(null, sourceFrameworks, out var inferredFramework); Assert.AreEqual(defaultFramework, inferredFramework); } [TestMethod] public void TryGetFrameworkShouldReturnDefaultFrameworkOnEmptySources() { - inferHelper.TryGetCompatibleFramework(new List(0), sourceFrameworks, out var inferredFramework); + inferHelper.TryGetAutoDetectCompatibleFramework(new List(0), sourceFrameworks, out var inferredFramework); Assert.AreEqual(defaultFramework, inferredFramework); } [TestMethod] public void TryGetFrameworkShouldReturnDefaultFrameworkOnNullItemInSources() { - inferHelper.TryGetCompatibleFramework(new List() { null }, sourceFrameworks, out var inferredFramework); + inferHelper.TryGetAutoDetectCompatibleFramework(new List() { null }, sourceFrameworks, out var inferredFramework); Assert.AreEqual(defaultFramework, inferredFramework); } [TestMethod] public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnEmptyItemInSources() { - inferHelper.TryGetCompatibleFramework(new List() { string.Empty }, sourceFrameworks, out var inferredFramework); + inferHelper.TryGetAutoDetectCompatibleFramework(new List() { string.Empty }, sourceFrameworks, out var inferredFramework); Assert.AreEqual(defaultFramework.Name, inferredFramework.Name); } @@ -264,7 +264,7 @@ public void TryGetFrameworkShouldReturnHighestVersionFxOnSameFxName() .Returns(new FrameworkName(frameworkNet47.Name)) .Returns(new FrameworkName(frameworkNet45.Name)); - inferHelper.TryGetCompatibleFramework(new List() { "net46.dll", "net47.exe", "net45.dll" }, sourceFrameworks, out var inferredFramework); + inferHelper.TryGetAutoDetectCompatibleFramework(new List() { "net46.dll", "net47.exe", "net45.dll" }, sourceFrameworks, out var inferredFramework); Assert.AreEqual(frameworkNet47.Name, inferredFramework.Name); this.mockAssemblyHelper.Verify(ah => ah.GetFrameWork(It.IsAny()),Times.Exactly(3)); } @@ -277,7 +277,7 @@ public void TryGetFrameworkShouldPopulatetheDictionaryForAllTheSources() .Returns(new FrameworkName(frameworkNet47.Name)) .Returns(new FrameworkName(frameworkNet45.Name)); - inferHelper.TryGetCompatibleFramework(new List() { "net46.dll", "net47.exe", "net45.dll" }, sourceFrameworks, out var inferredFramework); + inferHelper.TryGetAutoDetectCompatibleFramework(new List() { "net46.dll", "net47.exe", "net45.dll" }, sourceFrameworks, out var inferredFramework); Assert.AreEqual(frameworkNet47.Name, inferredFramework.Name); Assert.AreEqual(3, sourceFrameworks.Count); @@ -294,7 +294,7 @@ public void TryGetFrameworkShouldReturnHighestVersionFxOnEvenManyLowerVersionFxN .Returns(new FrameworkName(frameworkCore10.Name)) .Returns(new FrameworkName(frameworkCore11.Name)) .Returns(new FrameworkName(frameworkCore10.Name)); - inferHelper.TryGetCompatibleFramework(new List() { "netcore10_1.dll", "netcore11.dll", "netcore10_2.dll" }, sourceFrameworks, out var inferredFramework); + inferHelper.TryGetAutoDetectCompatibleFramework(new List() { "netcore10_1.dll", "netcore11.dll", "netcore10_2.dll" }, sourceFrameworks, out var inferredFramework); Assert.AreEqual(frameworkCore11.Name, inferredFramework.Name); this.mockAssemblyHelper.Verify(ah => ah.GetFrameWork(It.IsAny()), Times.Exactly(3)); } @@ -303,7 +303,7 @@ private void SetupAndValidateForSingleAssembly(string assemblyName, Framework fx { this.mockAssemblyHelper.Setup(sh => sh.GetFrameWork(assemblyName)) .Returns(new FrameworkName(fx.Name)); - inferHelper.TryGetCompatibleFramework(new List() { assemblyName }, sourceFrameworks, out var inferredFramework); + inferHelper.TryGetAutoDetectCompatibleFramework(new List() { assemblyName }, sourceFrameworks, out var inferredFramework); Assert.AreEqual(fx.Name, inferredFramework.Name); if (verify) { From c9740ea7dda9565df6e448a9bd523895f8d908cf Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Mon, 14 Jan 2019 18:47:07 +0530 Subject: [PATCH 11/19] Refactor --- .../Resources/CommonResources.Designer.cs | 4 +- .../InferRunSettingsHelper.cs | 62 ++++++++++++------- src/vstest.console/CommandLine/InferHelper.cs | 13 ++++ .../TestPlatformHelpers/TestRequestManager.cs | 25 +++++--- 4 files changed, 70 insertions(+), 34 deletions(-) diff --git a/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.Designer.cs b/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.Designer.cs index de5b2db5a4..8953794fc9 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.Designer.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Resources/CommonResources.Designer.cs @@ -69,9 +69,9 @@ public static string CannotBeNullOrEmpty { return ResourceManager.GetString("CannotBeNullOrEmpty", resourceCulture); } } - + /// - /// Looks up a localized string similar to Test run will use DLL(s) built for framework {0} and platform {1}. Following DLL(s) will not be part of run: {2} Go to {3} for more details on managing these settings.. + /// Looks up a localized string similar to The following DLL(s) do not match the specified framework {0} and platform {1} settings.{2}Ensure that the test assemblies target the specified framework/platform settings. Go to {3} for more details on managing these settings.. /// public static string DisplayChosenSettings { get { diff --git a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs index c052b40240..bc99ed2426 100644 --- a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs +++ b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs @@ -613,23 +613,17 @@ public static bool TryGetFrameworkXml(XPathNavigator runSettingsNavigator, out s /// /// Returns true if target framework is incompatible with any source framework, that is run needs to be aborted /// - public static bool IsFrameworkIncompatible(Framework chosenFramework, IDictionary sourceFrameworks) + public static bool IsFrameworkIncompatible(Framework chosenFramework, HashSet sourceFrameworks) { - bool isFrameworkIncompatible = false; - foreach (var source in sourceFrameworks.Keys) + foreach (var actualFramework in sourceFrameworks) { - Framework actualFramework = sourceFrameworks[source]; - string sourceFrameworkName = actualFramework.Name.Split(',')[0]; - string targetFrameworkName = chosenFramework.Name.Split(',')[0]; - - if (sourceFrameworkName.Equals(DotNetFrameworkString, StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(DotNetCoreString, StringComparison.OrdinalIgnoreCase) || - sourceFrameworkName.Equals(DotNetCoreString, StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(DotNetFrameworkString, StringComparison.OrdinalIgnoreCase)) + if (IsFrameworkIncompatible(actualFramework, chosenFramework, false)) { - isFrameworkIncompatible = true; + return true; } } - return isFrameworkIncompatible; + return false; } /// @@ -673,30 +667,50 @@ public static IEnumerable FilterCompatibleSources(Architecture chosenPla } /// - /// Returns true if source settings are incompatible with target settings. - /// Returns true if either source Platform is incompatible with target platform or source FrameworkVersion is incompatible with target FrameworkVersion. + /// Returns true if source settings are incomaptible with target settings. /// private static bool IsSettingIncompatible(Architecture sourcePlatform, - Architecture targetPlatform, - Framework sourceFramework, - Framework targetFramework) + Architecture targetPlatform, + Framework sourceFramework, + Framework targetFramework) { - bool isFrameworkSettingIncompatible = false; - bool isPlatformSettingIncompatible = false; + return IsPlatformIncompatible(sourcePlatform, targetPlatform) || IsFrameworkIncompatible(sourceFramework, targetFramework, true); + } + + /// + /// Returns true if source Platform is incompatible with target platform. + /// + private static bool IsPlatformIncompatible(Architecture sourcePlatform, Architecture targetPlatform) + { if (sourcePlatform == Architecture.Default || - sourcePlatform == Architecture.AnyCPU) + sourcePlatform == Architecture.AnyCPU) { - isPlatformSettingIncompatible = false; + return false; } - else + + return sourcePlatform != targetPlatform; + } + + /// + /// Returns true if source Framework or version is incompatible with target Framework or version. + /// + public static bool IsFrameworkIncompatible(Framework sourceFramework, Framework targetFramework, bool versionCheckRequired) + { + if (versionCheckRequired) { - isPlatformSettingIncompatible = sourcePlatform != targetPlatform ? true : false; + return !sourceFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase); } - isFrameworkSettingIncompatible = !sourceFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase); + string sourceFrameworkName = sourceFramework.Name.Split(',')[0]; + string targetFrameworkName = targetFramework.Name.Split(',')[0]; - return isPlatformSettingIncompatible || isFrameworkSettingIncompatible; + if (sourceFrameworkName.Equals(DotNetFrameworkString, StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(DotNetCoreString, StringComparison.OrdinalIgnoreCase) || + sourceFrameworkName.Equals(DotNetCoreString, StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(DotNetFrameworkString, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + return false; } } } diff --git a/src/vstest.console/CommandLine/InferHelper.cs b/src/vstest.console/CommandLine/InferHelper.cs index f8ad21b2db..cbcba2eeaf 100644 --- a/src/vstest.console/CommandLine/InferHelper.cs +++ b/src/vstest.console/CommandLine/InferHelper.cs @@ -24,6 +24,19 @@ internal InferHelper(IAssemblyMetadataProvider assemblyMetadataProvider) this.assemblyMetadataProvider = assemblyMetadataProvider; } + /// + /// Gets list of frameworks from sources + /// + public HashSet GetFrameworksList(IDictionary sourceFrameworks) + { + var frameworkList = new HashSet(); + foreach (var source in sourceFrameworks.Keys) + { + frameworkList.Add(sourceFrameworks[source]); + } + return frameworkList; + } + /// /// Determines Architecture from sources and returns true if source architectures are incompatible /// diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index 875e592bfa..c298702ccd 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -364,19 +364,23 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List sou var navigator = document.CreateNavigator(); + // Automatically detect frameworks and platforms from sources and return true if any incompatibility var isFrameworkIncompatible = inferHelper.TryGetAutoDetectCompatibleFramework(sources, sourceFrameworks, out var inferredFramework); - Framework chosenFramework; var isPlatformIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(sources, sourcePlatforms, out var inferredPlatform); - Architecture chosenPlatform; - + + // Throw exception if conflicts found in framework/platform if (isFrameworkIncompatible || isPlatformIncompatible) { throw new TestPlatformException(Resources.ConflictInFrameworkPlatform); } + // Update framework and platform if required. For commandline scenario update happens in ArgumentProcessor. - bool updateFramework = IsAutoFrameworkDetectRequired(navigator, out chosenFramework); - bool updatePlatform = IsAutoPlatformDetectRequired(navigator, out chosenPlatform); + Framework chosenFramework; + bool updateFramework = IsAutoFrameworkUpdateRequired(navigator, out chosenFramework); + Architecture chosenPlatform; + bool updatePlatform = IsAutoPlatformUpdateRequired(navigator, out chosenPlatform); + // Update framework and platform if (updateFramework) { InferRunSettingsHelper.UpdateTargetFramework(document, inferredFramework?.ToString(), overwrite: true); @@ -391,8 +395,12 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List sou settingsUpdated = true; } + // Get compatible sources and construct warning messages if any incompatibilty found var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(chosenPlatform, chosenFramework, sourcePlatforms, sourceFrameworks, out var incompatibleSettingWarning); - var isSettingIncompatible = InferRunSettingsHelper.IsFrameworkIncompatible(chosenFramework, sourceFrameworks); + + // isSettingIncompatible wil be true if run needs to be aborted due to incompatibility in source and target frameworks + var frameworkList = inferHelper.GetFrameworksList(sourceFrameworks); + var isSettingIncompatible = InferRunSettingsHelper.IsFrameworkIncompatible(chosenFramework, frameworkList); if (!string.IsNullOrEmpty(incompatibleSettingWarning)) { @@ -401,6 +409,7 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List sou { throw new TestPlatformException(string.Format(CultureInfo.CurrentCulture, Resources.TestRunAborted, incompatibleSettingWarning)); } + // If run need not be aborted, raise warning messages ConsoleLogger.RaiseTestRunWarning(incompatibleSettingWarning); } @@ -567,7 +576,7 @@ private void RunTests(IRequestData requestData, TestRunCriteria testRunCriteria, } } - private bool IsAutoFrameworkDetectRequired(XPathNavigator navigator, out Framework chosenFramework) + private bool IsAutoFrameworkUpdateRequired(XPathNavigator navigator, out Framework chosenFramework) { bool required = true; chosenFramework = null; @@ -590,7 +599,7 @@ private bool IsAutoFrameworkDetectRequired(XPathNavigator navigator, out Framewo return required; } - private bool IsAutoPlatformDetectRequired(XPathNavigator navigator, out Architecture chosenPlatform) + private bool IsAutoPlatformUpdateRequired(XPathNavigator navigator, out Architecture chosenPlatform) { bool required = true; chosenPlatform = Architecture.Default; From 2e66caa53d7a3e9aaa3452063c85ace2a30beed5 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Mon, 14 Jan 2019 19:02:07 +0530 Subject: [PATCH 12/19] Tests updated --- .../CommandLine/InferHelperTests.cs | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs b/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs index 8118123f18..26898a3629 100644 --- a/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs +++ b/test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs @@ -36,7 +36,7 @@ public InferHelperTests() } [TestMethod] - public void TryGetArchitectureShouldReturnDefaultArchitectureOnNullSources() + public void TryGetAutoDetectCompatibleArchitectureShouldReturnDefaultArchitectureOnNullSources() { bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(null, sourceArchitectures, out var inferredArchitecture); @@ -45,7 +45,7 @@ public void TryGetArchitectureShouldReturnDefaultArchitectureOnNullSources() } [TestMethod] - public void TryGetArchitectureShouldReturnDefaultArchitectureOnEmptySources() + public void TryGeAutoDetectCompatibleArchitectureShouldReturnDefaultArchitectureOnEmptySources() { bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(new List(0), sourceArchitectures, out var inferredArchitecture); @@ -54,7 +54,7 @@ public void TryGetArchitectureShouldReturnDefaultArchitectureOnEmptySources() } [TestMethod] - public void TryGetArchitectureShouldReturnDefaultArchitectureOnNullItemInSources() + public void TryGetAutoDetectCompatibleArchitectureShouldReturnDefaultArchitectureOnNullItemInSources() { bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(new List() { null }, sourceArchitectures, out var inferredArchitecture); @@ -63,7 +63,7 @@ public void TryGetArchitectureShouldReturnDefaultArchitectureOnNullItemInSources } [TestMethod] - public void TryGetArchitectureShouldReturnDefaultArchitectureOnWhiteSpaceItemInSources() + public void TryGetAutoDetectCompatibleArchitectureShouldReturnDefaultArchitectureOnWhiteSpaceItemInSources() { bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(new List() { " " }, sourceArchitectures, out var inferredArchitecture); @@ -72,7 +72,7 @@ public void TryGetArchitectureShouldReturnDefaultArchitectureOnWhiteSpaceItemInS } [TestMethod] - public void TryGetArchitectureShouldReturnCorrectArchForOneSource() + public void TryGetAutoDetectCompatibleArchitectureShouldReturnCorrectArchForOneSource() { this.mockAssemblyHelper.Setup(ah => ah.GetArchitecture(It.IsAny())).Returns(Architecture.X86); @@ -84,7 +84,7 @@ public void TryGetArchitectureShouldReturnCorrectArchForOneSource() } [TestMethod] - public void TryGetArchitectureShouldReturnCorrectDefaultArchForNotDotNetAssembly() + public void TryGetAutoDetectCompatibleArchitectureShouldReturnCorrectDefaultArchForNotDotNetAssembly() { bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(new List() { "NotDotNetAssebly.appx" }, sourceArchitectures, out var inferredArchitecture); @@ -94,7 +94,7 @@ public void TryGetArchitectureShouldReturnCorrectDefaultArchForNotDotNetAssembly } [TestMethod] - public void TryGetArchitectureShouldSetAnyCpuArchForNotDotNetAssembly() + public void TryGetAutoDetectCompatibleArchitectureShouldSetAnyCpuArchForNotDotNetAssembly() { bool isArchitectureIncompatible = inferHelper.TryGetAutoDetectCompatibleArchitecture(new List() { "NotDotNetAssebly.appx" }, sourceArchitectures, out var inferredArchitecture); @@ -103,7 +103,7 @@ public void TryGetArchitectureShouldSetAnyCpuArchForNotDotNetAssembly() } [TestMethod] - public void TryArchitectureShouldReturnDefaultArchForAllAnyCpuAssemblies() + public void TryGetAutoDetectCompatibleArchitectureShouldReturnDefaultArchForAllAnyCpuAssemblies() { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU); @@ -115,7 +115,7 @@ public void TryArchitectureShouldReturnDefaultArchForAllAnyCpuAssemblies() } [TestMethod] - public void TryGetArchitectureShouldReturnX86ArchIfOneX86AssemblyAndRestAnyCPU() + public void TryGetAutoDetectCompatibleArchitectureShouldReturnX86ArchIfOneX86AssemblyAndRestAnyCPU() { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.X86); @@ -126,7 +126,7 @@ public void TryGetArchitectureShouldReturnX86ArchIfOneX86AssemblyAndRestAnyCPU() } [TestMethod] - public void TryGetArchitectureShouldReturnARMArchIfOneARMAssemblyAndRestAnyCPU() + public void TryGetAutoDetectCompatibleArchitectureShouldReturnARMArchIfOneARMAssemblyAndRestAnyCPU() { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.ARM).Returns(Architecture.ARM).Returns(Architecture.ARM); @@ -138,7 +138,7 @@ public void TryGetArchitectureShouldReturnARMArchIfOneARMAssemblyAndRestAnyCPU() } [TestMethod] - public void TryGetArchitectureShouldReturnX64ArchIfOneX64AssemblyAndRestAnyCPU() + public void TryGetAutoDetectCompatibleArchitectureShouldReturnX64ArchIfOneX64AssemblyAndRestAnyCPU() { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.AnyCPU).Returns(Architecture.X64); @@ -150,7 +150,7 @@ public void TryGetArchitectureShouldReturnX64ArchIfOneX64AssemblyAndRestAnyCPU() } [TestMethod] - public void TryGetArchitectureShouldReturnDefaultArchOnConflictArches() + public void TryGetAutoDetectCompatibleArchitectureShouldReturnDefaultArchOnConflictArches() { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.X64).Returns(Architecture.X86); @@ -162,7 +162,7 @@ public void TryGetArchitectureShouldReturnDefaultArchOnConflictArches() } [TestMethod] - public void TryGetArchitectureShouldPoulateSourceArchitectureDictionary() + public void TryGetAutoDetectCompatibleArchitectureShouldPopulateSourceArchitectureDictionary() { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU).Returns(Architecture.X64).Returns(Architecture.X86); @@ -178,7 +178,7 @@ public void TryGetArchitectureShouldPoulateSourceArchitectureDictionary() } [TestMethod] - public void TryGetArchitectureShouldReturnDefaultArchIfthereIsNotDotNetAssemblyInSources() + public void TryGetAutoDetectCompatibleArchitectureShouldReturnDefaultArchIfthereIsNotDotNetAssemblyInSources() { this.mockAssemblyHelper.SetupSequence(ah => ah.GetArchitecture(It.IsAny())) .Returns(Architecture.AnyCPU); @@ -189,35 +189,35 @@ public void TryGetArchitectureShouldReturnDefaultArchIfthereIsNotDotNetAssemblyI } [TestMethod] - public void TryGetFrameworkShouldReturnDefaultFrameworkOnNullSources() + public void TryGetAutoDetectCompatibleFrameworkShouldReturnDefaultFrameworkOnNullSources() { inferHelper.TryGetAutoDetectCompatibleFramework(null, sourceFrameworks, out var inferredFramework); Assert.AreEqual(defaultFramework, inferredFramework); } [TestMethod] - public void TryGetFrameworkShouldReturnDefaultFrameworkOnEmptySources() + public void TryGetAutoDetectCompatibleFrameworkShouldReturnDefaultFrameworkOnEmptySources() { inferHelper.TryGetAutoDetectCompatibleFramework(new List(0), sourceFrameworks, out var inferredFramework); Assert.AreEqual(defaultFramework, inferredFramework); } [TestMethod] - public void TryGetFrameworkShouldReturnDefaultFrameworkOnNullItemInSources() + public void TryGetAutoDetectCompatibleFrameworkShouldReturnDefaultFrameworkOnNullItemInSources() { inferHelper.TryGetAutoDetectCompatibleFramework(new List() { null }, sourceFrameworks, out var inferredFramework); Assert.AreEqual(defaultFramework, inferredFramework); } [TestMethod] - public void AutoDetectFrameworkShouldReturnDefaultFrameworkOnEmptyItemInSources() + public void TryGetAutoDetectCompatibleFrameworkShouldReturnDefaultFrameworkOnEmptyItemInSources() { inferHelper.TryGetAutoDetectCompatibleFramework(new List() { string.Empty }, sourceFrameworks, out var inferredFramework); Assert.AreEqual(defaultFramework.Name, inferredFramework.Name); } [TestMethod] - public void TryGetFrameworkShouldReturnFrameworkCore10OnCore10Sources() + public void TryGetAutoDetectCompatibleFrameworkShouldReturnFrameworkCore10OnCore10Sources() { var fx = frameworkCore10; var assemblyName = "netcoreapp.dll"; @@ -225,7 +225,7 @@ public void TryGetFrameworkShouldReturnFrameworkCore10OnCore10Sources() } [TestMethod] - public void TryGetFrameworkShouldReturnFramework46On46Sources() + public void TryGetAutoDetectCompatibleFrameworkShouldReturnFramework46On46Sources() { var fx = frameworkNet46; var assemblyName = "net46.dll"; @@ -233,7 +233,7 @@ public void TryGetFrameworkShouldReturnFramework46On46Sources() } [TestMethod] - public void TryGetFrameworkShouldReturnFrameworkUap10ForAppxFiles() + public void TryGetAutoDetectCompatibleFrameworkShouldReturnFrameworkUap10ForAppxFiles() { var fx = Framework.FromString(Constants.DotNetFrameworkUap10); var assemblyName = "uwp10.appx"; @@ -241,7 +241,7 @@ public void TryGetFrameworkShouldReturnFrameworkUap10ForAppxFiles() } [TestMethod] - public void TryGetFrameworkShouldReturnFrameworkUap10ForAppxrecipeFiles() + public void TryGetAutoDetectCompatibleFrameworkShouldReturnFrameworkUap10ForAppxrecipeFiles() { var fx = Framework.FromString(Constants.DotNetFrameworkUap10); var assemblyName = "uwp10.appxrecipe"; @@ -249,7 +249,7 @@ public void TryGetFrameworkShouldReturnFrameworkUap10ForAppxrecipeFiles() } [TestMethod] - public void TryGetFrameworkShouldReturnDefaultFullFrameworkForJsFiles() + public void TryGetAutoDetectCompatibleFrameworkShouldReturnDefaultFullFrameworkForJsFiles() { var fx = Framework.FromString(Constants.DotNetFramework40); var assemblyName = "vstests.js"; @@ -257,7 +257,7 @@ public void TryGetFrameworkShouldReturnDefaultFullFrameworkForJsFiles() } [TestMethod] - public void TryGetFrameworkShouldReturnHighestVersionFxOnSameFxName() + public void TryGetAutoDetectCompatibleFrameworkShouldReturnHighestVersionFxOnSameFxName() { this.mockAssemblyHelper.SetupSequence(sh => sh.GetFrameWork(It.IsAny())) .Returns(new FrameworkName(frameworkNet46.Name)) @@ -270,7 +270,7 @@ public void TryGetFrameworkShouldReturnHighestVersionFxOnSameFxName() } [TestMethod] - public void TryGetFrameworkShouldPopulatetheDictionaryForAllTheSources() + public void TryGetAutoDetectCompatibleFrameworkShouldPopulatetheDictionaryForAllTheSources() { this.mockAssemblyHelper.SetupSequence(sh => sh.GetFrameWork(It.IsAny())) .Returns(new FrameworkName(frameworkNet46.Name)) @@ -288,7 +288,7 @@ public void TryGetFrameworkShouldPopulatetheDictionaryForAllTheSources() } [TestMethod] - public void TryGetFrameworkShouldReturnHighestVersionFxOnEvenManyLowerVersionFxNameExists() + public void TryGetAutoDetectCompatibleFrameworkShouldReturnHighestVersionFxOnEvenManyLowerVersionFxNameExists() { this.mockAssemblyHelper.SetupSequence(sh => sh.GetFrameWork(It.IsAny())) .Returns(new FrameworkName(frameworkCore10.Name)) From 10bc3f377202c61597ae49d9d2dcf19dd9c24be0 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Wed, 16 Jan 2019 09:45:56 +0530 Subject: [PATCH 13/19] Update TestRequestManager.cs --- src/vstest.console/TestPlatformHelpers/TestRequestManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index c298702ccd..21f1f02e22 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -409,7 +409,7 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List sou { throw new TestPlatformException(string.Format(CultureInfo.CurrentCulture, Resources.TestRunAborted, incompatibleSettingWarning)); } - // If run need not be aborted, raise warning messages + // If run does not need to be aborted, raise warning messages ConsoleLogger.RaiseTestRunWarning(incompatibleSettingWarning); } From ed39fbd6aa8e691ceefbf911055f8bdffaaa14a7 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Wed, 16 Jan 2019 18:44:49 +0530 Subject: [PATCH 14/19] Restructured and Added test --- .../InferRunSettingsHelper.cs | 43 +++++++------------ .../TestPlatformHelpers/TestRequestManager.cs | 2 +- .../InferRunSettingsHelperTests.cs | 30 +++++++++++++ 3 files changed, 47 insertions(+), 28 deletions(-) diff --git a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs index bc99ed2426..49d425878c 100644 --- a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs +++ b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs @@ -610,22 +610,7 @@ public static bool TryGetFrameworkXml(XPathNavigator runSettingsNavigator, out s return XmlUtilities.IsValidNodeXmlValue(frameworkXml, validator); } - /// - /// Returns true if target framework is incompatible with any source framework, that is run needs to be aborted - /// - public static bool IsFrameworkIncompatible(Framework chosenFramework, HashSet sourceFrameworks) - { - foreach (var actualFramework in sourceFrameworks) - { - if (IsFrameworkIncompatible(actualFramework, chosenFramework, false)) - { - return true; - } - } - - return false; - } - + /// /// Returns the sources matching the specified platform and framework settings. /// For incompatible sources, warning is added to incompatibleSettingWarning. @@ -674,7 +659,7 @@ private static bool IsSettingIncompatible(Architecture sourcePlatform, Framework sourceFramework, Framework targetFramework) { - return IsPlatformIncompatible(sourcePlatform, targetPlatform) || IsFrameworkIncompatible(sourceFramework, targetFramework, true); + return IsPlatformIncompatible(sourcePlatform, targetPlatform) || IsFrameworkIncompatible(new HashSet() { sourceFramework }, targetFramework); } @@ -695,21 +680,25 @@ private static bool IsPlatformIncompatible(Architecture sourcePlatform, Architec /// /// Returns true if source Framework or version is incompatible with target Framework or version. /// - public static bool IsFrameworkIncompatible(Framework sourceFramework, Framework targetFramework, bool versionCheckRequired) + public static bool IsFrameworkIncompatible(HashSet sourceFrameworks, Framework targetFramework, bool versionCheckRequired = true) { - if (versionCheckRequired) + foreach (var actualFramework in sourceFrameworks) { - return !sourceFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase); - } + if (versionCheckRequired) + { + return !actualFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase); + } - string sourceFrameworkName = sourceFramework.Name.Split(',')[0]; - string targetFrameworkName = targetFramework.Name.Split(',')[0]; + string sourceFrameworkName = actualFramework.Name.Split(',')[0]; + string targetFrameworkName = targetFramework.Name.Split(',')[0]; - if (sourceFrameworkName.Equals(DotNetFrameworkString, StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(DotNetCoreString, StringComparison.OrdinalIgnoreCase) || - sourceFrameworkName.Equals(DotNetCoreString, StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(DotNetFrameworkString, StringComparison.OrdinalIgnoreCase)) - { - return true; + if (sourceFrameworkName.Equals(DotNetFrameworkString, StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(DotNetCoreString, StringComparison.OrdinalIgnoreCase) || + sourceFrameworkName.Equals(DotNetCoreString, StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(DotNetFrameworkString, StringComparison.OrdinalIgnoreCase)) + { + return true; + } } + return false; } } diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index c298702ccd..a5a1e55cd3 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -400,7 +400,7 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List sou // isSettingIncompatible wil be true if run needs to be aborted due to incompatibility in source and target frameworks var frameworkList = inferHelper.GetFrameworksList(sourceFrameworks); - var isSettingIncompatible = InferRunSettingsHelper.IsFrameworkIncompatible(chosenFramework, frameworkList); + var isSettingIncompatible = InferRunSettingsHelper.IsFrameworkIncompatible(frameworkList, chosenFramework, false); if (!string.IsNullOrEmpty(incompatibleSettingWarning)) { diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs index 288685f5b2..3bdba3b1a2 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs @@ -468,6 +468,36 @@ public void FilterCompatibleSourcesShouldRetrunWarningMessageIfNoConflict() Assert.IsTrue(string.IsNullOrEmpty(warningMessage)); } + [TestMethod] + public void IsFrameworkIncompatibleShouldReturnTrueIfNoVersionCheckAndFrameworksIncompatible() + { + HashSet sourceFrameworks = new HashSet() { frameworkNet45, frameworkNet47 }; + Framework targetFramework = Framework.FromString(".NETCoreApp,Version=1.0"); + + bool isFrameworkIncompatible = InferRunSettingsHelper.IsFrameworkIncompatible(sourceFrameworks, targetFramework, false); + Assert.IsTrue(isFrameworkIncompatible); + } + + [TestMethod] + public void IsFrameworkIncompatibleShouldReturnFalseIfNoVersionCheckAndFrameworksHaveDifferentVersions() + { + HashSet sourceFrameworks = new HashSet() { frameworkNet45, frameworkNet47 }; + Framework targetFramework = frameworkNet46; + + bool isFrameworkIncompatible = InferRunSettingsHelper.IsFrameworkIncompatible(sourceFrameworks, targetFramework, false); + Assert.IsFalse(isFrameworkIncompatible); + } + + [TestMethod] + public void IsFrameworkIncompatibleShouldReturnTrueIfVersionCheckAndFrameworksHaveDifferentVersions() + { + HashSet sourceFrameworks = new HashSet() { frameworkNet45, frameworkNet47 }; + Framework targetFramework = frameworkNet46; + + bool isFrameworkIncompatible = InferRunSettingsHelper.IsFrameworkIncompatible(sourceFrameworks, targetFramework, true); + Assert.IsTrue(isFrameworkIncompatible); + } + [TestMethod] public void IsTestSettingsEnabledShouldReturnTrueIfRunsettingsHasTestSettings() { From bc8c1200ef78527d098375a85df0db59e1c05a28 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Wed, 16 Jan 2019 21:12:03 +0530 Subject: [PATCH 15/19] Update TestRequestManager.cs --- src/vstest.console/TestPlatformHelpers/TestRequestManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index c8bc056d39..a87aff8673 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -409,7 +409,7 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List sou { throw new TestPlatformException(string.Format(CultureInfo.CurrentCulture, Resources.TestRunAborted, incompatibleSettingWarning)); } - // If run does not need to be aborted, raise warning messages + // If run does not need to abort, raise warning messages ConsoleLogger.RaiseTestRunWarning(incompatibleSettingWarning); } From e8508463238902f0dbc73cb0c738cd9e4b192f7a Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Mon, 21 Jan 2019 14:20:01 +0530 Subject: [PATCH 16/19] minor change --- .../InferRunSettingsHelper.cs | 4 ++-- src/vstest.console/CommandLine/InferHelper.cs | 13 ------------- .../TestPlatformHelpers/TestRequestManager.cs | 3 +-- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs index 49d425878c..ae40dd70a1 100644 --- a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs +++ b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs @@ -659,7 +659,7 @@ private static bool IsSettingIncompatible(Architecture sourcePlatform, Framework sourceFramework, Framework targetFramework) { - return IsPlatformIncompatible(sourcePlatform, targetPlatform) || IsFrameworkIncompatible(new HashSet() { sourceFramework }, targetFramework); + return IsPlatformIncompatible(sourcePlatform, targetPlatform) || IsFrameworkIncompatible(new List() { sourceFramework }, targetFramework); } @@ -680,7 +680,7 @@ private static bool IsPlatformIncompatible(Architecture sourcePlatform, Architec /// /// Returns true if source Framework or version is incompatible with target Framework or version. /// - public static bool IsFrameworkIncompatible(HashSet sourceFrameworks, Framework targetFramework, bool versionCheckRequired = true) + public static bool IsFrameworkIncompatible(IEnumerable sourceFrameworks, Framework targetFramework, bool versionCheckRequired = true) { foreach (var actualFramework in sourceFrameworks) { diff --git a/src/vstest.console/CommandLine/InferHelper.cs b/src/vstest.console/CommandLine/InferHelper.cs index cbcba2eeaf..f8ad21b2db 100644 --- a/src/vstest.console/CommandLine/InferHelper.cs +++ b/src/vstest.console/CommandLine/InferHelper.cs @@ -24,19 +24,6 @@ internal InferHelper(IAssemblyMetadataProvider assemblyMetadataProvider) this.assemblyMetadataProvider = assemblyMetadataProvider; } - /// - /// Gets list of frameworks from sources - /// - public HashSet GetFrameworksList(IDictionary sourceFrameworks) - { - var frameworkList = new HashSet(); - foreach (var source in sourceFrameworks.Keys) - { - frameworkList.Add(sourceFrameworks[source]); - } - return frameworkList; - } - /// /// Determines Architecture from sources and returns true if source architectures are incompatible /// diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index c8bc056d39..612766ef05 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -399,8 +399,7 @@ private bool UpdateRunSettingsIfRequired(string runsettingsXml, List sou var compatibleSources = InferRunSettingsHelper.FilterCompatibleSources(chosenPlatform, chosenFramework, sourcePlatforms, sourceFrameworks, out var incompatibleSettingWarning); // isSettingIncompatible wil be true if run needs to be aborted due to incompatibility in source and target frameworks - var frameworkList = inferHelper.GetFrameworksList(sourceFrameworks); - var isSettingIncompatible = InferRunSettingsHelper.IsFrameworkIncompatible(frameworkList, chosenFramework, false); + var isSettingIncompatible = InferRunSettingsHelper.IsFrameworkIncompatible(sourceFrameworks.Values.Distinct(), chosenFramework, false); if (!string.IsNullOrEmpty(incompatibleSettingWarning)) { From 3d5b84456b470a3a0d19cee523fdc5d04ebdb11d Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Wed, 23 Jan 2019 11:37:35 +0530 Subject: [PATCH 17/19] minor change --- .../InferRunSettingsHelper.cs | 8 +++++--- .../InferRunSettingsHelperTests.cs | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs index ae40dd70a1..ed69242020 100644 --- a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs +++ b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs @@ -682,11 +682,13 @@ private static bool IsPlatformIncompatible(Architecture sourcePlatform, Architec /// public static bool IsFrameworkIncompatible(IEnumerable sourceFrameworks, Framework targetFramework, bool versionCheckRequired = true) { + bool isFrameworkInCompatible = false; + foreach (var actualFramework in sourceFrameworks) { if (versionCheckRequired) { - return !actualFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase); + isFrameworkInCompatible = isFrameworkInCompatible || !actualFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase); } string sourceFrameworkName = actualFramework.Name.Split(',')[0]; @@ -695,11 +697,11 @@ public static bool IsFrameworkIncompatible(IEnumerable sourceFramewor if (sourceFrameworkName.Equals(DotNetFrameworkString, StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(DotNetCoreString, StringComparison.OrdinalIgnoreCase) || sourceFrameworkName.Equals(DotNetCoreString, StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(DotNetFrameworkString, StringComparison.OrdinalIgnoreCase)) { - return true; + isFrameworkInCompatible = true; } } - return false; + return isFrameworkInCompatible; } } } diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs index 3bdba3b1a2..edd37f064d 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/InferRunSettingsHelperTests.cs @@ -471,8 +471,8 @@ public void FilterCompatibleSourcesShouldRetrunWarningMessageIfNoConflict() [TestMethod] public void IsFrameworkIncompatibleShouldReturnTrueIfNoVersionCheckAndFrameworksIncompatible() { - HashSet sourceFrameworks = new HashSet() { frameworkNet45, frameworkNet47 }; Framework targetFramework = Framework.FromString(".NETCoreApp,Version=1.0"); + HashSet sourceFrameworks = new HashSet() { targetFramework , frameworkNet45, frameworkNet47 }; bool isFrameworkIncompatible = InferRunSettingsHelper.IsFrameworkIncompatible(sourceFrameworks, targetFramework, false); Assert.IsTrue(isFrameworkIncompatible); @@ -481,7 +481,7 @@ public void IsFrameworkIncompatibleShouldReturnTrueIfNoVersionCheckAndFrameworks [TestMethod] public void IsFrameworkIncompatibleShouldReturnFalseIfNoVersionCheckAndFrameworksHaveDifferentVersions() { - HashSet sourceFrameworks = new HashSet() { frameworkNet45, frameworkNet47 }; + HashSet sourceFrameworks = new HashSet() { frameworkNet46, frameworkNet45, frameworkNet47 }; Framework targetFramework = frameworkNet46; bool isFrameworkIncompatible = InferRunSettingsHelper.IsFrameworkIncompatible(sourceFrameworks, targetFramework, false); From 6bcc76c55802e9fc355fcbed7bd92c99dab2fc53 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Tue, 12 Feb 2019 12:28:54 +0530 Subject: [PATCH 18/19] Modified logic in IsFrameworkIncompatible --- .../InferRunSettingsHelper.cs | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs index ed69242020..c9652abfc2 100644 --- a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs +++ b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs @@ -49,8 +49,6 @@ public class InferRunSettingsHelper private const string LegacyElementsString = "Elements"; private const string DeploymentAttributesString = "DeploymentAttributes"; private const string ExecutionAttributesString = "ExecutionAttributes"; - private const string DotNetFrameworkString = ".NETFramework"; - private const string DotNetCoreString = ".NETCoreApp"; private static readonly List ExecutionNodesPaths = new List { @"/RunSettings/LegacySettings/Execution/TestTypeSpecific/UnitTestRunConfig/AssemblyResolution", @"/RunSettings/LegacySettings/Execution/Timeouts", @"/RunSettings/LegacySettings/Execution/Hosts" }; /// @@ -689,15 +687,21 @@ public static bool IsFrameworkIncompatible(IEnumerable sourceFramewor if (versionCheckRequired) { isFrameworkInCompatible = isFrameworkInCompatible || !actualFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase); - } - - string sourceFrameworkName = actualFramework.Name.Split(',')[0]; - string targetFrameworkName = targetFramework.Name.Split(',')[0]; - if (sourceFrameworkName.Equals(DotNetFrameworkString, StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(DotNetCoreString, StringComparison.OrdinalIgnoreCase) || - sourceFrameworkName.Equals(DotNetCoreString, StringComparison.OrdinalIgnoreCase) && targetFrameworkName.Equals(DotNetFrameworkString, StringComparison.OrdinalIgnoreCase)) + if (isFrameworkInCompatible) + { + return true; + } + } + else { - isFrameworkInCompatible = true; + string sourceFrameworkName = actualFramework.Name.Split(',')[0]; + string targetFrameworkName = targetFramework.Name.Split(',')[0]; + + if (!sourceFrameworkName.Equals(targetFrameworkName, StringComparison.OrdinalIgnoreCase)) + { + isFrameworkInCompatible = true; + } } } From 53b609b7e5fad330868b895d337717e83d875c88 Mon Sep 17 00:00:00 2001 From: Vagisha Nidhi Date: Wed, 13 Feb 2019 13:37:45 +0530 Subject: [PATCH 19/19] Removing unused variable --- .../InferRunSettingsHelper.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs index c9652abfc2..8ad00f096f 100644 --- a/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs +++ b/src/Microsoft.TestPlatform.Utilities/InferRunSettingsHelper.cs @@ -680,15 +680,11 @@ private static bool IsPlatformIncompatible(Architecture sourcePlatform, Architec /// public static bool IsFrameworkIncompatible(IEnumerable sourceFrameworks, Framework targetFramework, bool versionCheckRequired = true) { - bool isFrameworkInCompatible = false; - foreach (var actualFramework in sourceFrameworks) { if (versionCheckRequired) { - isFrameworkInCompatible = isFrameworkInCompatible || !actualFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase); - - if (isFrameworkInCompatible) + if (!actualFramework.Name.Equals(targetFramework.Name, StringComparison.OrdinalIgnoreCase)) { return true; } @@ -700,12 +696,12 @@ public static bool IsFrameworkIncompatible(IEnumerable sourceFramewor if (!sourceFrameworkName.Equals(targetFrameworkName, StringComparison.OrdinalIgnoreCase)) { - isFrameworkInCompatible = true; + return true; } } } - return isFrameworkInCompatible; + return false; } } }