diff --git a/src/Adapter/MSTest.TestAdapter/Execution/TestExecutionManager.cs b/src/Adapter/MSTest.TestAdapter/Execution/TestExecutionManager.cs index e05a6e1b02..a5e145fd8f 100644 --- a/src/Adapter/MSTest.TestAdapter/Execution/TestExecutionManager.cs +++ b/src/Adapter/MSTest.TestAdapter/Execution/TestExecutionManager.cs @@ -401,10 +401,12 @@ private void ExecuteTestsInSource(IEnumerable tests, IRunContext? runC ExecuteTestsWithTestRunner(testsToRun, frameworkHandle, source, sourceLevelParameters, testRunner); } +#if !WINDOWS_UWP if (MSTestGracefulStopTestExecutionCapability.Instance.IsStopRequested) { testRunner.ForceCleanup(); } +#endif PlatformServiceProvider.Instance.AdapterTraceLogger.LogInfo("Executed tests belonging to source {0}", source); } @@ -426,10 +428,12 @@ private void ExecuteTestsWithTestRunner( foreach (TestCase currentTest in orderedTests) { _testRunCancellationToken?.ThrowIfCancellationRequested(); +#if !WINDOWS_UWP if (MSTestGracefulStopTestExecutionCapability.Instance.IsStopRequested) { break; } +#endif // If it is a fixture test, add it to the list of fixture tests and do not execute it. // It is executed by test itself. diff --git a/src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj b/src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj index f2471f2e19..50aae952d1 100644 --- a/src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj +++ b/src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj @@ -48,7 +48,8 @@ - + Analyzer false diff --git a/src/Adapter/MSTest.TestAdapter/MSTestSettings.cs b/src/Adapter/MSTest.TestAdapter/MSTestSettings.cs index 1870ce1d62..1be800f802 100644 --- a/src/Adapter/MSTest.TestAdapter/MSTestSettings.cs +++ b/src/Adapter/MSTest.TestAdapter/MSTestSettings.cs @@ -8,7 +8,9 @@ using Microsoft.Testing.Platform.Configurations; using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel; +#if !WINDOWS_UWP using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices; +#endif using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; @@ -263,7 +265,9 @@ public static void PopulateSettings(MSTestSettings settings) [Obsolete("this function will be removed in v4.0.0")] public static void PopulateSettings(IDiscoveryContext? context) => PopulateSettings(context, null, null); - private static bool IsRunSettingsFileHasMSTestSettings(string? runSettingsXml) => IsRunSettingsFileHasSettingName(runSettingsXml, SettingsName) || IsRunSettingsFileHasSettingName(runSettingsXml, SettingsNameAlias); +#if !WINDOWS_UWP + private static bool IsRunSettingsFileHasMSTestSettings(string? runSettingsXml) + => IsRunSettingsFileHasSettingName(runSettingsXml, SettingsName) || IsRunSettingsFileHasSettingName(runSettingsXml, SettingsNameAlias); private static bool IsRunSettingsFileHasSettingName(string? runSettingsXml, string SettingName) { @@ -288,6 +292,7 @@ private static bool IsRunSettingsFileHasSettingName(string? runSettingsXml, stri return !reader.EOF; } +#endif /// /// Populate adapter settings from the context. @@ -298,16 +303,25 @@ private static bool IsRunSettingsFileHasSettingName(string? runSettingsXml, stri /// internal static void PopulateSettings(IDiscoveryContext? context, IMessageLogger? logger, IConfiguration? configuration) { - if (configuration?["mstest"] != null && context?.RunSettings != null && IsRunSettingsFileHasMSTestSettings(context.RunSettings.SettingsXml)) +#if !WINDOWS_UWP + if (configuration?["mstest"] != null + && context?.RunSettings != null + && IsRunSettingsFileHasMSTestSettings(context.RunSettings.SettingsXml)) { throw new InvalidOperationException(Resource.DuplicateConfigurationError); } +#endif // This will contain default adapter settings var settings = new MSTestSettings(); var runConfigurationSettings = RunConfigurationSettings.PopulateSettings(context); - if (!StringEx.IsNullOrEmpty(context?.RunSettings?.SettingsXml) && configuration?["mstest"] is null) +#if !WINDOWS_UWP + if (!StringEx.IsNullOrEmpty(context?.RunSettings?.SettingsXml) + && configuration?["mstest"] is null) +#else + if (!StringEx.IsNullOrEmpty(context?.RunSettings?.SettingsXml)) +#endif { MSTestSettings? aliasSettings = GetSettings(context.RunSettings.SettingsXml, SettingsNameAlias, logger); @@ -325,11 +339,13 @@ internal static void PopulateSettings(IDiscoveryContext? context, IMessageLogger SetGlobalSettings(context.RunSettings.SettingsXml, settings, logger); } +#if !WINDOWS_UWP else if (configuration?["mstest"] is not null) { RunConfigurationSettings.SetRunConfigurationSettingsFromConfig(configuration, runConfigurationSettings); SetSettingsFromConfig(configuration, logger, settings); } +#endif CurrentSettings = settings; RunConfigurationSettings = runConfigurationSettings; @@ -877,6 +893,7 @@ private static void SetGlobalSettings( } } +#if !WINDOWS_UWP private static void ParseBooleanSetting(IConfiguration configuration, string key, IMessageLogger? logger, Action setSetting) { if (configuration[$"mstest:{key}"] is not string value) @@ -1033,4 +1050,5 @@ internal static void SetSettingsFromConfig(IConfiguration configuration, IMessag MSTestSettingsProvider.Load(configuration); } +#endif } diff --git a/src/Adapter/MSTest.TestAdapter/RunConfigurationSettings.cs b/src/Adapter/MSTest.TestAdapter/RunConfigurationSettings.cs index d7009797eb..e9a1701c71 100644 --- a/src/Adapter/MSTest.TestAdapter/RunConfigurationSettings.cs +++ b/src/Adapter/MSTest.TestAdapter/RunConfigurationSettings.cs @@ -2,10 +2,14 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Diagnostics.CodeAnalysis; -using System.Globalization; using System.Xml; +#if !WINDOWS_UWP +using System.Globalization; + using Microsoft.Testing.Platform.Configurations; +#endif + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; @@ -166,6 +170,7 @@ private static RunConfigurationSettings ToSettings(XmlReader reader) return settings; } +#if !WINDOWS_UWP internal static RunConfigurationSettings SetRunConfigurationSettingsFromConfig(IConfiguration configuration, RunConfigurationSettings settings) { // Expected format of the json is: - @@ -195,4 +200,5 @@ internal static RunConfigurationSettings SetRunConfigurationSettingsFromConfig(I return settings; } +#endif } diff --git a/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestGracefulStopTestExecutionCapability.cs b/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestGracefulStopTestExecutionCapability.cs index a8ef89ff47..986e45c004 100644 --- a/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestGracefulStopTestExecutionCapability.cs +++ b/src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestGracefulStopTestExecutionCapability.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +#if !WINDOWS_UWP using Microsoft.Testing.Platform.Capabilities.TestFramework; namespace Microsoft.VisualStudio.TestTools.UnitTesting; @@ -23,3 +24,4 @@ public Task StopTestExecutionAsync(CancellationToken cancellationToken) return Task.CompletedTask; } } +#endif diff --git a/src/Adapter/MSTestAdapter.PlatformServices/Interfaces/IConfiguration.cs b/src/Adapter/MSTestAdapter.PlatformServices/Interfaces/IConfiguration.cs new file mode 100644 index 0000000000..4a177a55d9 --- /dev/null +++ b/src/Adapter/MSTestAdapter.PlatformServices/Interfaces/IConfiguration.cs @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#if WINDOWS_UWP +namespace Microsoft.Testing.Platform.Configurations; + +internal interface IConfiguration +{ +} +#endif diff --git a/src/Adapter/MSTestAdapter.PlatformServices/MSTestAdapter.PlatformServices.csproj b/src/Adapter/MSTestAdapter.PlatformServices/MSTestAdapter.PlatformServices.csproj index 4be35846e8..afa1b916ed 100644 --- a/src/Adapter/MSTestAdapter.PlatformServices/MSTestAdapter.PlatformServices.csproj +++ b/src/Adapter/MSTestAdapter.PlatformServices/MSTestAdapter.PlatformServices.csproj @@ -1,4 +1,4 @@ - + @@ -31,7 +31,8 @@ - + Analyzer false @@ -39,6 +40,7 @@ + diff --git a/src/Adapter/MSTestAdapter.PlatformServices/PublicAPI/uap10.0.16299/PublicAPI.Unshipped.txt b/src/Adapter/MSTestAdapter.PlatformServices/PublicAPI/uap10.0.16299/PublicAPI.Unshipped.txt index 815c92006a..7dc5c58110 100644 --- a/src/Adapter/MSTestAdapter.PlatformServices/PublicAPI/uap10.0.16299/PublicAPI.Unshipped.txt +++ b/src/Adapter/MSTestAdapter.PlatformServices/PublicAPI/uap10.0.16299/PublicAPI.Unshipped.txt @@ -1 +1 @@ -#nullable enable \ No newline at end of file +#nullable enable